Search in sources :

Example 6 with Resolver

use of io.fabric8.patch.management.conflicts.Resolver in project fabric8 by jboss-fuse.

the class ContainerResolverSetAction method doExecute.

@Override
protected Object doExecute() throws Exception {
    if (containerIds == null || containerIds.isEmpty()) {
        if (all) {
            containerIds = new ArrayList<String>();
            for (Container container : fabricService.getContainers()) {
                containerIds.add(container.getId());
            }
        } else {
            System.out.println("No container has been specified. Assuming the current container.");
            containerIds = Arrays.asList(fabricService.getCurrentContainer().getId());
        }
    } else {
        if (all) {
            throw new IllegalArgumentException("Can not use --all with a list of containers simultaneously.");
        }
    }
    for (String containerId : containerIds) {
        Container container = fabricService.getContainer(containerId);
        container.setResolver(resolver);
        if (resolver.equalsIgnoreCase("manualip")) {
            if (manualIp != null && !manualIp.isEmpty()) {
                setData(getCurator(), ZkPath.CONTAINER_MANUAL_IP.getPath(containerId), manualIp);
            }
        }
    }
    return null;
}
Also used : Container(io.fabric8.api.Container)

Example 7 with Resolver

use of io.fabric8.patch.management.conflicts.Resolver 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"));
}
Also used : MavenResolver(io.fabric8.maven.MavenResolver) File(java.io.File) Test(org.junit.Test)

Example 8 with Resolver

use of io.fabric8.patch.management.conflicts.Resolver 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"));
}
Also used : SnapshotVersion(org.apache.maven.artifact.repository.metadata.SnapshotVersion) MavenResolver(io.fabric8.maven.MavenResolver) Metadata(org.apache.maven.artifact.repository.metadata.Metadata) File(java.io.File) Test(org.junit.Test)

Example 9 with Resolver

use of io.fabric8.patch.management.conflicts.Resolver 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"));
}
Also used : MavenResolver(io.fabric8.maven.MavenResolver) Metadata(org.apache.maven.artifact.repository.metadata.Metadata) File(java.io.File) Test(org.junit.Test)

Example 10 with Resolver

use of io.fabric8.patch.management.conflicts.Resolver in project fabric8 by jboss-fuse.

the class MavenProxySnapshotResolutionTest method snapshotIsAvailableInDefaultRepository.

@Test
public void snapshotIsAvailableInDefaultRepository() throws IOException, InvalidMavenArtifactRequest {
    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();
    mvnInstall(defaultRepository, "io.fabric8.test", "universalis-api", "0.1.0-SNAPSHOT", at("10:00"), "a");
    // Here's expected state of repository where SNAPSHOT was `mvn install`ed
    assertFalse(new File(defaultRepository, "io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/maven-metadata.xml").isFile());
    assertTrue(new File(defaultRepository, "io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/maven-metadata-local.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(true));
    for (SnapshotVersion snapshotVersion : metadata.getVersioning().getSnapshotVersions()) {
        if ("jar".equals(snapshotVersion.getExtension())) {
            assertThat(snapshotVersion.getVersion(), is("0.1.0-SNAPSHOT"));
            checked = true;
        }
    }
    assertTrue("We should find snapshot metadata", checked);
    // if metadata says it's "0.1.0-SNAPSHOT", we should have no problem downloading this artifact without
    // version transformation
    file = servlet.download("io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/universalis-api-0.1.0-SNAPSHOT.jar");
    assertThat(FileUtils.readFileToString(file), equalTo("a"));
    mvnInstall(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/universalis-api-0.1.0-SNAPSHOT.jar");
    assertThat("No policy should prevent us from seeing newer snapshot from defaultRepository", FileUtils.readFileToString(file), equalTo("b"));
}
Also used : SnapshotVersion(org.apache.maven.artifact.repository.metadata.SnapshotVersion) MavenResolver(io.fabric8.maven.MavenResolver) Metadata(org.apache.maven.artifact.repository.metadata.Metadata) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)23 MavenResolver (io.fabric8.maven.MavenResolver)22 Test (org.junit.Test)21 IOException (java.io.IOException)20 FabricService (io.fabric8.api.FabricService)10 Container (io.fabric8.api.Container)9 RuntimeProperties (io.fabric8.api.RuntimeProperties)7 HashMap (java.util.HashMap)7 PlaceholderResolver (io.fabric8.api.PlaceholderResolver)6 HashSet (java.util.HashSet)6 Hashtable (java.util.Hashtable)6 Metadata (org.apache.maven.artifact.repository.metadata.Metadata)6 Map (java.util.Map)5 DownloadManager (io.fabric8.agent.download.DownloadManager)4 AbstractRuntimeProperties (io.fabric8.api.scr.AbstractRuntimeProperties)4 MavenConfigurationImpl (io.fabric8.maven.util.MavenConfigurationImpl)4 FileInputStream (java.io.FileInputStream)4 URI (java.net.URI)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)4