Skip to content

Commit

Permalink
Use main artifact p2-maven-repository packaging and default execution
Browse files Browse the repository at this point in the history
If the MavenP2SiteMojo is used as part of the p2-maven-repository
packaging and we are in the default executions do not attach an artifact
but set the main one.
  • Loading branch information
laeubi committed Nov 28, 2023
1 parent 92a7c2a commit a8a6e8b
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@

import org.apache.commons.io.FileUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
Expand All @@ -66,6 +68,7 @@
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.tycho.PackagingType;
import org.eclipse.tycho.TychoConstants;
import org.eclipse.tycho.core.PGPService;
import org.eclipse.tycho.p2maven.tools.TychoFeaturesAndBundlesPublisherApplication;
Expand Down Expand Up @@ -215,6 +218,9 @@ public class MavenP2SiteMojo extends AbstractMojo {
@Parameter(defaultValue = INCLUDE_PGP_DEFAULT + "")
private boolean includePGPSignature = INCLUDE_PGP_DEFAULT;

@Parameter(property = "mojoExecution", readonly = true)
MojoExecution execution;

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
//fetch a random service to make sure OSGi framework is there ... even if the service is (yet) not used
Expand Down Expand Up @@ -399,7 +405,14 @@ public void execute() throws MojoExecutionException, MojoFailureException {
} catch (IOException e) {
throw new MojoExecutionException("failed to create archive", e);
}
projectHelper.attachArtifact(project, "zip", "p2site", destFile);
if (PackagingType.TYPE_P2_SITE.equals(project.getPackaging())
&& execution.getExecutionId().startsWith("default-")) {
Artifact artifact = project.getArtifact();
artifact.setFile(destFile);
artifact.setArtifactHandler(new DefaultArtifactHandler("zip"));
} else {
projectHelper.attachArtifact(project, "zip", "p2site", destFile);
}
}

private List<String> getKeyServers() {
Expand Down

0 comments on commit a8a6e8b

Please sign in to comment.