Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Dufour2019-03-28 14:34:40 -0400
committerMickael Istria - away until Apr 22nd2019-04-12 13:33:39 -0400
commit9d52c62abba51475f1aa426db757c4b6f7037b08 (patch)
tree5bee58f9c0bbb8591fac8313ee57f7722c7f1e46
parentfd33a52ca7afc0c3c0e193f937e56b24f92fac67 (diff)
downloadorg.eclipse.tycho-9d52c62abba51475f1aa426db757c4b6f7037b08.tar.gz
org.eclipse.tycho-9d52c62abba51475f1aa426db757c4b6f7037b08.tar.xz
org.eclipse.tycho-9d52c62abba51475f1aa426db757c4b6f7037b08.zip
Bug 453708: Support for site/repository-reference/@location in
eclipse-repository Change-Id: I10957947bc927378e636f061f66ff252dd254ea7 Signed-off-by: Guillaume Dufour <guillaume.duff@gmail.com>
-rw-r--r--tycho-bundles/org.eclipse.tycho.p2.tools.impl/src/main/java/org/eclipse/tycho/p2/tools/mirroring/MirrorApplication.java30
-rw-r--r--tycho-bundles/org.eclipse.tycho.p2.tools.impl/src/main/java/org/eclipse/tycho/p2/tools/mirroring/MirrorApplicationServiceImpl.java2
-rw-r--r--tycho-bundles/org.eclipse.tycho.p2.tools.shared/src/main/java/org/eclipse/tycho/p2/tools/DestinationRepositoryDescriptor.java12
-rw-r--r--tycho-bundles/org.eclipse.tycho.p2.tools.shared/src/main/java/org/eclipse/tycho/p2/tools/RepositoryReference.java37
-rw-r--r--tycho-bundles/org.eclipse.tycho.p2.tools.tests/src/test/java/org/eclipse/tycho/p2/tools/mirroring/MirrorApplicationServiceTest.java2
-rw-r--r--tycho-its/projects/p2Repository.repositoryRef.location/category.xml10
-rw-r--r--tycho-its/projects/p2Repository.repositoryRef.location/pom.xml29
-rw-r--r--tycho-its/src/test/java/org/eclipse/tycho/test/p2Repository/RepoRefLocationP2RepositoryIntegrationTest.java81
-rw-r--r--tycho-metadata-model/src/main/java/org/eclipse/tycho/model/Category.java9
-rw-r--r--tycho-metadata-model/src/main/java/org/eclipse/tycho/model/RepositoryReference.java75
-rw-r--r--tycho-p2/tycho-p2-repository-plugin/src/main/java/org/eclipse/tycho/plugins/p2/repository/AssembleRepositoryMojo.java38
11 files changed, 317 insertions, 8 deletions
diff --git a/tycho-bundles/org.eclipse.tycho.p2.tools.impl/src/main/java/org/eclipse/tycho/p2/tools/mirroring/MirrorApplication.java b/tycho-bundles/org.eclipse.tycho.p2.tools.impl/src/main/java/org/eclipse/tycho/p2/tools/mirroring/MirrorApplication.java
index 69b8c8f93..85a54986c 100644
--- a/tycho-bundles/org.eclipse.tycho.p2.tools.impl/src/main/java/org/eclipse/tycho/p2/tools/mirroring/MirrorApplication.java
+++ b/tycho-bundles/org.eclipse.tycho.p2.tools.impl/src/main/java/org/eclipse/tycho/p2/tools/mirroring/MirrorApplication.java
@@ -10,7 +10,10 @@
*******************************************************************************/
package org.eclipse.tycho.p2.tools.mirroring;
+import java.net.URI;
+import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
@@ -19,21 +22,28 @@ import org.eclipse.equinox.p2.internal.repository.mirroring.Mirroring;
import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.IQueryable;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.IRepositoryReference;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
+import org.eclipse.tycho.p2.tools.RepositoryReference;
@SuppressWarnings("restriction")
public class MirrorApplication extends org.eclipse.equinox.p2.internal.repository.tools.MirrorApplication {
private final boolean includePackedArtifacts;
- private Map<String, String> extraArtifactRepositoryProperties;
+ private final Map<String, String> extraArtifactRepositoryProperties;
+ private final List<RepositoryReference> repositoryReferences;
public MirrorApplication(IProvisioningAgent agent, boolean includePackedArtifacts,
- Map<String, String> extraArtifactRepositoryProperties) {
+ Map<String, String> extraArtifactRepositoryProperties, List<RepositoryReference> repositoryReferences) {
super();
this.agent = agent;
this.includePackedArtifacts = includePackedArtifacts;
this.extraArtifactRepositoryProperties = extraArtifactRepositoryProperties;
+ this.repositoryReferences = repositoryReferences;
this.removeAddedRepositories = false;
}
@@ -49,6 +59,22 @@ public class MirrorApplication extends org.eclipse.equinox.p2.internal.repositor
}
@Override
+ protected IMetadataRepository initializeDestination(RepositoryDescriptor toInit, IMetadataRepositoryManager mgr)
+ throws ProvisionException {
+ IMetadataRepository result = super.initializeDestination(toInit, mgr);
+ List<? extends IRepositoryReference> iRepoRefs = repositoryReferences.stream()
+ .map(MirrorApplication::toSpiRepositoryReference).collect(Collectors.toList());
+ result.addReferences(iRepoRefs);
+ return result;
+ }
+
+ private static org.eclipse.equinox.p2.repository.spi.RepositoryReference toSpiRepositoryReference(
+ RepositoryReference rr) {
+ return new org.eclipse.equinox.p2.repository.spi.RepositoryReference(URI.create(rr.getLocation()), rr.getName(),
+ IRepository.TYPE_METADATA, rr.isEnable() ? IRepository.ENABLED : IRepository.NONE);
+ }
+
+ @Override
protected Mirroring getMirroring(IQueryable<IInstallableUnit> slice, IProgressMonitor monitor) {
Mirroring mirroring = super.getMirroring(slice, monitor);
mirroring.setIncludePacked(includePackedArtifacts);
diff --git a/tycho-bundles/org.eclipse.tycho.p2.tools.impl/src/main/java/org/eclipse/tycho/p2/tools/mirroring/MirrorApplicationServiceImpl.java b/tycho-bundles/org.eclipse.tycho.p2.tools.impl/src/main/java/org/eclipse/tycho/p2/tools/mirroring/MirrorApplicationServiceImpl.java
index 162dfe2c0..43fa51aab 100644
--- a/tycho-bundles/org.eclipse.tycho.p2.tools.impl/src/main/java/org/eclipse/tycho/p2/tools/mirroring/MirrorApplicationServiceImpl.java
+++ b/tycho-bundles/org.eclipse.tycho.p2.tools.impl/src/main/java/org/eclipse/tycho/p2/tools/mirroring/MirrorApplicationServiceImpl.java
@@ -210,7 +210,7 @@ public class MirrorApplicationServiceImpl implements MirrorApplicationService {
private static MirrorApplication createMirrorApplication(RepositoryReferences sources,
DestinationRepositoryDescriptor destination, IProvisioningAgent agent, boolean includePacked) {
final MirrorApplication mirrorApp = new MirrorApplication(agent, includePacked,
- destination.getExtraArtifactRepositoryProperties());
+ destination.getExtraArtifactRepositoryProperties(), destination.getRepositoryReferences());
List<RepositoryDescriptor> sourceDescriptors = createSourceDescriptors(sources);
for (RepositoryDescriptor sourceDescriptor : sourceDescriptors) {
diff --git a/tycho-bundles/org.eclipse.tycho.p2.tools.shared/src/main/java/org/eclipse/tycho/p2/tools/DestinationRepositoryDescriptor.java b/tycho-bundles/org.eclipse.tycho.p2.tools.shared/src/main/java/org/eclipse/tycho/p2/tools/DestinationRepositoryDescriptor.java
index 7eef21d67..d08d98f89 100644
--- a/tycho-bundles/org.eclipse.tycho.p2.tools.shared/src/main/java/org/eclipse/tycho/p2/tools/DestinationRepositoryDescriptor.java
+++ b/tycho-bundles/org.eclipse.tycho.p2.tools.shared/src/main/java/org/eclipse/tycho/p2/tools/DestinationRepositoryDescriptor.java
@@ -12,6 +12,7 @@ package org.eclipse.tycho.p2.tools;
import java.io.File;
import java.util.Collections;
+import java.util.List;
import java.util.Map;
public class DestinationRepositoryDescriptor {
@@ -23,11 +24,12 @@ public class DestinationRepositoryDescriptor {
private final boolean keepNonXzIndexFiles;
private final boolean metaDataOnly;
private final boolean append;
- private Map<String, String> extraArtifactRepositoryProperties;
+ private final Map<String, String> extraArtifactRepositoryProperties;
+ private final List<RepositoryReference> repositoryReferences;
public DestinationRepositoryDescriptor(File location, String name, boolean compress, boolean xzCompress,
boolean keepNonXzIndexFiles, boolean metaDataOnly, boolean append,
- Map<String, String> extraArtifactRepositoryProperties) {
+ Map<String, String> extraArtifactRepositoryProperties, List<RepositoryReference> repositoryReferences) {
this.location = location;
this.name = name;
this.compress = compress;
@@ -36,10 +38,11 @@ public class DestinationRepositoryDescriptor {
this.metaDataOnly = metaDataOnly;
this.append = append;
this.extraArtifactRepositoryProperties = extraArtifactRepositoryProperties;
+ this.repositoryReferences = repositoryReferences;
}
public DestinationRepositoryDescriptor(File location, String name) {
- this(location, name, true, true, false, false, true, Collections.emptyMap());
+ this(location, name, true, true, false, false, true, Collections.emptyMap(), Collections.emptyList());
}
public File getLocation() {
@@ -74,4 +77,7 @@ public class DestinationRepositoryDescriptor {
return extraArtifactRepositoryProperties == null ? Collections.emptyMap() : extraArtifactRepositoryProperties;
}
+ public List<RepositoryReference> getRepositoryReferences() {
+ return repositoryReferences == null ? Collections.emptyList() : repositoryReferences;
+ }
}
diff --git a/tycho-bundles/org.eclipse.tycho.p2.tools.shared/src/main/java/org/eclipse/tycho/p2/tools/RepositoryReference.java b/tycho-bundles/org.eclipse.tycho.p2.tools.shared/src/main/java/org/eclipse/tycho/p2/tools/RepositoryReference.java
new file mode 100644
index 000000000..370e325cf
--- /dev/null
+++ b/tycho-bundles/org.eclipse.tycho.p2.tools.shared/src/main/java/org/eclipse/tycho/p2/tools/RepositoryReference.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Guillaume Dufour and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Guillaume Dufour - Bug 453708 Support for site/repository-reference/@location in eclipse-repository
+ *******************************************************************************/
+package org.eclipse.tycho.p2.tools;
+
+public class RepositoryReference {
+ private final String name;
+ private final String location;
+ private final boolean enable;
+
+ public RepositoryReference(String name, String location, boolean enable) {
+ super();
+ this.name = name;
+ this.location = location;
+ this.enable = enable;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public boolean isEnable() {
+ return enable;
+ }
+
+}
diff --git a/tycho-bundles/org.eclipse.tycho.p2.tools.tests/src/test/java/org/eclipse/tycho/p2/tools/mirroring/MirrorApplicationServiceTest.java b/tycho-bundles/org.eclipse.tycho.p2.tools.tests/src/test/java/org/eclipse/tycho/p2/tools/mirroring/MirrorApplicationServiceTest.java
index be6b621ac..d8d1a3c76 100644
--- a/tycho-bundles/org.eclipse.tycho.p2.tools.tests/src/test/java/org/eclipse/tycho/p2/tools/mirroring/MirrorApplicationServiceTest.java
+++ b/tycho-bundles/org.eclipse.tycho.p2.tools.tests/src/test/java/org/eclipse/tycho/p2/tools/mirroring/MirrorApplicationServiceTest.java
@@ -115,7 +115,7 @@ public class MirrorApplicationServiceTest {
extraArtifactRepositoryProperties.put("p2.mirrorsURL", "http://some.where.else");
extraArtifactRepositoryProperties.put("foo", "bar");
destinationRepo = new DestinationRepositoryDescriptor(tempFolder.newFolder("dest2"), DEFAULT_NAME, false, false,
- false, false, true, extraArtifactRepositoryProperties);
+ false, false, true, extraArtifactRepositoryProperties, Collections.emptyList());
subject.mirrorReactor(sourceRepos("patch", "e342"), destinationRepo, seedFor(SIMPLE_FEATURE_IU), context, false,
false, null);
diff --git a/tycho-its/projects/p2Repository.repositoryRef.location/category.xml b/tycho-its/projects/p2Repository.repositoryRef.location/category.xml
new file mode 100644
index 000000000..5ff3bfa64
--- /dev/null
+++ b/tycho-its/projects/p2Repository.repositoryRef.location/category.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<site>
+ <category-def name="Test Category" label="Test Category Label">
+ <description>
+ Test Category Description
+ </description>
+ </category-def>
+ <repository-reference location="http://some.where" enabled="false" />
+ <repository-reference location="http://some.where.else" enabled="true" />
+</site>
diff --git a/tycho-its/projects/p2Repository.repositoryRef.location/pom.xml b/tycho-its/projects/p2Repository.repositoryRef.location/pom.xml
new file mode 100644
index 000000000..e69cba726
--- /dev/null
+++ b/tycho-its/projects/p2Repository.repositoryRef.location/pom.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>1.0.0</version>
+ <groupId>tycho-its-project.p2Repository.repositoryRef.location</groupId>
+ <artifactId>repositoryRef.location</artifactId>
+ <packaging>eclipse-repository</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-p2-repository-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <compress>false</compress>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-maven-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/p2Repository/RepoRefLocationP2RepositoryIntegrationTest.java b/tycho-its/src/test/java/org/eclipse/tycho/test/p2Repository/RepoRefLocationP2RepositoryIntegrationTest.java
new file mode 100644
index 000000000..ace438e74
--- /dev/null
+++ b/tycho-its/src/test/java/org/eclipse/tycho/test/p2Repository/RepoRefLocationP2RepositoryIntegrationTest.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Guillaume Dufour and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Guillaume Dufour - support repo ref location (453708)
+ *******************************************************************************/
+package org.eclipse.tycho.test.p2Repository;
+
+import static org.eclipse.tycho.test.util.TychoMatchers.isFile;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.maven.it.Verifier;
+import org.eclipse.tycho.test.AbstractTychoIntegrationTest;
+import org.eclipse.tycho.test.util.P2RepositoryTool;
+import org.eclipse.tycho.test.util.ResourceUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import de.pdark.decentxml.Document;
+import de.pdark.decentxml.XMLParser;
+
+public class RepoRefLocationP2RepositoryIntegrationTest extends AbstractTychoIntegrationTest {
+
+ private static Verifier verifier;
+ private static P2RepositoryTool p2Repo;
+
+ @SuppressWarnings("unchecked")
+ @BeforeClass
+ public static void executeBuild() throws Exception {
+ verifier = new RepoRefLocationP2RepositoryIntegrationTest().getVerifier("/p2Repository.repositoryRef.location",
+ false);
+ verifier.getCliOptions().add("-Dtest-data-repo=" + ResourceUtil.P2Repositories.ECLIPSE_OXYGEN.toString());
+ verifier.executeGoal("package");
+ verifier.verifyErrorFreeLog();
+ p2Repo = P2RepositoryTool.forEclipseRepositoryModule(new File(verifier.getBasedir()));
+ }
+
+ @Test
+ public void testRefLocation() throws Exception {
+ File target = new File(verifier.getBasedir(), "target");
+ File repository = new File(target, "repository");
+ File contentXml = new File(repository, "content.xml");
+ assertThat(contentXml, isFile());
+ File artifactXml = new File(repository, "artifacts.xml");
+ assertThat(artifactXml, isFile());
+ assertThat(new File(target, "category.xml"), isFile());
+
+ Map<String, Boolean> expected = new HashMap<>(2, 1.f);
+ expected.put("http://some.where", false);
+ expected.put("http://some.where.else", true);
+ Document artifactsDocument = XMLParser.parse(contentXml);
+ // See MetadataRepositoryIO.Writer#writeRepositoryReferences
+ artifactsDocument.getChild("repository").getChild("references").getChildren("repository").forEach(element -> {
+ String location = element.getAttributeValue("uri");
+ if (expected.containsKey(location)
+ && expected.get(location).equals(element.getAttributeValue("options").equals("1"))) {
+ expected.remove(location);
+ } else {
+ System.out.println(location);
+ System.out.println(expected.containsKey(location));
+ System.out.println(expected.get(location));
+ System.out.println();
+ fail("Unexpected repository reference in artifact repository " + element);
+ }
+ });
+ assertEquals("Missing repository reference in artifact repository", Collections.emptyMap(), expected);
+
+ }
+
+}
diff --git a/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/Category.java b/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/Category.java
index 8bd776720..555bf6664 100644
--- a/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/Category.java
+++ b/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/Category.java
@@ -7,6 +7,7 @@
*
* Contributors:
* SAP AG - initial API and implementation
+ * Guillaume Dufour - Bug 453708 Support for site/repository-reference/@location in eclipse-repository
*******************************************************************************/
package org.eclipse.tycho.model;
@@ -64,6 +65,14 @@ public class Category {
return Collections.unmodifiableList(plugins);
}
+ public List<RepositoryReference> getRepositoryReferences() {
+ ArrayList<RepositoryReference> repos = new ArrayList<>();
+ for (Element repoDom : dom.getChildren("repository-reference")) {
+ repos.add(new RepositoryReference(repoDom));
+ }
+ return Collections.unmodifiableList(repos);
+ }
+
public static Category read(File file) throws IOException {
return read(new BufferedInputStream(new FileInputStream(file)));
}
diff --git a/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/RepositoryReference.java b/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/RepositoryReference.java
new file mode 100644
index 000000000..8245ec427
--- /dev/null
+++ b/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/RepositoryReference.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Guillaume Dufour and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Guillaume Dufour - Bug 453708 Support for site/repository-reference/@location in eclipse-repository
+ *******************************************************************************/
+package org.eclipse.tycho.model;
+
+import java.util.Objects;
+
+import de.pdark.decentxml.Element;
+
+public class RepositoryReference {
+ private final Element dom;
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getLocation(), isEnabled());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!(obj instanceof RepositoryReference))
+ return false;
+ RepositoryReference other = (RepositoryReference) obj;
+ return Objects.equals(getLocation(), other.getLocation()) && isEnabled() == other.isEnabled();
+ }
+
+ @Override
+ public String toString() {
+ return getLocation() + "_" + isEnabled();
+ }
+
+ public RepositoryReference(Element dom) {
+ this.dom = dom;
+ }
+
+ public RepositoryReference(String tagname) {
+ this.dom = new Element(tagname);
+ }
+
+ public String getLocation() {
+ return dom.getAttributeValue("location");
+ }
+
+ public void setLocation(String location) {
+ dom.setAttribute("location", location);
+ }
+
+ public String getName() {
+ return dom.getAttributeValue("name");
+ }
+
+ public void setName(String name) {
+ dom.setAttribute("name", name);
+ }
+
+ public boolean isEnabled() {
+ return Boolean.parseBoolean(dom.getAttributeValue("enabled"));
+ }
+
+ public void setEnabled(boolean enabled) {
+ dom.setAttribute("enabled", Boolean.toString(enabled));
+ }
+
+ Element getDom() {
+ return dom;
+ }
+}
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 2a6e64051..980838b33 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
@@ -12,7 +12,9 @@ package org.eclipse.tycho.plugins.p2.repository;
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
import org.apache.maven.plugin.MojoExecutionException;
@@ -21,14 +23,20 @@ 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;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
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;
import org.eclipse.tycho.p2.facade.RepositoryReferenceTool;
import org.eclipse.tycho.p2.tools.DestinationRepositoryDescriptor;
import org.eclipse.tycho.p2.tools.FacadeException;
+import org.eclipse.tycho.p2.tools.RepositoryReference;
import org.eclipse.tycho.p2.tools.RepositoryReferences;
import org.eclipse.tycho.p2.tools.mirroring.facade.MirrorApplicationService;
@@ -142,9 +150,20 @@ public class AssembleRepositoryMojo extends AbstractRepositoryMojo {
TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(getProject());
MirrorApplicationService mirrorApp = p2.getService(MirrorApplicationService.class);
+
+ final List<Category> categories = getCategories();
+ final List<RepositoryReference> repositoryRefrences = new ArrayList<>();
+ for (Category category : categories) {
+ for (org.eclipse.tycho.model.RepositoryReference categoryRepositoryReference : category
+ .getRepositoryReferences()) {
+ repositoryRefrences.add(new RepositoryReference(categoryRepositoryReference.getName(),
+ categoryRepositoryReference.getLocation(), categoryRepositoryReference.isEnabled()));
+ }
+ }
+
DestinationRepositoryDescriptor destinationRepoDescriptor = new DestinationRepositoryDescriptor(destination,
repositoryName, compress, xzCompress, keepNonXzIndexFiles, !createArtifactRepository, true,
- extraArtifactRepositoryProperties);
+ extraArtifactRepositoryProperties, repositoryRefrences);
mirrorApp.mirrorReactor(sources, destinationRepoDescriptor, projectSeeds, getBuildContext(),
includeAllDependencies, configuration.isIncludePackedArtifacts(), profileProperties);
} catch (FacadeException e) {
@@ -169,4 +188,21 @@ public class AssembleRepositoryMojo extends AbstractRepositoryMojo {
return repositoryReferenceTool.getVisibleRepositories(getProject(), getSession(), flags);
}
+ private List<Category> getCategories() {
+ return getEclipseRepositoryProject().loadCategories(getProject());
+ }
+
+ protected EclipseRepositoryProject getEclipseRepositoryProject() {
+ return (EclipseRepositoryProject) getTychoProjectFacet(PackagingType.TYPE_ECLIPSE_REPOSITORY);
+ }
+
+ private TychoProject getTychoProjectFacet(String packaging) {
+ TychoProject facet;
+ try {
+ facet = (TychoProject) getSession().lookup(TychoProject.class.getName(), packaging);
+ } catch (ComponentLookupException e) {
+ throw new IllegalStateException("Could not lookup required component", e);
+ }
+ return facet;
+ }
}

Back to the top