From 79bcce89aa09f200fa2b1c97585fc5890934835c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Tue, 28 Nov 2023 10:16:46 +0100 Subject: [PATCH] Use main artifact p2-maven-repository packaging and default execution 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. --- .../plugins/p2/repository/MavenP2SiteMojo.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tycho-p2-repository-plugin/src/main/java/org/eclipse/tycho/plugins/p2/repository/MavenP2SiteMojo.java b/tycho-p2-repository-plugin/src/main/java/org/eclipse/tycho/plugins/p2/repository/MavenP2SiteMojo.java index 3e0ad0063d..76d1978c43 100644 --- a/tycho-p2-repository-plugin/src/main/java/org/eclipse/tycho/plugins/p2/repository/MavenP2SiteMojo.java +++ b/tycho-p2-repository-plugin/src/main/java/org/eclipse/tycho/plugins/p2/repository/MavenP2SiteMojo.java @@ -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; @@ -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; @@ -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 @@ -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 getKeyServers() {