use of org.eclipse.ceylon.model.cmr.ArtifactResult in project ceylon by eclipse.
the class MavenBackupDependencyResolver method resolve.
@Override
public ModuleInfo resolve(DependencyContext context, Overrides overrides) {
if (context.ignoreInner() == false) {
ArtifactResult result = context.result();
File mod = result.artifact();
if (mod != null && IOUtils.isZipFile(mod)) {
String name = result.name();
int p = name.indexOf(':');
if (p < 0) {
p = name.lastIndexOf('.');
}
if (p < 0) {
// not a Maven artifact
return null;
}
String groupId = name.substring(0, p);
String artifactId = name.substring(p + 1);
String descriptorPath = String.format("META-INF/maven/%s/%s/pom.xml", groupId, artifactId);
InputStream inputStream = IOUtils.findDescriptor(result, descriptorPath);
if (inputStream != null) {
try {
return resolveFromInputStream(inputStream, name, result.version(), overrides);
} finally {
IOUtils.safeClose(inputStream);
}
}
}
}
return null;
}
use of org.eclipse.ceylon.model.cmr.ArtifactResult in project ceylon by eclipse.
the class MavenDependencyResolver method resolve.
@Override
public ModuleInfo resolve(DependencyContext context, Overrides overrides) {
if (context.ignoreInner() == false) {
ArtifactResult result = context.result();
File mod = result.artifact();
if (mod != null && IOUtils.isZipFile(mod)) {
String name = result.name();
int p = name.indexOf(':');
if (p < 0) {
p = name.lastIndexOf('.');
}
if (p < 0) {
// not a Maven artifact
return null;
}
String groupId = name.substring(0, p);
String artifactId = name.substring(p + 1);
String descriptorPath = String.format("META-INF/maven/%s/%s/pom.xml", groupId, artifactId);
InputStream inputStream = IOUtils.findDescriptor(result, descriptorPath);
if (inputStream != null) {
try {
return resolveFromInputStream(inputStream, name, result.version(), overrides);
} finally {
IOUtils.safeClose(inputStream);
}
}
}
}
return null;
}
use of org.eclipse.ceylon.model.cmr.ArtifactResult in project ceylon by eclipse.
the class AetherTestCase method testAetherFetchingDependenciesWithUselessProperties.
@Test
public void testAetherFetchingDependenciesWithUselessProperties() throws Throwable {
CmrRepository repository = AetherRepository.createRepository(log, false, 60000);
RepositoryManager manager = new SimpleRepositoryManager(repository, log);
ArtifactResult result = manager.getArtifactResult(MavenArtifactContext.NAMESPACE, "org.springframework.cloud:spring-cloud-starter-eureka", "1.1.2.RELEASE");
Assert.assertNotNull(result);
File artifact = result.artifact();
boolean exists = false;
try {
Assert.assertNotNull(artifact);
Assert.assertTrue(artifact.exists());
exists = true;
List<ArtifactResult> deps = result.dependencies();
Assert.assertEquals(10, deps.size());
log.debug("deps = " + deps);
} finally {
if (exists) {
// delete this one
Assert.assertTrue(artifact.delete());
}
}
}
use of org.eclipse.ceylon.model.cmr.ArtifactResult in project ceylon by eclipse.
the class AetherTestCase method testFilterOverrides.
@Test
public void testFilterOverrides() throws Throwable {
CmrRepository repository = createAetherRepository();
RepositoryManager manager = new SimpleRepositoryManager(repository, log, RepositoryManagerBuilder.parseOverrides(getOverridesFileName()));
ArtifactResult result = manager.getArtifactResult(MavenArtifactContext.NAMESPACE, "org.osgi:org.osgi.core", "4.0.0");
Assert.assertNotNull(result);
Assert.assertEquals(result.name(), "org.osgi:org.osgi.core");
File artifact = result.artifact();
boolean exists = false;
try {
Assert.assertNotNull(artifact);
Assert.assertTrue(artifact.exists());
exists = true;
Assert.assertNotNull(result.filter());
Assert.assertTrue(result.filter().accept("org/osgi/test"));
Assert.assertFalse(result.filter().accept("org/eclipse/test"));
} finally {
if (exists) {
// delete this one
Assert.assertTrue(artifact.delete());
}
}
}
use of org.eclipse.ceylon.model.cmr.ArtifactResult in project ceylon by eclipse.
the class AetherTestCase method testReplaceOverrides.
@Test
public void testReplaceOverrides() throws Throwable {
CmrRepository repository = createAetherRepository();
RepositoryManager manager = new SimpleRepositoryManager(repository, log, RepositoryManagerBuilder.parseOverrides(getOverridesFileName()));
ArtifactResult result = manager.getArtifactResult(MavenArtifactContext.NAMESPACE, "org.apache.camel:camel-core", "2.9.2");
Assert.assertNotNull(result);
Assert.assertEquals(result.name(), "org.osgi:org.osgi.core");
File artifact = result.artifact();
boolean exists = false;
try {
Assert.assertNotNull(artifact);
Assert.assertTrue(artifact.exists());
exists = true;
List<ArtifactResult> deps = result.dependencies();
Assert.assertEquals(deps.size(), 0);
} finally {
if (exists) {
// delete this one
Assert.assertTrue(artifact.delete());
}
}
}
Aggregations