Skip to content

Commit

Permalink
Prepare for 2024-06 release
Browse files Browse the repository at this point in the history
  • Loading branch information
laeubi committed Jun 16, 2024
1 parent 180df52 commit beaf5f7
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public MavenTargetDefinitionContent(MavenGAVLocation location, MavenDependencies
throw new TargetDefinitionResolutionException("feature generation failed!", e);
}
}
FeaturePublisher.publishFeatures(features, repositoryContent::put, logger);
FeaturePublisher.publishFeatures(features, repositoryContent::put, artifactRepository, logger);
}
}

Expand Down Expand Up @@ -396,7 +396,7 @@ private IInstallableUnit publish(BundleDescription bundleDescription, File bundl
private IInstallableUnit publish(BundleDescription bundleDescription, File bundleLocation, IPropertyAdvice advice) {
IArtifactKey key = BundlesAction.createBundleArtifactKey(bundleDescription.getSymbolicName(),
bundleDescription.getVersion().toString());
IArtifactDescriptor descriptor = FileArtifactRepository.forFile(bundleLocation, key);
IArtifactDescriptor descriptor = FileArtifactRepository.forFile(bundleLocation, key, artifactRepository);
PublisherInfo publisherInfo = new PublisherInfo();
publisherInfo.addAdvice(advice);
publisherInfo.addAdvice(new MavenChecksumAdvice(bundleLocation));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRequest;
import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository;
import org.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository;
Expand Down Expand Up @@ -222,17 +223,18 @@ private static boolean matches(IArtifactKey key, IArtifactDescriptor descriptor)
&& key.getVersion().equals(descriptorKey.getVersion()));
}

