Skip to content

Commit

Permalink
Fixed build
Browse files Browse the repository at this point in the history
- coverage
- code cleanup
- update informations in pom.xml, some plugin updates
- stop shallow clone to remove warning in SonarCloud
- added link to sonarcloud
  • Loading branch information
Luigi R. Viggiano committed Sep 3, 2019
1 parent 913369b commit 281abb8
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 119 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
sudo: required
dist: trusty
group: edge
git:
depth: false

language: java
jdk:
Expand All @@ -16,7 +18,7 @@ os:

install: mvn -B -V -DskipTests=true -Dmaven.javadoc.skip=true install
script: mvn -B -V test
after_success: if [[ $JAVA_HOME =~ java-9 ]] ; then mvn -B -V -Pcoverage clean verify sonar:sonar; fi
after_success: if [[ $JAVA_HOME =~ java-9 ]] ; then mvn -B -V -Pcoverage clean verify sonar:sonar coveralls:report; fi

addons:
apt:
Expand Down
24 changes: 14 additions & 10 deletions owner-extras/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@
<description>Extras for OWNER library</description>
<packaging>jar</packaging>

<profiles>
<profile>
<id>coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<dependencies>
<dependency>
<groupId>org.aeonbits.owner</groupId>
Expand Down Expand Up @@ -58,16 +72,6 @@
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<!--
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
</plugin>
-->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
Expand Down
25 changes: 15 additions & 10 deletions owner-java8-extras/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,27 @@
<properties>
<compiler-release>8</compiler-release>
</properties>

