forked from sonatype/sonatype-tycho
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TYCHO-570 Make published artifacts available in build
- Register the p2 artifact repository with the published bundles in a central registry (the ArtifactRepositoryBlackboard). The blackboard implements the artifact repository factory extension point and therefore the registered artifact repositories can be loaded through the normal p2 APIs. - The artifact repositories are registered under a special key (see RepositoryBlackboardKey) which is unique for each module. - The p2 Mojos include the artifact repository with the published bundles of the current module by adding the special key as source/context p2 repository. Through this, POM dependency artifacts can for example be mirrored into an eclipse-repository. This commit resolves TYCHO-570 aka bug 342851. Bug: 342851 Artifacts from POM dependencies missing in eclipse-repository
- Loading branch information
Showing
20 changed files
with
313 additions
and
17 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
tycho-its/projects/pomDependencyConsider.p2Data.generate/feature/build.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bin.includes = feature.xml |
26 changes: 26 additions & 0 deletions
26
tycho-its/projects/pomDependencyConsider.p2Data.generate/feature/feature.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<feature | ||
id="pomDependencyConsider.p2Data.generate.feature" | ||
label="Feature" | ||
version="0.0.1.qualifier"> | ||
|
||
<description url="http://www.example.com/description"> | ||
[Enter Feature Description here.] | ||
</description> | ||
|
||
<copyright url="http://www.example.com/copyright"> | ||
[Enter Copyright Description here.] | ||
</copyright> | ||
|
||
<license url="http://www.example.com/license"> | ||
[Enter License Description here.] | ||
</license> | ||
|
||
<plugin | ||
id="com.google.gson" | ||
download-size="0" | ||
install-size="0" | ||
version="0.0.0" | ||
unpack="false"/> | ||
|
||
</feature> |
13 changes: 13 additions & 0 deletions
13
tycho-its/projects/pomDependencyConsider.p2Data.generate/feature/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>tycho-its-project.pomDependencyConsider.p2Data.generate</groupId> | ||
<artifactId>parent</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>pomDependencyConsider.p2Data.generate.feature</artifactId> | ||
<packaging>eclipse-feature</packaging> | ||
|
||
</project> |
46 changes: 46 additions & 0 deletions
46
tycho-its/projects/pomDependencyConsider.p2Data.generate/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>tycho-its-project.pomDependencyConsider.p2Data.generate</groupId> | ||
<artifactId>parent</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
|
||
<modules> | ||
<module>feature</module> | ||
<module>repository</module> | ||
</modules> | ||
|
||
<dependencies> | ||
<!-- The test uses this artifact for the following reasons: | ||
* The artifact is an OSGi bundle not built by Tycho. There is no p2 data deployed | ||
with the artifact. Since the Tycho p2 Mojos expect that p2 data exists for all | ||
external content in the target platform, that data needs to be generated on the | ||
fly by the dependency resolver. --> | ||
<dependency> | ||
<groupId>com.google.code.gson</groupId> | ||
<artifactId>gson</artifactId> | ||
<version>1.6</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>tycho-maven-plugin</artifactId> | ||
<version>${tycho-version}</version> | ||
<extensions>true</extensions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>target-platform-configuration</artifactId> | ||
<version>${tycho-version}</version> | ||
<configuration> | ||
<pomDependencies>consider</pomDependencies> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
6 changes: 6 additions & 0 deletions
6
tycho-its/projects/pomDependencyConsider.p2Data.generate/repository/category.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<site> | ||
<feature | ||
url="features/pomDependencyConsider.p2Data.generate.feature_0.0.0.jar" | ||
id="pomDependencyConsider.p2Data.generate.feature" version="0.0.0" /> | ||
</site> |
13 changes: 13 additions & 0 deletions
13
tycho-its/projects/pomDependencyConsider.p2Data.generate/repository/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>tycho-its-project.pomDependencyConsider.p2Data.generate</groupId> | ||
<artifactId>parent</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>repository</artifactId> | ||
<packaging>eclipse-repository</packaging> | ||
|
||
</project> |
40 changes: 40 additions & 0 deletions
40
...tycho/test/pomDependencyConsider/p2Data/generate/PomDependencyOnNonTychoArtifactTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2011 SAP AG 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: | ||
* SAP AG - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.test.pomDependencyConsider.p2Data.generate; | ||
|
||
import java.io.File; | ||
|
||
import org.apache.maven.it.Verifier; | ||
import org.eclipse.tycho.test.AbstractTychoIntegrationTest; | ||
import org.eclipse.tycho.test.util.P2RepositoryTool; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class PomDependencyOnNonTychoArtifactTest extends AbstractTychoIntegrationTest { | ||
private static final String POM_DEPENDENCY_BUNDLE_ID = "com.google.gson"; | ||
private static final String POM_DEPENDENCY_BUNDLE_VERSION = "1.6.0"; | ||
|
||
@Test | ||
public void testP2DataGeneratedForPomDependency() throws Exception { | ||
// project with a POM dependency on a bundle not built by Tycho | ||
Verifier verifier = getVerifier("pomDependencyConsider.p2Data.generate", false); | ||
|
||
verifier.executeGoal("verify"); | ||
verifier.verifyErrorFreeLog(); | ||
|
||
String testProjectRoot = verifier.getBasedir(); | ||
P2RepositoryTool p2Repo = P2RepositoryTool.forEclipseRepositoryModule(new File(testProjectRoot, "repository")); | ||
|
||
// this was bug TYCHO-570: the build passed, but the POM dependency bundle was missing | ||
File expectedBundle = p2Repo.getBundleArtifact(POM_DEPENDENCY_BUNDLE_ID, POM_DEPENDENCY_BUNDLE_VERSION); | ||
Assert.assertTrue(expectedBundle.isFile()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...e/src/main/java/org/eclipse/tycho/repository/registry/facade/RepositoryBlackboardKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2011 SAP AG 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: | ||
* SAP AG - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.repository.registry.facade; | ||
|
||
import java.io.File; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
|
||
public class RepositoryBlackboardKey { | ||
|
||
// TODO p2 bug 347319 prevents using a special scheme, that will ensure that only our p2 repository factory load the blackboard key URIs | ||
//public static String SCHEME = "registry"; | ||
public static String SCHEME = "file"; | ||
|
||
private final URI uri; | ||
|
||
private RepositoryBlackboardKey(URI uri) { | ||
this.uri = uri; | ||
} | ||
|
||
public URI toURI() { | ||
return uri; | ||
} | ||
|
||
/** | ||
* Creates a key under which the POM dependency artifacts of the resolution context (which is a | ||
* superset of the target platform) of a project are available as p2 repository. | ||
*/ | ||
public static RepositoryBlackboardKey forResolutionContextArtifacts(File projectLocation) { | ||
try { | ||
return new RepositoryBlackboardKey( | ||
new URI(SCHEME, "/resolution-context-artifacts@" + projectLocation, null)); | ||
} catch (URISyntaxException e) { | ||
// the used constructor escapes invalid characters, so I don't see this happening | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getClass().getName() + "(uri=" + uri + ")"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...rc/main/java/org/eclipse/tycho/repository/registry/impl/ArtifactRepositoryBlackboard.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2011 SAP AG 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: | ||
* SAP AG - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.repository.registry.impl; | ||
|
||
import java.net.URI; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.eclipse.core.runtime.IProgressMonitor; | ||
import org.eclipse.equinox.p2.core.IProvisioningAgent; | ||
import org.eclipse.equinox.p2.core.ProvisionException; | ||
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; | ||
import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactRepositoryFactory; | ||
import org.eclipse.tycho.repository.registry.facade.RepositoryBlackboardKey; | ||
import org.eclipse.tycho.repository.util.RepositoryFactoryTools; | ||
|
||
public class ArtifactRepositoryBlackboard extends ArtifactRepositoryFactory { | ||
|
||
private static HashMap<URI, IArtifactRepository> registry = new HashMap<URI, IArtifactRepository>(); | ||
|
||
public static synchronized void putRepository(RepositoryBlackboardKey key, IArtifactRepository repository) { | ||
registry.put(key.toURI(), repository); | ||
} | ||
|
||
@Override | ||
public IArtifactRepository create(URI location, String name, String type, Map<String, String> properties) | ||
throws ProvisionException { | ||
throw RepositoryFactoryTools.unsupportedCreation(getClass()); | ||
} | ||
|
||
@Override | ||
public IArtifactRepository load(URI location, int flags, IProgressMonitor monitor) throws ProvisionException { | ||
if (RepositoryBlackboardKey.SCHEME.equals(location.getScheme())) { | ||
return getRegisteredRepositoryOrNull(location, getAgent()); | ||
} | ||
return null; | ||
} | ||
|
||
private static synchronized IArtifactRepository getRegisteredRepositoryOrNull(URI location, IProvisioningAgent agent) | ||
throws ProvisionException { | ||
return registry.get(location); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.