Skip to content

Commit

Permalink
Merge pull request #147 from ascopes/bugfix/classpath-flag-ordering
Browse files Browse the repository at this point in the history
Fix order of -classpath flag in JvmPluginResolver
  • Loading branch information
ascopes committed Apr 7, 2024
1 parent 3351b85 commit ffc2163
Showing 1 changed file with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.inject.Inject;
Expand Down Expand Up @@ -108,26 +109,33 @@ private List<String> resolveAndBuildArgLine(
.iterator();

// First dependency is always the thing we actually want to execute,
// so is guaranteed to be present.
// so is guaranteed to be present. Marked as final to avoid checkstyle complaining
// about the distance between declaration and usage.
final var pluginPath = dependencyIterator.next();
var args = new ArrayList<String>();
args.add("java");
args.add("-jar");
args.add(dependencyIterator.next().toString());

if (dependencyIterator.hasNext()) {
var sb = new StringBuilder().append(dependencyIterator.next());

while (dependencyIterator.hasNext()) {
sb.append(":").append(dependencyIterator.next());
}

args.add("-classpath");
args.add(sb.toString());
args.add(buildClasspath(dependencyIterator));
}

args.add("-jar");
args.add(pluginPath.toString());

return args;
}

private String buildClasspath(Iterator<Path> paths) {
var sb = new StringBuilder().append(paths.next());

while (paths.hasNext()) {
sb.append(":").append(paths.next());
}

return sb.toString();
}

private String pluginIdDigest(DependableCoordinate dependableCoordinate) {
var digestableString = String.join(
":",
Expand Down

0 comments on commit ffc2163

Please sign in to comment.