Skip to content

Commit

Permalink
eclipse-tycho#443 - publish maven GAVC info into the P2 meta-data
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 Jan 3, 2022
1 parent f57b599 commit baaa9ce
Showing 1 changed file with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit baaa9ce

Please sign in to comment.