Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ _site/
/Gemfile.lock
/push_docs.sh
/copy_blog.sh
*/out/*
12 changes: 4 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
language: java
sudo: false
install: gradle -q assemble
script: gradle -i check
install: ./gradlew -q assemble
script: ./gradlew -i check
jdk:
- oraclejdk7
- oraclejdk8

branches:
Expand All @@ -13,12 +12,9 @@ branches:
env:
global:
- TERM=dumb
- secure: "XzCjWbN5BM2ioZy+1GVcFuHVUwX8YHjuved7gZ0CAHp1pMyhPudzZqlLZ2ZWKv44sVS/ZM4ylwbO4JFGyJcobd5/CeP+iJpYPRGas4EYWIuA882K3NgBEn8smnaxy/PcrQwl9QVhnMrsVu8KrmB/dHwBphMyfAT65+2eiQbQWRk="

after_success:
- gradle jacocoRootReport coveralls
# - bash <(curl -s https://codecov.io/bash)
- ./gradlew jacocoRootReport coveralls
- bash <(curl -s https://codecov.io/bash)

notifications:
slack: puniverse:OsnbakHrYeTcLyalVgtUeI4F

12 changes: 6 additions & 6 deletions capsule-util/src/main/java/co/paralleluniverse/capsule/Jar.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import java.util.jar.JarInputStream;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import java.util.jar.Pack200;
//import java.util.jar.Pack200;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import static java.nio.charset.StandardCharsets.UTF_8;
Expand All @@ -56,7 +56,7 @@ public class Jar {
private final Manifest manifest;
private final JarInputStream jis;
private JarOutputStream jos;
private Pack200.Packer packer;
//private Pack200.Packer packer;
private String jarPrefixStr;
private Path jarPrefixFile;
private boolean sealed;
Expand Down Expand Up @@ -567,10 +567,10 @@ private static void addEntry(JarOutputStream jarOut, String path, byte[] data) t
* @param packer
* @return {@code this}
*/
public Jar setPacker(Pack200.Packer packer) {
/*public Jar setPacker(Pack200.Packer packer) {
this.packer = packer;
return this;
}
}*/

/**
* If set to true true, a header will be added to the JAR file when written, that will make the JAR an executable file in POSIX environments.
Expand Down Expand Up @@ -706,9 +706,9 @@ public <T extends OutputStream> T write(T os) throws IOException {
throw new IllegalStateException("Cannot write to another target if setOutputStream has been called");
final byte[] content = ((ByteArrayOutputStream) this.os).toByteArray();

if (packer != null)
/*if (packer != null)
packer.pack(new JarInputStream(new ByteArrayInputStream(content)), os);
else
else*/
os.write(content);

os.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private static Object[] process(Path[] paths) throws IOException {
final Path p = paths[i];
final Object o;
if (Files.isRegularFile(p))
o = FileSystems.newFileSystem(p, null);
o = FileSystems.newFileSystem(p.toUri(), null, null);
else
o = p;
os[i] = o;
Expand Down
18 changes: 10 additions & 8 deletions capsule/src/main/java/Capsule.java
Original file line number Diff line number Diff line change
Expand Up @@ -4160,17 +4160,19 @@ private static Path getJavaExecutable0(Path javaHome) {
return javaHome.resolve("bin").resolve(exec + (isWindows() ? ".exe" : ""));
}

private static final Pattern PAT_JAVA_VERSION_LINE = Pattern.compile(".*?\"(.+?)\"");
private static final Pattern PAT_JAVA_VERSION_LINE = Pattern.compile(".*?\"(.+?)\".*");

static String parseJavaVersionLine(String versionLine) {
final Matcher m = PAT_JAVA_VERSION_LINE.matcher(versionLine);
if (!m.matches())
throw new IllegalArgumentException("Could not parse version line: " + versionLine);
return m.group(1);
}

private static String getActualJavaVersion(Path javaHome) {
try {
final String versionLine = first(exec(1, true, new ProcessBuilder(asList(getJavaExecutable0(javaHome).toString(), "-version"))));
final Matcher m = PAT_JAVA_VERSION_LINE.matcher(versionLine);
if (!m.matches())
throw new IllegalArgumentException("Could not parse version line: " + versionLine);
final String version = m.group(1);

return version;
return parseJavaVersionLine(versionLine);
} catch (Exception e) {
throw rethrow(e);
}
Expand Down Expand Up @@ -4250,7 +4252,7 @@ private static boolean equals(int[] a, int[] b, int n) {
return true;
}

private static final Pattern PAT_JAVA_VERSION = Pattern.compile("(?<major>\\d+)(\\.(?<minor>\\d+))?(?:\\.(?<patch>\\d+))?(_(?<update>\\d+))?(-(?<pre>[^-]+))?(-(?<build>.+))?");
private static final Pattern PAT_JAVA_VERSION = Pattern.compile("(?<major>\\d+)(\\.(?<minor>\\d+))?(?:\\.(?<patch>\\d+))?[0-9.]*(_(?<update>\\d+))?(-(?<pre>[^-]+))?(-(?<build>.+))?");

// visible for testing
static int[] parseJavaVersion(String v) {
Expand Down
13 changes: 13 additions & 0 deletions capsule/src/test/java/CapsuleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,10 @@ public void testParseJavaVersion() {
ver = Capsule.parseJavaVersion("1.8.0_30-ea");
assertArrayEquals(ver, ints(1, 8, 0, 30, -3));
assertEquals("1.8.0_30-ea", Capsule.toJavaVersionString(ver));

ver = Capsule.parseJavaVersion("11.0.14.1");
assertArrayEquals(ver, ints(1, 11, 14, 0, 0));
assertEquals("1.11.14", Capsule.toJavaVersionString(ver));
}

@Test
Expand Down Expand Up @@ -1571,6 +1575,15 @@ public void testPathingJar() throws Exception {
}
//</editor-fold>

@Test
public void testParseJavaVersionLine() {
assertEquals("1.8.0_161", Capsule.parseJavaVersionLine("java version \"1.8.0_161\""));
assertEquals("9.0.4", Capsule.parseJavaVersionLine("java version \"9.0.4\""));
assertEquals("10", Capsule.parseJavaVersionLine("java version \"10\" 2018-03-20"));
assertEquals("11", Capsule.parseJavaVersionLine("java version \"11\" 2018-09-25"));
assertEquals("10.0.2", Capsule.parseJavaVersionLine("openjdk version \"10.0.2\" 2018-07-17"));
}

//<editor-fold defaultstate="collapsed" desc="Utilities">
/////////// Utilities ///////////////////////////////////
// may be called once per test (always writes jar into /capsule.jar)
Expand Down
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
172 changes: 172 additions & 0 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.