You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@twill.apache.org by ch...@apache.org on 2020/03/16 01:37:57 UTC
[twill] branch master updated: (TWILL-259) Expands environment
variables in classpath
This is an automated email from the ASF dual-hosted git repository.
chtyim pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/twill.git
The following commit(s) were added to refs/heads/master by this push:
new 29bea34 (TWILL-259) Expands environment variables in classpath
29bea34 is described below
commit 29bea3409ced14a269d07cf1d91d60aae872d49e
Author: Terence Yim <te...@google.com>
AuthorDate: Sun Mar 15 15:07:16 2020 -0700
(TWILL-259) Expands environment variables in classpath
This fixes #89 on GitHub.
Signed-off-by: Terence Yim <te...@google.com>
---
.../java/org/apache/twill/launcher/TwillLauncher.java | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/twill-core/src/main/java/org/apache/twill/launcher/TwillLauncher.java b/twill-core/src/main/java/org/apache/twill/launcher/TwillLauncher.java
index 056639f..3e41592 100644
--- a/twill-core/src/main/java/org/apache/twill/launcher/TwillLauncher.java
+++ b/twill-core/src/main/java/org/apache/twill/launcher/TwillLauncher.java
@@ -85,14 +85,8 @@ public final class TwillLauncher {
// For backward compatibility, sort jars from twill and jars from application together
// With TWILL-179, this will change as the user can have control on how it should be.
- List<File> libJarFiles = listJarFiles(new File(appJarDir, "lib"), new ArrayList<File>());
- Collections.sort(listJarFiles(new File(twillJarDir, "lib"), libJarFiles), new Comparator<File>() {
- @Override
- public int compare(File file1, File file2) {
- // order by the file name only. If the name are the same, the one in application jar will prevail.
- return file1.getName().compareTo(file2.getName());
- }
- });
+ List<File> libJarFiles = listJarFiles(new File(appJarDir, "lib"), new ArrayList<>());
+ listJarFiles(new File(twillJarDir, "lib"), libJarFiles).sort(Comparator.comparing(File::getName));
// Add the app jar, resources jar and twill jar directories to the classpath as well
for (File dir : Arrays.asList(appJarDir, twillJarDir)) {
@@ -115,7 +109,7 @@ public final class TwillLauncher {
}
addClassPathsToList(urls, new File(Constants.Files.RUNTIME_CONFIG_JAR, Constants.Files.APPLICATION_CLASSPATH));
- return urls.toArray(new URL[urls.size()]);
+ return urls.toArray(new URL[0]);
}
/**
@@ -148,7 +142,7 @@ public final class TwillLauncher {
try (BufferedReader reader = Files.newBufferedReader(classpathFile.toPath(), StandardCharsets.UTF_8)) {
String line = reader.readLine();
if (line != null) {
- for (String path : line.split(":")) {
+ for (String path : expand(line).split(":")) {
urls.addAll(getClassPaths(path.trim()));
}
}
@@ -160,7 +154,7 @@ public final class TwillLauncher {
if (classpath.endsWith("/*")) {
// Grab all .jar files
File dir = new File(classpath.substring(0, classpath.length() - 2));
- List<File> files = listJarFiles(dir, new ArrayList<File>());
+ List<File> files = listJarFiles(dir, new ArrayList<>());
Collections.sort(files);
if (files.isEmpty()) {
return singleItem(dir.toURI().toURL());