From baaa9ce1bbfab393e726b77c90855025290fe548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Mon, 3 Jan 2022 17:19:58 +0100 Subject: [PATCH] #443 - publish maven GAVC info into the P2 meta-data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christoph Läubrich --- .../MavenTargetDefinitionContent.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/resolver/MavenTargetDefinitionContent.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/resolver/MavenTargetDefinitionContent.java index c5e20d1c04..98a4f19be3 100644 --- a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/resolver/MavenTargetDefinitionContent.java +++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/resolver/MavenTargetDefinitionContent.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 Christoph Läubrich and others. + * Copyright (c) 2020, 2022 Christoph Läubrich and others. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -57,6 +57,7 @@ import org.eclipse.tycho.core.shared.MavenDependenciesResolver; import org.eclipse.tycho.core.shared.MavenLogger; import org.eclipse.tycho.core.shared.MavenModelFacade; +import org.eclipse.tycho.p2.impl.publisher.MavenPropertiesAdvice; import org.eclipse.tycho.p2.metadata.IArtifactFacade; import org.eclipse.tycho.p2.repository.GAV; import org.eclipse.tycho.p2.target.TargetDefinitionContent; @@ -218,11 +219,14 @@ public MavenTargetDefinitionContent(MavenGAVLocation location, MavenDependencies logger.debug("The following manifest was generated for this artifact:\r\n" + wrappedArtifact.getGeneratedManifest()); } - unit = publish(BundlesAction.createBundleDescription(tempFile), tempFile); + unit = publish(BundlesAction.createBundleDescription(tempFile), tempFile, + /* + * do not propagate maven artifacts info for wrapped bundles + */ null); symbolicName = wrappedArtifact.getWrappedBsn(); bundleVersion = wrappedArtifact.getWrappedVersion(); } else { - unit = publish(bundleDescription, bundleLocation); + unit = publish(bundleDescription, bundleLocation, mavenArtifact); } bundles.add(unit); if (logger.isDebugEnabled()) { @@ -255,9 +259,11 @@ public MavenTargetDefinitionContent(MavenGAVLocation location, MavenDependencies } IInstallableUnit unit; if (isValidSourceManifest(manifest)) { - unit = publish(BundlesAction.createBundleDescription(sourceFile), sourceFile); + unit = publish(BundlesAction.createBundleDescription(sourceFile), sourceFile, + sourceArtifact); } else { - unit = generateSourceBundle(symbolicName, bundleVersion, manifest, sourceFile); + unit = generateSourceBundle(symbolicName, bundleVersion, manifest, sourceFile, + sourceArtifact); } sourceBundles.add(unit); if (unit != null && logger.isDebugEnabled()) { @@ -320,7 +326,7 @@ public MavenTargetDefinitionContent(MavenGAVLocation location, MavenDependencies } private IInstallableUnit generateSourceBundle(String symbolicName, String bundleVersion, Manifest manifest, - File sourceFile) throws IOException, BundleException { + File sourceFile, IArtifactFacade sourceArtifact) throws IOException, BundleException { File tempFile = File.createTempFile("tycho_wrapped_source", ".jar"); tempFile.deleteOnExit(); @@ -349,14 +355,20 @@ private IInstallableUnit generateSourceBundle(String symbolicName, String bundle } } } - return publish(BundlesAction.createBundleDescription(tempFile), tempFile); + return publish(BundlesAction.createBundleDescription(tempFile), tempFile, sourceArtifact); } - private IInstallableUnit publish(BundleDescription bundleDescription, File bundleLocation) { + private IInstallableUnit publish(BundleDescription bundleDescription, File bundleLocation, + IArtifactFacade mavenArtifact) { IArtifactKey key = BundlesAction.createBundleArtifactKey(bundleDescription.getSymbolicName(), bundleDescription.getVersion().toString()); PublisherInfo publisherInfo = new PublisherInfo(); + if (mavenArtifact != null) { + MavenPropertiesAdvice advice = new MavenPropertiesAdvice(mavenArtifact.getGroupId(), + mavenArtifact.getArtifactId(), mavenArtifact.getVersion(), mavenArtifact.getClassifier()); + publisherInfo.addAdvice(advice); + } publisherInfo.setArtifactOptions(IPublisherInfo.A_INDEX); IInstallableUnit iu = BundlesAction.createBundleIU(bundleDescription, key, publisherInfo); repositoryContent.put(FileArtifactRepository.forFile(bundleLocation, key), iu);