Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#443 - publish maven GAVC info into the P2 meta-data #485

Merged
merged 1 commit into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ public MavenPropertiesAdvice(String groupId, String artifactId, String version,
}
}

public MavenPropertiesAdvice(String groupId, String artifactId, String version, String classifier,
String extension) {
this(groupId, artifactId, version, classifier);
if (extension != null && !extension.isEmpty()) {
properties.put(RepositoryLayoutHelper.PROP_EXTENSION, extension);
}
}

@Override
public Map<String, String> getArtifactProperties(IInstallableUnit iu, IArtifactDescriptor descriptor) {
// workaround Bug 539672
Expand Down
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,21 @@ 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(),
mavenArtifact.getPackagingType());
publisherInfo.addAdvice(advice);
}
publisherInfo.setArtifactOptions(IPublisherInfo.A_INDEX);
IInstallableUnit iu = BundlesAction.createBundleIU(bundleDescription, key, publisherInfo);
repositoryContent.put(FileArtifactRepository.forFile(bundleLocation, key), iu);
Expand Down