Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix order of -classpath flag in JvmPluginResolver #147

Merged
merged 1 commit into from
Apr 5, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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 @@ -110,26 +111,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(MavenArtifact plugin) {
return Digests.sha1(plugin.toString());
}
Expand Down
Loading