Skip to content

Commit

Permalink
Resolve Attach libraries for runagent goal (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinayagarwal authored Jun 11, 2021
1 parent 5ad4e4e commit 4f4e844
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/main/java/com/gluonhq/NativeRunAgentMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

package com.gluonhq;

import com.gluonhq.attach.AttachArtifactResolver;
import com.gluonhq.attach.AttachService;
import org.apache.maven.model.Model;
import org.apache.maven.model.Profile;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
Expand Down Expand Up @@ -133,7 +135,16 @@ public void execute() throws MojoExecutionException {
}, () -> getLog().warn("No JavaFX plugin found",
new MojoExecutionException("No JavaFX plugin found")));

// 6. Serialize new pom
// 6. Check for Attach Dependencies and if Desktop is supported, add the classifier
model.getDependencies().stream()
.filter(p -> p.getGroupId().equalsIgnoreCase(AttachArtifactResolver.DEPENDENCY_GROUP))
.filter(p -> Arrays.stream(AttachService.values())
.filter(AttachService::isDesktopSupported)
.anyMatch(attach -> attach.getServiceName().equalsIgnoreCase(p.getArtifactId()))
)
.forEach(p -> p.setClassifier("desktop"));

// 7. Serialize new pom
try (OutputStream os = new FileOutputStream(agentPomFile)) {
new MavenXpp3Writer().write(os, model);
}
Expand All @@ -148,7 +159,7 @@ public void execute() throws MojoExecutionException {
invocationRequest.setGoals(Collections.singletonList("javafx:run"));

final Invoker invoker = new DefaultInvoker();
// 7. Execute:
// 8. Execute:
try {
final InvocationResult invocationResult = invoker.execute(invocationRequest);
if (invocationResult.getExitCode() != 0) {
Expand Down

0 comments on commit 4f4e844

Please sign in to comment.