Skip to content

Commit

Permalink
Fix #781 - all p2 items and embedded jars must be considered optional
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Läubrich <laeubi@laeubi-soft.de>
  • Loading branch information
laeubi committed Mar 18, 2022
1 parent 8722235 commit bb105b0
Showing 1 changed file with 13 additions and 4 deletions.
Expand Up @@ -34,6 +34,8 @@
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.eclipse.tycho.PackagingType;
import org.eclipse.tycho.TychoConstants;

/**
* Updates the pom file with the dependencies from the tycho model. If you
Expand Down Expand Up @@ -109,10 +111,12 @@ public void execute() throws MojoExecutionException, MojoFailureException {
List<Dependency> list = Objects.requireNonNullElse(project.getDependencies(), Collections.emptyList());
for (Dependency dep : list) {
Dependency copy = dep.clone();
copy.setSystemPath(null);
if (dep.getGroupId().startsWith("p2.eclipse.") && Artifact.SCOPE_SYSTEM.equals(dep.getScope())) {
copy.setOptional(true);
copy.setScope(Artifact.SCOPE_PROVIDED);
if (Artifact.SCOPE_SYSTEM.equals(dep.getScope())) {
if (dep.getGroupId().startsWith(TychoConstants.P2_GROUPID_PREFIX) || isEmbeddedJar(dep)) {
copy.setOptional(true);
copy.setScope(Artifact.SCOPE_PROVIDED);
copy.setSystemPath(null);
}
}
dependencies.add(copy);
}
Expand All @@ -139,4 +143,9 @@ public void execute() throws MojoExecutionException, MojoFailureException {

}

private boolean isEmbeddedJar(Dependency dep) {
return PackagingType.TYPE_ECLIPSE_PLUGIN.equals(dep.getType()) && dep.getClassifier() != null
&& !dep.getClassifier().isBlank();
}

}

0 comments on commit bb105b0

Please sign in to comment.