use of org.eclipse.tycho.p2.repository.GAV in project tycho by eclipse.
the class TargetPlatformFactoryTest method testIncludeLocalMavenRepo.
@Test
public void testIncludeLocalMavenRepo() throws Exception {
TestResolverFactory factory = new TestResolverFactory(logVerifier.getLogger());
LocalMetadataRepository localMetadataRepo = factory.getLocalMetadataRepository();
// add one IU to local repo
localMetadataRepo.addInstallableUnit(InstallableUnitUtil.createIU("locallyInstalledIU", "1.0.0"), new GAV("test", "foo", "1.0.0"));
subject = factory.getTargetPlatformFactoryImpl();
Collection<IInstallableUnit> iusIncludingLocalRepo = subject.createTargetPlatform(tpConfig, NOOP_EE_RESOLUTION_HANDLER, null, null).getInstallableUnits();
tpConfig.setForceIgnoreLocalArtifacts(true);
Collection<IInstallableUnit> iusWithoutLocalRepo = subject.createTargetPlatform(tpConfig, NOOP_EE_RESOLUTION_HANDLER, null, null).getInstallableUnits();
Set<IInstallableUnit> retainedIUs = new HashSet<>(iusIncludingLocalRepo);
retainedIUs.removeAll(iusWithoutLocalRepo);
assertEquals(1, retainedIUs.size());
assertEquals("locallyInstalledIU", retainedIUs.iterator().next().getId());
}
use of org.eclipse.tycho.p2.repository.GAV in project tycho by eclipse.
the class P2MetadataGeneratorImplTest method gav.
@Test
public void gav() throws Exception {
P2GeneratorImpl impl = new P2GeneratorImpl(false);
impl.setBuildPropertiesParser(new BuildPropertiesParserForTesting());
File location = new File("resources/generator/bundle").getCanonicalFile();
String groupId = "org.eclipse.tycho.p2.impl.test";
String artifactId = "bundle";
String version = "1.0.0-SNAPSHOT";
List<TargetEnvironment> environments = new ArrayList<>();
DependencyMetadata metadata = impl.generateMetadata(new ArtifactMock(location, groupId, artifactId, version, PackagingType.TYPE_ECLIPSE_PLUGIN), environments);
List<IInstallableUnit> units = new ArrayList<>(metadata.getInstallableUnits());
List<IArtifactDescriptor> artifacts = new ArrayList<>(metadata.getArtifactDescriptors());
Assert.assertEquals(1, units.size());
IInstallableUnit unit = units.iterator().next();
Assert.assertEquals("org.eclipse.tycho.p2.impl.test.bundle", unit.getId());
Assert.assertEquals("1.0.0.qualifier", unit.getVersion().toString());
Assert.assertEquals(2, unit.getRequirements().size());
Assert.assertEquals(1, artifacts.size());
IArtifactDescriptor ad = artifacts.iterator().next();
Assert.assertEquals("org.eclipse.tycho.p2.impl.test.bundle", ad.getArtifactKey().getId());
Assert.assertEquals("1.0.0.qualifier", ad.getArtifactKey().getVersion().toString());
Assert.assertEquals(groupId, ad.getProperties().get(RepositoryLayoutHelper.PROP_GROUP_ID));
Assert.assertEquals(artifactId, ad.getProperties().get(RepositoryLayoutHelper.PROP_ARTIFACT_ID));
Assert.assertEquals(version, ad.getProperties().get(RepositoryLayoutHelper.PROP_VERSION));
}
use of org.eclipse.tycho.p2.repository.GAV in project tycho by eclipse.
the class PomDependencyProcessor method collectPomDependencies.
PomDependencyCollector collectPomDependencies(MavenProject project, Collection<Artifact> transitivePomDependencies) {
final TychoRepositoryIndex p2ArtifactsInLocalRepo = localRepoIndices.getArtifactsIndex();
PomDependencyCollector result = resolverFactory.newPomDependencyCollector();
result.setProjectLocation(project.getBasedir());
for (Artifact artifact : transitivePomDependencies) {
if (Artifact.SCOPE_SYSTEM.equals(artifact.getScope())) {
// ignore
continue;
}
P2DataArtifacts p2Data = new P2DataArtifacts(artifact);
p2Data.resolve(session, project.getRemoteArtifactRepositories());
if (p2Data.p2MetadataXml.isAvailable() && p2Data.p2ArtifactsXml.isAvailable()) {
/*
* The POM dependency has (probably) been built by Tycho, so we can re-use the
* existing p2 data in the target platform. The data is stored in the attached
* artifacts p2metadata.xml and p2artifacts.xml, which are now present in the local
* Maven repository.
*/
if (logger.isDebugEnabled()) {
logger.debug("P2TargetPlatformResolver: Using existing metadata of " + artifact.toString());
}
result.addArtifactWithExistingMetadata(new ArtifactFacade(artifact), new ArtifactFacade(p2Data.p2MetadataXml.artifact));
/*
* Since the p2artifacts.xml exists on disk, we can add the artifact to the (global)
* p2 artifact repository view of local Maven repository. Then, the artifact is
* available in the build.
*/
// TODO this should happen in resolution context
p2ArtifactsInLocalRepo.addGav(new GAV(artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion()));
} else if (!p2Data.p2MetadataXml.isAvailable() && !p2Data.p2ArtifactsXml.isAvailable()) {
/*
* The POM dependency has not been built by Tycho. If the dependency is a bundle,
* run the p2 bundle publisher on it and add the result to the resolution context.
*/
if (logger.isDebugEnabled()) {
logger.debug("P2resolver.addMavenArtifact " + artifact.toString());
}
result.publishAndAddArtifactIfBundleArtifact(new ArtifactFacade(artifact));
} else {
failDueToPartialP2Data(artifact, p2Data);
}
}
return result;
}
use of org.eclipse.tycho.p2.repository.GAV in project tycho by eclipse.
the class RepositoryLayoutHelperTest method testRelpathSimpleGroupId.
@Test
public void testRelpathSimpleGroupId() {
GAV gav = new GAV("a", "b", "1.0.0");
Assert.assertEquals("a/b/1.0.0/b-1.0.0.jar", RepositoryLayoutHelper.getRelativePath(gav, null, null));
}
use of org.eclipse.tycho.p2.repository.GAV in project tycho by eclipse.
the class UpdateLocalIndexMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
LocalRepositoryP2Indices localRepoIndices = serviceFactory.getService(LocalRepositoryP2Indices.class);
GAV gav = new GAV(project.getGroupId(), project.getArtifactId(), project.getArtifact().getVersion());
TychoRepositoryIndex artifactsIndex = localRepoIndices.getArtifactsIndex();
TychoRepositoryIndex metadataIndex = localRepoIndices.getMetadataIndex();
try {
addGavAndSave(gav, artifactsIndex);
addGavAndSave(gav, metadataIndex);
} catch (IOException e) {
throw new MojoExecutionException("Could not update local repository index", e);
}
}
Aggregations