public static IArtifactDescriptor forFile(File file, IArtifactKey key) {
return new FileArtifactDescriptor(file, key);
public static IArtifactDescriptor forFile(File file, IArtifactKey key, IArtifactRepository repository) {
return new FileArtifactDescriptor(file, key, repository);
}

private static final class FileArtifactDescriptor extends ArtifactDescriptor {

private File file;

private FileArtifactDescriptor(File file, IArtifactKey key) {
private FileArtifactDescriptor(File file, IArtifactKey key, IArtifactRepository repository) {
super(key);
this.file = file;
setRepository(repository);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
import org.eclipse.equinox.p2.publisher.Publisher;
import org.eclipse.equinox.p2.publisher.PublisherInfo;
import org.eclipse.equinox.p2.publisher.actions.IPropertyAdvice;
import org.eclipse.tycho.p2maven.tmp.BundlesAction;
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.tycho.core.resolver.target.FileArtifactRepository;
import org.eclipse.tycho.p2maven.tmp.BundlesAction;
import org.osgi.framework.BundleException;

public class BundlePublisher extends BundlesAction {
Expand All @@ -47,8 +47,8 @@ private BundlePublisher(BundleDescription bundleDescription) {
super(new BundleDescription[] { bundleDescription });
}

public static Optional<IInstallableUnit> getBundleIU(File bundleLocation, IPublisherAdvice... advices)
throws IOException, BundleException {
public static Optional<IInstallableUnit> getBundleIU(File bundleLocation, IArtifactRepository repository,
IPublisherAdvice... advices) throws IOException, BundleException {
BundleDescription bundleDescription = BundlesAction.createBundleDescription(bundleLocation);
if (bundleDescription == null) {
//seems it is not a bundle
Expand All @@ -65,7 +65,7 @@ public static Optional<IInstallableUnit> getBundleIU(File bundleLocation, IPubli
}
IArtifactKey key = BundlesAction.createBundleArtifactKey(symbolicName,
bundleDescription.getVersion().toString());
IArtifactDescriptor descriptor = FileArtifactRepository.forFile(bundleLocation, key);
IArtifactDescriptor descriptor = FileArtifactRepository.forFile(bundleLocation, key, repository);
return Optional.ofNullable(publishBundle(bundleDescription, descriptor, publisherInfo));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
public class FeaturePublisher {

public static void publishFeatures(List<Feature> features,
BiConsumer<IArtifactDescriptor, IInstallableUnit> consumer, MavenLogger logger) {
BiConsumer<IArtifactDescriptor, IInstallableUnit> consumer, IArtifactRepository artifactRepository,
MavenLogger logger) {
if (features.isEmpty()) {
return;
}
Expand Down Expand Up @@ -85,7 +86,7 @@ protected IInstallableUnit generateFeatureJarIU(Feature feature, IPublisherInfo
//The actual published feature...
for (IArtifactKey key : artifacts) {
IArtifactDescriptor fileDescriptor = FileArtifactRepository
.forFile(new File(publishedFeature.getLocation()), key);
.forFile(new File(publishedFeature.getLocation()), key, artifactRepository);
consumer.accept(fileDescriptor, unit);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.publisher.IPublisherInfo;
import org.eclipse.equinox.p2.publisher.PublisherInfo;
import org.eclipse.tycho.p2maven.tmp.BundlesAction;
import org.eclipse.equinox.p2.publisher.eclipse.Feature;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
Expand All @@ -37,6 +36,7 @@
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.tycho.core.resolver.target.FileArtifactRepository;
import org.eclipse.tycho.core.resolver.target.SupplierMetadataRepository;
import org.eclipse.tycho.p2maven.tmp.BundlesAction;
import org.eclipse.tycho.targetplatform.TargetDefinitionContent;
import org.eclipse.tycho.targetplatform.TargetDefinitionResolutionException;
import org.osgi.framework.BundleException;
Expand Down Expand Up @@ -84,14 +84,16 @@ public synchronized void preload(IProgressMonitor monitor) {
boolean hasPlugins = pluginsPath.isDirectory();
boolean hasFeatures = featurePath.isDirectory();
if (hasPlugins) {
readBundles(pluginsPath, repositoryContent::put, hasFeatures ? subMonitor.split(100) : subMonitor);
readBundles(pluginsPath, repositoryContent::put, hasFeatures ? subMonitor.split(100) : subMonitor,
artifactRepository);
}
if (hasFeatures) {
readFeatures(featurePath, repositoryContent::put, hasPlugins ? subMonitor.split(100) : subMonitor);
readFeatures(featurePath, repositoryContent::put, artifactRepository,
hasPlugins ? subMonitor.split(100) : subMonitor);
}
if (!hasFeatures && !hasPlugins) {
readBundles(location, repositoryContent::put, subMonitor.split(100));
readFeatures(location, repositoryContent::put, subMonitor.split(100));
readBundles(location, repositoryContent::put, subMonitor.split(100), artifactRepository);
readFeatures(location, repositoryContent::put, artifactRepository, subMonitor.split(100));
}
} catch (ResolverException e) {
throw new TargetDefinitionResolutionException("resolving location " + location + " failed", e);
Expand All @@ -110,7 +112,7 @@ private Map<IArtifactDescriptor, IInstallableUnit> getRepositoryContent() {
}

private static void readFeatures(File path, BiConsumer<IArtifactDescriptor, IInstallableUnit> consumer,
IProgressMonitor monitor) throws ResolverException {
IArtifactRepository artifactRepository, IProgressMonitor monitor) {
PublisherInfo publisherInfo = new PublisherInfo();
publisherInfo.setArtifactOptions(IPublisherInfo.A_INDEX);
if (path.isDirectory()) {
Expand All @@ -130,7 +132,7 @@ private static void readFeatures(File path, BiConsumer<IArtifactDescriptor, IIns
Feature feature = new FeatureParser().parse(featureLocation);
if (feature != null) {
feature.setLocation(featureLocation.getAbsolutePath());
FeaturePublisher.publishFeatures(List.of(feature), consumer, null);
FeaturePublisher.publishFeatures(List.of(feature), consumer, artifactRepository, null);
}
subMonitor.worked(1);
}
Expand All @@ -139,7 +141,7 @@ private static void readFeatures(File path, BiConsumer<IArtifactDescriptor, IIns
}

private static void readBundles(File path, BiConsumer<IArtifactDescriptor, IInstallableUnit> consumer,
IProgressMonitor monitor) throws ResolverException {
IProgressMonitor monitor, IArtifactRepository artifactRepository) throws ResolverException {
PublisherInfo publisherInfo = new PublisherInfo();
publisherInfo.setArtifactOptions(IPublisherInfo.A_INDEX);
if (path.isDirectory()) {
Expand All @@ -161,7 +163,7 @@ private static void readBundles(File path, BiConsumer<IArtifactDescriptor, IInst
if (bundleDescription != null) {
IArtifactKey key = BundlesAction.createBundleArtifactKey(
bundleDescription.getSymbolicName(), bundleDescription.getVersion().toString());
consumer.accept(FileArtifactRepository.forFile(bundleLocation, key),
consumer.accept(FileArtifactRepository.forFile(bundleLocation, key, artifactRepository),
BundlesAction.createBundleIU(bundleDescription, key, publisherInfo));
}
} catch (BundleException | IOException | RuntimeException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@ public class PomDependencyCollectorImpl implements PomDependencyCollector {
private final List<IArtifactDescriptor> fileDescriptors = new ArrayList<>();
private FileRepositoryArtifactProvider fileRepositoryArtifactProvider;

private FileArtifactRepository artifactRepository;

public PomDependencyCollectorImpl(Logger logger, ReactorProject project, IProvisioningAgent agent) {
this.logger = logger;
this.project = project;
artifactRepository = new FileArtifactRepository(agent, fileDescriptors::iterator);
fileRepositoryArtifactProvider = new FileRepositoryArtifactProvider(
Collections.singletonList(new FileArtifactRepository(agent, fileDescriptors::iterator)),
ArtifactTransferPolicies.forLocalArtifacts());
Collections.singletonList(artifactRepository), ArtifactTransferPolicies.forLocalArtifacts());
}

public File getProjectLocation() {
Expand All @@ -85,7 +87,8 @@ public Entry<ArtifactKey, IArtifactDescriptor> addMavenArtifact(IArtifactFacade
for (IArtifactKey key : unit.getArtifacts()) {
ArtifactKey artifactKey = ArtifactTypeHelper.toTychoArtifactKey(unit, key);
if (artifactKey != null) {
IArtifactDescriptor descriptor = FileArtifactRepository.forFile(artifact.getLocation(), key);
IArtifactDescriptor descriptor = FileArtifactRepository.forFile(artifact.getLocation(), key,
artifactRepository);
fileDescriptors.add(descriptor);
descriptorMap.put(artifact, descriptor);
resultArtifactKey = new SimpleEntry<>(artifactKey, descriptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.publisher.IPublisherInfo;
import org.eclipse.equinox.p2.publisher.PublisherInfo;
import org.eclipse.tycho.p2maven.tmp.BundlesAction;
import org.eclipse.equinox.p2.publisher.eclipse.Feature;
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
Expand All @@ -43,6 +42,7 @@
import org.eclipse.tycho.core.shared.MavenLogger;
import org.eclipse.tycho.p2.resolver.BundlePublisher;
import org.eclipse.tycho.p2.resolver.FeaturePublisher;
import org.eclipse.tycho.p2maven.tmp.BundlesAction;
import org.eclipse.tycho.p2maven.transport.TychoRepositoryTransport;
import org.eclipse.tycho.targetplatform.TargetDefinitionContent;
import org.eclipse.tycho.targetplatform.TargetDefinitionResolutionException;
Expand Down Expand Up @@ -106,13 +106,13 @@ public RepositoryLocationContent(URI uri, Collection<Requirement> requirements,
throw new TargetDefinitionResolutionException("Can't fetch resource from " + url, e);
}
}
FeaturePublisher.publishFeatures(features, repositoryContent::put, logger);
FeaturePublisher.publishFeatures(features, repositoryContent::put, artifactRepository, logger);
}

private void publish(BundleDescription bundleDescription, File bundleLocation) {
IArtifactKey key = BundlesAction.createBundleArtifactKey(bundleDescription.getSymbolicName(),
bundleDescription.getVersion().toString());
IArtifactDescriptor descriptor = FileArtifactRepository.forFile(bundleLocation, key);
IArtifactDescriptor descriptor = FileArtifactRepository.forFile(bundleLocation, key, artifactRepository);
PublisherInfo publisherInfo = new PublisherInfo();
publisherInfo.setArtifactOptions(IPublisherInfo.A_INDEX);
IInstallableUnit iu = BundlePublisher.publishBundle(bundleDescription, descriptor, publisherInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public P2TargetPlatform createTargetPlatform(TargetPlatformConfigurationStub tpC
try {
MavenPropertiesAdvice advice = new MavenPropertiesAdvice(mavenArtifactKey.getGroupId(),
mavenArtifactKey.getArtifactId(), key.getVersion());
Optional<IInstallableUnit> iu = BundlePublisher.getBundleIU(bundleFile, advice);
Optional<IInstallableUnit> iu = BundlePublisher.getBundleIU(bundleFile, null, advice);
IInstallableUnit unit = iu.orElse(null);
if (unit != null) {
InstallableUnitDescription description = new InstallableUnitDescription();
Expand Down

0 comments on commit beaf5f7

Please sign in to comment.