<profiles>
<profile>
<id>coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<plugins>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<!--
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
</plugin>
-->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* @author Stefan Freyr Stefansson
*/
class ConverterUtil {

// Suppresses default constructor, ensuring no one instantiate this class.
private ConverterUtil() {}

/**
* Splits a string into a numeric part and a character part. The input string should conform to the format
* <code>[numeric_part][char_part]</code> with an optional whitespace between the two parts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,4 @@ private static Duration parseDuration(String input) {

return Duration.of(Long.parseLong(numberString), units);
}

private static String getUnits(String s) {
int i = s.length() - 1;
while (i >= 0) {
char c = s.charAt(i);
if (!Character.isLetter(c))
break;
i -= 1;
}
return s.substring(i + 1);
}
}
24 changes: 14 additions & 10 deletions owner-java8/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,26 @@
<compiler-release>8</compiler-release>
</properties>

<profiles>
<profile>
<id>coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<plugins>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<!--
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
</plugin>
-->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
Expand Down
6 changes: 1 addition & 5 deletions owner-site/site/_includes/docs_contents.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,9 @@ <h4>Other stuff</h4>
<li><a href="https://github.com/lviggiano/owner/releases">Releases</a></li>
<li><a href="https://t.me/ownerapi">Telegram Chat</a></li>
<li><a href="https://travis-ci.org/lviggiano/owner">Travis CI reports</a></li>
<li><a href="https://sonarcloud.io/dashboard?id=org.aeonbits.owner%3Aowner-parent">Sonar reports</a></li>
<li><a href="https://coveralls.io/r/lviggiano/owner">Coveralls reports</a></li>
<li><a href="https://www.ohloh.net/p/owner">OWNER at Ohloh</a></li>
<!-- Newinstance and dev.aeonbits.org servers are gone, cloudbees is not reliable.
<li><a href="https://aeonbits.ci.cloudbees.com/job/owner-api/">Jenkins reports</a></li>
<li><a href="http://dev.aeonbits.org:9000/dashboard/index/org.aeonbits.owner:owner">Sonar reports</a></li>
<li><a href="http://newinstance.it/owner/latest/">Maven site</a></li>
-->
</ul>

</aside>
Expand Down
6 changes: 1 addition & 5 deletions owner-site/site/_includes/docs_contents_mobile.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,9 @@
<option value="https://github.com/lviggiano/owner/releases">Releases</option>
<option value="https://t.me/ownerapi">Telegram Chat</option>
<option value="https://travis-ci.org/lviggiano/owner">Travis CI reports</option>
<option value="https://sonarcloud.io/dashboard?id=org.aeonbits.owner%3Aowner-parent">Sonar reports</option>
<option value="https://coveralls.io/r/lviggiano/owner">Coveralls reports</option>
<option value="https://www.ohloh.net/p/owner">OWNER at Ohloh</option>
<!-- Newinstance and dev.aeonbits.org servers are gone, cloudbees is not reliable.
<option value="https://aeonbits.ci.cloudbees.com/job/owner-api/">Jenkins reports</option>
<option value="http://dev.aeonbits.org:9000/dashboard/index/org.aeonbits.owner:owner">Sonar reports</option>
<option value="http://newinstance.it/owner/latest/">Maven site</option>
-->
</optgroup>

</select>
Expand Down
24 changes: 14 additions & 10 deletions owner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@
<description>Get rid of the boilerplate code in Java properties based configuration.</description>
<packaging>jar</packaging>

<profiles>
<profile>
<id>coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<dependencies>
<!-- Order matters -->
<dependency>
Expand Down Expand Up @@ -50,16 +64,6 @@
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<!--
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
</plugin>
-->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
Expand Down
3 changes: 3 additions & 0 deletions owner/src/main/java/org/aeonbits/owner/util/Base64.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public class Base64 {
private static Object decoderObject;
private static Object encoderObject;

// Suppresses default constructor, ensuring no one instantiate this class.
private Base64() {}

static {
Class<?>[] decodeParameterTypes = { String.class };
Class<?>[] encodeParameterTypes = { byte[].class };
Expand Down
20 changes: 19 additions & 1 deletion owner/src/main/java/org/aeonbits/owner/util/Collections.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
public abstract class Collections {

// Suppresses default constructor, ensuring non-instantiability.
// Suppresses default constructor, ensuring no one instantiate this class.
private Collections() {}

private static final class EntryMap<K, V> extends AbstractMap<K, V> implements Serializable {
Expand All @@ -55,6 +55,24 @@ private EntryMap(Entry<? extends K, ? extends V>... entries) {
public Set<Entry<K, V>> entrySet() {
return (Set) entries;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;

EntryMap<?, ?> entryMap = (EntryMap<?, ?>) o;

return entries.equals(entryMap.entries);
}

@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + entries.hashCode();
return result;
}
}

public static <K, V> Entry<K, V> entry(K key, V value) {
Expand Down
5 changes: 2 additions & 3 deletions owner/src/main/java/org/aeonbits/owner/util/Reflection.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
*/
public final class Reflection {

// Suppresses default LOOKUP_CONSTRUCTOR, ensuring non-instantiability.
private Reflection() {
}
// Suppresses default constructor, ensuring no one instantiate this class.
private Reflection() {}

public static boolean isClassAvailable(String className) {
return forName(className) != null;
Expand Down
34 changes: 23 additions & 11 deletions owner/src/main/java/org/aeonbits/owner/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,18 @@ public static <T> T[] reverse(T[] array) {

public static String expandUserHome(String text) {
if (text.equals("~"))
return system.getProperty("user.home");
return getUserHome();
if (text.indexOf("~/") == 0 || text.indexOf("file:~/") == 0 || text.indexOf("jar:file:~/") == 0)
return text.replaceFirst("~/", Matcher.quoteReplacement(system.getProperty("user.home")) + "/");
return text.replaceFirst("~/", Matcher.quoteReplacement(getUserHome()) + "/");
if (text.indexOf("~\\") == 0 || text.indexOf("file:~\\") == 0 || text.indexOf("jar:file:~\\") == 0)
return text.replaceFirst("~\\\\", Matcher.quoteReplacement(system.getProperty("user.home")) + "\\\\");
return text.replaceFirst("~\\\\", Matcher.quoteReplacement(getUserHome()) + "\\\\");
return text;
}

private static String getUserHome() {
return system.getProperty("user.home");
}

public static String fixBackslashesToSlashes(String path) {
return path.replace('\\', '/');
}
Expand Down Expand Up @@ -238,17 +242,25 @@ private static void rename(File source, File target) throws IOException {
private static void storeJar(File target, String entryName, Properties props) throws IOException {
byte[] bytes = toBytes(props);
InputStream input = new ByteArrayInputStream(bytes);
JarOutputStream output = new JarOutputStream(new FileOutputStream(target));
try {
ZipEntry entry = new ZipEntry(entryName);
output.putNextEntry(entry);
byte[] buffer = new byte[4096];
int size;
while ((size = input.read(buffer)) != -1)
output.write(buffer, 0, size);
FileOutputStream fileOutputStream = new FileOutputStream(target);
try {
JarOutputStream output = new JarOutputStream(fileOutputStream);
try {
ZipEntry entry = new ZipEntry(entryName);
output.putNextEntry(entry);
byte[] buffer = new byte[4096];
int size;
while ((size = input.read(buffer)) != -1)
output.write(buffer, 0, size);
} finally {
output.close();
}
} finally {
fileOutputStream.close();
}
} finally {
input.close();
output.close();
}
}

Expand Down
Loading

0 comments on commit 281abb8

Please sign in to comment.