Skip to content

Commit

Permalink
More WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
cstamas committed Sep 5, 2024
1 parent 24b03da commit a9a1b86
Show file tree
Hide file tree
Showing 20 changed files with 164 additions and 95 deletions.
16 changes: 14 additions & 2 deletions target-platform-configuration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<build>
<plugins>
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
<groupId>org.eclipse.sisu</groupId>
<artifactId>sisu-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -44,6 +44,18 @@
</build>

<dependencies>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
Expand Down Expand Up @@ -53,6 +52,8 @@
import org.eclipse.tycho.p2maven.SlicingOptions;
import org.eclipse.tycho.repository.registry.facade.ReactorRepositoryManager;

import javax.inject.Inject;

/**
* Supports mirroring the computed target platform of the current project, this behaves similar to
* what PDE offers with its export deployable feature / plug-in and assembles an update site that
Expand Down Expand Up @@ -104,19 +105,19 @@ public class MirrorTargetPlatformMojo extends AbstractMojo {
@Parameter
private SlicingOptions options;

@Component
@Inject
private TargetPlatformService platformService;

@Component
@Inject
private MirrorApplicationService mirrorService;

@Component
@Inject
private ReactorRepositoryManager repositoryManager;

@Component
@Inject
private IProvisioningAgent agent;

@Component
@Inject
private InstallableUnitSlicer installableUnitSlicer;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
import org.apache.maven.artifact.repository.MavenArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout2;
import org.codehaus.plexus.component.annotations.Component;

@Component(role = ArtifactRepositoryLayout.class, hint = TargetArtifactRepositoryLayout.ID)
import javax.inject.Named;
import javax.inject.Singleton;

@Singleton
@Named(TargetArtifactRepositoryLayout.ID)
public class TargetArtifactRepositoryLayout implements ArtifactRepositoryLayout, ArtifactRepositoryLayout2 {
public static final String ID = "target";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@

import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IRequirement;
Expand All @@ -39,20 +36,22 @@
import org.eclipse.tycho.p2maven.tmp.BundlesAction;
import org.eclipse.tycho.resolver.InstallableUnitProvider;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

/**
* Provides additional requirements defined in the target platform configuration
*
*/
@Component(role = InstallableUnitProvider.class, hint = "target")
@Singleton
@Named("target")
public class TargetPlatformConfigurationInstallableUnitProvider implements InstallableUnitProvider {

@Requirement
@Inject
private DefaultTargetPlatformConfigurationReader configurationReader;

@Requirement
private Logger logger;

@Requirement
@Inject
private TychoProjectManager projectManager;

@Override
Expand Down Expand Up @@ -89,7 +88,6 @@ private static IRequirement createRequirementFor(String type, String id, Version
}

private static IInstallableUnit createUnitRequiring(Collection<IRequirement> requirements) {

InstallableUnitDescription result = new MetadataFactory.InstallableUnitDescription();
result.setId("target-platform-extra-requirements-" + UUID.randomUUID());
result.setVersion(Version.createOSGi(0, 0, 0, String.valueOf(System.currentTimeMillis())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.eclipse.tycho.ReactorProject;
import org.eclipse.tycho.TargetPlatformService;
import org.eclipse.tycho.core.osgitools.DefaultReactorProject;

import javax.inject.Inject;

@Mojo(name = "target-platform", threadSafe = true)
public class TargetPlatformMojo extends AbstractMojo {

Expand All @@ -33,7 +34,7 @@ public class TargetPlatformMojo extends AbstractMojo {
@Parameter(property = "project", readonly = true)
private MavenProject project;

@Component
@Inject
private TargetPlatformService platformService;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@
*******************************************************************************/
package org.eclipse.tycho.target;

import org.codehaus.plexus.component.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.spi.connector.RepositoryConnector;
import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
import org.eclipse.aether.transfer.NoRepositoryConnectorException;

@Component(role = RepositoryConnectorFactory.class, hint = TargetArtifactRepositoryLayout.ID)
import javax.inject.Named;
import javax.inject.Singleton;

@Singleton
@Named(TargetArtifactRepositoryLayout.ID)
public class TargetRepositoryConnectorFactory implements RepositoryConnectorFactory {

@Override
Expand Down
20 changes: 18 additions & 2 deletions tycho-ds-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@
<name>Tycho OSGi Declarative Services Plugin</name>
<description>A plugin for handling OSGi Declarative Services</description>
<dependencies>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
Expand All @@ -29,6 +41,10 @@
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-xml</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-core</artifactId>
Expand All @@ -42,8 +58,8 @@
<build>
<plugins>
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
<groupId>org.eclipse.sisu</groupId>
<artifactId>sisu-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@

import org.apache.maven.model.Plugin;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.eclipse.tycho.ReactorProject;
import org.eclipse.tycho.core.DeclarativeServicesConfiguration;
import org.osgi.framework.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Component(role = DeclarativeServiceConfigurationReader.class)
import javax.inject.Named;
import javax.inject.Singleton;

@Singleton
@Named
public class DeclarativeServiceConfigurationReader {

private static final String DS_PLUGIN = "org.eclipse.tycho:tycho-ds-plugin";
Expand All @@ -44,8 +47,7 @@ public class DeclarativeServiceConfigurationReader {

private static final String PDE_DS_ANNOTATIONS_PREFS = ".settings/org.eclipse.pde.ds.annotations.prefs";

@Requirement
private Logger logger;
private final Logger logger = LoggerFactory.getLogger(getClass());

public DeclarativeServicesConfiguration getConfiguration(ReactorProject reactorProject) throws IOException {
return getConfiguration(Objects.requireNonNull(reactorProject.adapt(MavenProject.class)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
import java.util.Optional;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

import org.apache.maven.SessionScoped;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.eclipse.aether.resolution.ArtifactResolutionException;
import org.eclipse.tycho.ArtifactKey;
import org.eclipse.tycho.ResolvedArtifactKey;
Expand All @@ -34,6 +33,7 @@
import org.eclipse.tycho.core.TychoProjectManager;
import org.eclipse.tycho.core.maven.MavenDependenciesResolver;
import org.eclipse.tycho.core.osgitools.AbstractSpecificationClasspathContributor;
import org.eclipse.tycho.core.osgitools.MavenBundleResolver;
import org.osgi.framework.Version;
import org.osgi.framework.VersionRange;

Expand All @@ -43,8 +43,8 @@
import aQute.bnd.osgi.Constants;
import aQute.bnd.osgi.Processor;

@Component(role = ClasspathContributor.class, hint = "ds-annotations")
@SessionScoped
@Singleton
@Named("ds-annotations")
public class DeclarativeServicesClasspathContributor extends AbstractSpecificationClasspathContributor
implements ClasspathContributor {

Expand All @@ -56,18 +56,18 @@ public class DeclarativeServicesClasspathContributor extends AbstractSpecificati
private static final String DS_ANNOTATIONS_1_2_ARTIFACT_ID = "osgi.cmpn";
private static final String DS_ANNOTATIONS_1_2_VERSION = "5.0.0";

@Requirement
@Inject
DeclarativeServiceConfigurationReader configurationReader;

@Requirement
@Inject
MavenDependenciesResolver dependenciesResolver;

@Requirement
@Inject
TychoProjectManager projectManager;

@Inject
public DeclarativeServicesClasspathContributor(MavenSession session) {
super(session, DS_ANNOTATIONS_PACKAGE, DS_ANNOTATIONS_GROUP_ID, DS_ANNOTATIONS_ARTIFACT_ID);
public DeclarativeServicesClasspathContributor(MavenBundleResolver mavenBundleResolver, MavenSession session) {
super(mavenBundleResolver, session, DS_ANNOTATIONS_PACKAGE, DS_ANNOTATIONS_GROUP_ID, DS_ANNOTATIONS_ARTIFACT_ID);
}

@Override
Expand Down
Loading

0 comments on commit a9a1b86

Please sign in to comment.