use of io.fabric8.agent.model.Repository in project fabric8 by jboss-fuse.
the class AetherBasedResolver method addLocalSubDirs.
private void addLocalSubDirs(List<LocalRepository> list, File parentDir) {
if (!parentDir.isDirectory()) {
LOG.debug("Repository marked with @multi does not resolve to a directory: " + parentDir);
return;
}
for (File repo : parentDir.listFiles()) {
if (repo.isDirectory()) {
try {
String repoURI = repo.toURI().toString() + "@id=" + repo.getName();
LOG.debug("Adding repo from inside multi dir: " + repoURI);
addLocalRepo(list, new MavenRepositoryURL(repoURI));
} catch (MalformedURLException e) {
LOG.error("Error resolving repo url of a multi repo " + repo.toURI());
}
}
}
}
use of io.fabric8.agent.model.Repository in project fabric8 by jboss-fuse.
the class AetherBasedResolver method selectDefaultRepositories.
List<LocalRepository> selectDefaultRepositories() {
List<LocalRepository> list = new ArrayList<LocalRepository>();
List<MavenRepositoryURL> urls = Collections.emptyList();
try {
urls = m_config.getDefaultRepositories();
} catch (MalformedURLException exc) {
LOG.error("invalid repository URLs", exc);
}
for (MavenRepositoryURL r : urls) {
if (r.isMulti()) {
addLocalSubDirs(list, r.getFile());
} else {
addLocalRepo(list, r);
}
}
return list;
}
use of io.fabric8.agent.model.Repository in project fabric8 by jboss-fuse.
the class MavenProxyResolutionTest method releaseIsAvailableInRemoteRepositoryNotUpdatingRelease.
@Test
public void releaseIsAvailableInRemoteRepositoryNotUpdatingRelease() throws IOException, InvalidMavenArtifactRequest {
File remoteRepository = initFileRepository("rr");
MavenResolver resolver = new ResolverBuilder().withRemoteRepositories(Collections.singletonList(remoteRepository)).withUpdatePolicy(RepositoryPolicy.UPDATE_POLICY_ALWAYS).build();
MavenDownloadProxyServlet servlet = new MavenDownloadProxyServlet(resolver, runtime, null, 1, 0);
mvnInstall(remoteRepository, "io.fabric8.test", "universalis-api", "0.1.0", at("10:00"), "a");
File file = servlet.download("io/fabric8/test/universalis-api/0.1.0/universalis-api-0.1.0.jar");
// first resolution
assertThat(FileUtils.readFileToString(file), equalTo("a"));
// don't do that, it's not proper use of maven. But sometimes we just have another deployment to public repository...
mvnInstall(remoteRepository, "io.fabric8.test", "universalis-api", "0.1.0", at("11:00"), "b");
// second resolution
file = servlet.download("io/fabric8/test/universalis-api/0.1.0/universalis-api-0.1.0.jar");
assertThat("Artifact won't be updated for release version", FileUtils.readFileToString(file), equalTo("a"));
}
use of io.fabric8.agent.model.Repository in project fabric8 by jboss-fuse.
the class MavenProxySnapshotResolutionTest method snapshotIsAvailableInDefaultRepositoryActingAsRemote.
@Test
public void snapshotIsAvailableInDefaultRepositoryActingAsRemote() throws IOException, InvalidMavenArtifactRequest {
File differentLocalRepository = initFileRepository("dlr");
File defaultRepository = initFileRepository("dr");
MavenResolver resolver = new ResolverBuilder().withRemoteRepositories(Collections.<File>emptyList()).withUpdatePolicy(RepositoryPolicy.UPDATE_POLICY_NEVER).withDefaultRepositories(Collections.singletonList(defaultRepository)).build();
MavenDownloadProxyServlet servlet = new MavenDownloadProxyServlet(resolver, runtime, null, 1, 0);
servlet.start();
mvnDeploy(differentLocalRepository, defaultRepository, "io.fabric8.test", "universalis-api", "0.1.0-SNAPSHOT", at("10:00"), "a");
// Here's expected state of repository where SNAPSHOT was `mvn deploy`ed
assertFalse(new File(defaultRepository, "io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/maven-metadata-local.xml").isFile());
assertTrue(new File(defaultRepository, "io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/maven-metadata.xml").isFile());
File file = servlet.download("io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/maven-metadata.xml");
Metadata metadata = readMetadata(file);
boolean checked = false;
assertThat(metadata.getVersioning().getSnapshot().isLocalCopy(), is(false));
for (SnapshotVersion snapshotVersion : metadata.getVersioning().getSnapshotVersions()) {
if ("jar".equals(snapshotVersion.getExtension())) {
assertThat(snapshotVersion.getVersion(), is("0.1.0-20170101.100000-1"));
checked = true;
}
}
assertTrue("We should find snapshot metadata", checked);
// download artifact using version from metadata
file = servlet.download("io/fabric8/test/universalis-api/0.1.0-20170101.100000-1/universalis-api-0.1.0-20170101.100000-1.jar");
assertThat(FileUtils.readFileToString(file), equalTo("a"));
mvnDeploy(differentLocalRepository, defaultRepository, "io.fabric8.test", "universalis-api", "0.1.0-SNAPSHOT", at("11:00"), "b");
file = servlet.download("io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/maven-metadata.xml");
metadata = readMetadata(file);
assertThat("No policy should prevent us from seeing newer snapshot from defaultRepository", metadata.getVersioning().getSnapshotVersions().get(0).getVersion(), is("0.1.0-20170101.110000-2"));
}
use of io.fabric8.agent.model.Repository in project fabric8 by jboss-fuse.
the class MavenProxySnapshotResolutionTest method snapshotIsAvailableInLocalAndDefaultRepository.
@Test
public void snapshotIsAvailableInLocalAndDefaultRepository() throws IOException, InvalidMavenArtifactRequest {
File defaultRepository = initFileRepository("dr");
MavenResolver resolver = new ResolverBuilder().withDefaultRepositories(Collections.singletonList(defaultRepository)).build();
MavenDownloadProxyServlet servlet = new MavenDownloadProxyServlet(resolver, runtime, null, 1, 0);
servlet.start();
mvnInstall(defaultRepository, "io.fabric8.test", "universalis-api", "0.1.0-SNAPSHOT", at("11:00"), "a");
mvnInstall(localRepository, "io.fabric8.test", "universalis-api", "0.1.0-SNAPSHOT", at("12:00"), "b");
File file = servlet.download("io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/maven-metadata.xml");
Metadata metadata = readMetadata(file);
assertThat("Default repository has priority over local repository", metadata.getVersioning().getSnapshotVersions().get(0).getUpdated(), is("20170101110000"));
}
Aggregations