Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2019-05-18 07:48:24 -0400
committerAlexander Kurtakov2019-05-18 07:48:24 -0400
commit80ada502e1b2babbb5a6417274bc7fa4d3310210 (patch)
tree3df4c17610a9518163f9b0e0be1e33685d7a9830
parent8bd7ca213df4c85adc8eef68a520bf58315e04a0 (diff)
downloadorg.eclipse.tycho-80ada502e1b2babbb5a6417274bc7fa4d3310210.tar.gz
org.eclipse.tycho-80ada502e1b2babbb5a6417274bc7fa4d3310210.tar.xz
org.eclipse.tycho-80ada502e1b2babbb5a6417274bc7fa4d3310210.zip
Inject EclipseRepositoryProject instead of looking it up.
Change-Id: Ib309b1eae6a1d13fe2396ffa22ecd116c0cffa8d Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--tycho-core/src/main/java/org/eclipse/tycho/core/maven/AbstractP2Mojo.java18
-rw-r--r--tycho-p2/tycho-p2-publisher-plugin/src/main/java/org/eclipse/tycho/plugins/p2/publisher/PublishCategoriesMojo.java9
-rw-r--r--tycho-p2/tycho-p2-publisher-plugin/src/main/java/org/eclipse/tycho/plugins/p2/publisher/PublishProductMojo.java8
-rw-r--r--tycho-p2/tycho-p2-repository-plugin/src/main/java/org/eclipse/tycho/plugins/p2/repository/AssembleRepositoryMojo.java8
4 files changed, 22 insertions, 21 deletions
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/AbstractP2Mojo.java b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/AbstractP2Mojo.java
index d66e16689..396f132f2 100644
--- a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/AbstractP2Mojo.java
+++ b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/AbstractP2Mojo.java
@@ -16,14 +16,10 @@ import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.eclipse.tycho.BuildOutputDirectory;
-import org.eclipse.tycho.PackagingType;
import org.eclipse.tycho.ReactorProject;
import org.eclipse.tycho.ReactorProjectIdentities;
-import org.eclipse.tycho.core.TychoProject;
import org.eclipse.tycho.core.osgitools.DefaultReactorProject;
-import org.eclipse.tycho.core.osgitools.EclipseRepositoryProject;
import org.eclipse.tycho.core.shared.TargetEnvironment;
import org.eclipse.tycho.core.utils.TychoProjectUtils;
import org.eclipse.tycho.osgi.adapters.MavenReactorProjectIdentities;
@@ -68,20 +64,6 @@ public abstract class AbstractP2Mojo extends AbstractMojo {
return getProjectIdentities().getBuildDirectory();
}
- protected EclipseRepositoryProject getEclipseRepositoryProject() {
- return (EclipseRepositoryProject) getTychoProjectFacet(PackagingType.TYPE_ECLIPSE_REPOSITORY);
- }
-
- private TychoProject getTychoProjectFacet(String packaging) {
- TychoProject facet;
- try {
- facet = (TychoProject) session.lookup(TychoProject.class.getName(), packaging);
- } catch (ComponentLookupException e) {
- throw new IllegalStateException("Could not lookup required component", e);
- }
- return facet;
- }
-
protected BuildContext getBuildContext() {
return new BuildContext(getProjectIdentities(), getQualifier(), getEnvironments());
}
diff --git a/tycho-p2/tycho-p2-publisher-plugin/src/main/java/org/eclipse/tycho/plugins/p2/publisher/PublishCategoriesMojo.java b/tycho-p2/tycho-p2-publisher-plugin/src/main/java/org/eclipse/tycho/plugins/p2/publisher/PublishCategoriesMojo.java
index 0a8403631..066f3f220 100644
--- a/tycho-p2/tycho-p2-publisher-plugin/src/main/java/org/eclipse/tycho/plugins/p2/publisher/PublishCategoriesMojo.java
+++ b/tycho-p2/tycho-p2-publisher-plugin/src/main/java/org/eclipse/tycho/plugins/p2/publisher/PublishCategoriesMojo.java
@@ -19,10 +19,14 @@ import java.util.List;
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.codehaus.plexus.util.FileUtils;
import org.eclipse.tycho.BuildOutputDirectory;
+import org.eclipse.tycho.PackagingType;
+import org.eclipse.tycho.core.TychoProject;
+import org.eclipse.tycho.core.osgitools.EclipseRepositoryProject;
import org.eclipse.tycho.core.resolver.shared.DependencySeed;
import org.eclipse.tycho.model.Category;
import org.eclipse.tycho.p2.tools.FacadeException;
@@ -39,6 +43,9 @@ import org.eclipse.tycho.p2.tools.publisher.facade.PublisherServiceFactory;
@Mojo(name = "publish-categories", defaultPhase = LifecyclePhase.PACKAGE)
public final class PublishCategoriesMojo extends AbstractPublishMojo {
+ @Component(role = TychoProject.class, hint = PackagingType.TYPE_ECLIPSE_REPOSITORY)
+ private EclipseRepositoryProject eclipseRepositoryProject;
+
@Override
protected Collection<DependencySeed> publishContent(PublisherServiceFactory publisherServiceFactory)
throws MojoExecutionException, MojoFailureException {
@@ -96,6 +103,6 @@ public final class PublishCategoriesMojo extends AbstractPublishMojo {
}
private List<Category> getCategories() {
- return getEclipseRepositoryProject().loadCategories(getProject());
+ return eclipseRepositoryProject.loadCategories(getProject());
}
}
diff --git a/tycho-p2/tycho-p2-publisher-plugin/src/main/java/org/eclipse/tycho/plugins/p2/publisher/PublishProductMojo.java b/tycho-p2/tycho-p2-publisher-plugin/src/main/java/org/eclipse/tycho/plugins/p2/publisher/PublishProductMojo.java
index b8a2c3e8e..b7745bda6 100644
--- a/tycho-p2/tycho-p2-publisher-plugin/src/main/java/org/eclipse/tycho/plugins/p2/publisher/PublishProductMojo.java
+++ b/tycho-p2/tycho-p2-publisher-plugin/src/main/java/org/eclipse/tycho/plugins/p2/publisher/PublishProductMojo.java
@@ -28,8 +28,11 @@ import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.UnArchiver;
import org.eclipse.tycho.ArtifactDescriptor;
import org.eclipse.tycho.ArtifactType;
+import org.eclipse.tycho.PackagingType;
import org.eclipse.tycho.artifacts.DependencyArtifacts;
+import org.eclipse.tycho.core.TychoProject;
import org.eclipse.tycho.core.maven.TychoInterpolator;
+import org.eclipse.tycho.core.osgitools.EclipseRepositoryProject;
import org.eclipse.tycho.core.resolver.shared.DependencySeed;
import org.eclipse.tycho.core.resolver.shared.PlatformPropertiesUtils;
import org.eclipse.tycho.core.shared.Interpolator;
@@ -75,6 +78,9 @@ public final class PublishProductMojo extends AbstractPublishMojo {
@Component
private FileLockService fileLockService;
+ @Component(role = TychoProject.class, hint = PackagingType.TYPE_ECLIPSE_REPOSITORY)
+ private EclipseRepositoryProject eclipseRepositoryProject;
+
@Override
protected Collection<DependencySeed> publishContent(PublisherServiceFactory publisherServiceFactory)
throws MojoExecutionException, MojoFailureException {
@@ -83,7 +89,7 @@ public final class PublishProductMojo extends AbstractPublishMojo {
getEnvironments(), getQualifier(), interpolator);
List<DependencySeed> seeds = new ArrayList<>();
- for (File productFile : getEclipseRepositoryProject().getProductFiles(getProject())) {
+ for (File productFile : eclipseRepositoryProject.getProductFiles(getProject())) {
try {
ProductConfiguration productConfiguration = ProductConfiguration.read(productFile);
if (isEmpty(productConfiguration.getId())) {
diff --git a/tycho-p2/tycho-p2-repository-plugin/src/main/java/org/eclipse/tycho/plugins/p2/repository/AssembleRepositoryMojo.java b/tycho-p2/tycho-p2-repository-plugin/src/main/java/org/eclipse/tycho/plugins/p2/repository/AssembleRepositoryMojo.java
index f2a364504..a1cd9d4c1 100644
--- a/tycho-p2/tycho-p2-repository-plugin/src/main/java/org/eclipse/tycho/plugins/p2/repository/AssembleRepositoryMojo.java
+++ b/tycho-p2/tycho-p2-repository-plugin/src/main/java/org/eclipse/tycho/plugins/p2/repository/AssembleRepositoryMojo.java
@@ -26,7 +26,10 @@ import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.util.FileUtils;
import org.eclipse.sisu.equinox.EquinoxServiceFactory;
+import org.eclipse.tycho.PackagingType;
import org.eclipse.tycho.core.TargetPlatformConfiguration;
+import org.eclipse.tycho.core.TychoProject;
+import org.eclipse.tycho.core.osgitools.EclipseRepositoryProject;
import org.eclipse.tycho.core.resolver.shared.DependencySeed;
import org.eclipse.tycho.core.utils.TychoProjectUtils;
import org.eclipse.tycho.model.Category;
@@ -130,6 +133,9 @@ public class AssembleRepositoryMojo extends AbstractRepositoryMojo {
@Component
private EquinoxServiceFactory p2;
+ @Component(role = TychoProject.class, hint = PackagingType.TYPE_ECLIPSE_REPOSITORY)
+ private EclipseRepositoryProject eclipseRepositoryProject;
+
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
@@ -182,7 +188,7 @@ public class AssembleRepositoryMojo extends AbstractRepositoryMojo {
}
private List<Category> getCategories() {
- return getEclipseRepositoryProject().loadCategories(getProject());
+ return eclipseRepositoryProject.loadCategories(getProject());
}
}

Back to the top