org.jboss.shrinkwrap.resolver.api.maven.repository.MavenUpdatePolicy Java Examples

The following examples show how to use org.jboss.shrinkwrap.resolver.api.maven.repository.MavenUpdatePolicy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Main.java    From thorntail with Apache License 2.0 6 votes vote down vote up
private static ArtifactResolvingHelper getResolvingHelper(final List<String> repos) {
    final ConfigurableMavenResolverSystem resolver = Maven.configureResolver()
            .withMavenCentralRepo(true)
            .withRemoteRepo(MavenRemoteRepositories.createRemoteRepository("jboss-public-repository-group",
                                                                           "https://repository.jboss.org/nexus/content/groups/public/",
                                                                           "default")
                                    .setChecksumPolicy(MavenChecksumPolicy.CHECKSUM_POLICY_IGNORE)
                                    .setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_NEVER))
            .withRemoteRepo(MavenRemoteRepositories.createRemoteRepository("redhat-ga",
                                                                           "https://maven.repository.redhat.com/ga/",
                                                                           "default")
                                    .setChecksumPolicy(MavenChecksumPolicy.CHECKSUM_POLICY_IGNORE)
                                    .setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_NEVER));

    repos.forEach(r -> resolver.withRemoteRepo(MavenRemoteRepositories.createRemoteRepository(r, r, "default")
                                                       .setChecksumPolicy(MavenChecksumPolicy.CHECKSUM_POLICY_IGNORE)
                                                       .setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_NEVER)));

    return new ShrinkwrapArtifactResolvingHelper(resolver);
}
 
Example #2
Source File: AbstractArchiveProvider.java    From krazo with Apache License 2.0 5 votes vote down vote up
public AbstractArchiveProvider() {

        sonatypeRepo = MavenRemoteRepositories.createRemoteRepository(
            "sonatype-oss-snapshots",
            "https://oss.sonatype.org/content/repositories/snapshots",
            "default"
        );

        // prevent weird errors logged during test execution
        sonatypeRepo.setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_ALWAYS);

    }
 
Example #3
Source File: AbstractArchiveProvider.java    From ozark with Apache License 2.0 5 votes vote down vote up
public AbstractArchiveProvider() {

        sonatypeRepo = MavenRemoteRepositories.createRemoteRepository(
            "sonatype-oss-snapshots",
            "https://oss.sonatype.org/content/repositories/snapshots",
            "default"
        );

        // prevent weird errors logged during test execution
        sonatypeRepo.setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_ALWAYS);

    }
 
Example #4
Source File: Main.java    From wildfly-swarm with Apache License 2.0 5 votes vote down vote up
private static ArtifactResolvingHelper getResolvingHelper(final List<String> repos) {
    final ConfigurableMavenResolverSystem resolver = Maven.configureResolver()
            .withMavenCentralRepo(true)
            .withRemoteRepo(MavenRemoteRepositories.createRemoteRepository("jboss-public-repository-group",
                                                                           "http://repository.jboss.org/nexus/content/groups/public/",
                                                                           "default")
                                    .setChecksumPolicy(MavenChecksumPolicy.CHECKSUM_POLICY_IGNORE)
                                    .setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_NEVER));

    repos.forEach(r -> resolver.withRemoteRepo(MavenRemoteRepositories.createRemoteRepository(r, r, "default")
                                                       .setChecksumPolicy(MavenChecksumPolicy.CHECKSUM_POLICY_IGNORE)
                                                       .setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_NEVER)));

    return new ShrinkwrapArtifactResolvingHelper(resolver);
}
 
Example #5
Source File: ShrinkwrapArtifactResolvingHelper.java    From thorntail with Apache License 2.0 4 votes vote down vote up
public static ShrinkwrapArtifactResolvingHelper defaultInstance() {
    return INSTANCE.updateAndGet(e -> {
        if (e != null) {
            return e;
        }

        MavenRemoteRepository jbossPublic =
                MavenRemoteRepositories.createRemoteRepository("jboss-public-repository-group",
                                                               "https://repository.jboss.org/nexus/content/groups/public/",
                                                               MAVEN_LAYOUT_DEFAULT);
        jbossPublic.setChecksumPolicy(MavenChecksumPolicy.CHECKSUM_POLICY_IGNORE);
        jbossPublic.setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_NEVER);

        MavenRemoteRepository redhatGa =
                MavenRemoteRepositories.createRemoteRepository("redhat-ga",
                                                               "https://maven.repository.redhat.com/ga/",
                                                               MAVEN_LAYOUT_DEFAULT);
        redhatGa.setChecksumPolicy(MavenChecksumPolicy.CHECKSUM_POLICY_IGNORE);
        redhatGa.setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_NEVER);

        MavenRemoteRepository gradleTools =
                MavenRemoteRepositories.createRemoteRepository("gradle",
                                                               "https://repo.gradle.org/gradle/libs-releases-local",
                                                               MAVEN_LAYOUT_DEFAULT);
        gradleTools.setChecksumPolicy(MavenChecksumPolicy.CHECKSUM_POLICY_IGNORE);
        gradleTools.setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_NEVER);

        Boolean offline = Boolean.valueOf(System.getProperty("thorntail.resolver.offline", "false"));
        final ConfigurableMavenResolverSystem resolver = Maven.configureResolver()
                .withMavenCentralRepo(true)
                .withRemoteRepo(jbossPublic)
                .withRemoteRepo(redhatGa)
                .withRemoteRepo(gradleTools)
                .workOffline(offline);

        final String additionalRepos = System.getProperty(SwarmInternalProperties.BUILD_REPOS);
        if (additionalRepos != null) {
            Arrays.asList(additionalRepos.split(","))
                    .forEach(r -> {
                        MavenRemoteRepository repo =
                                MavenRemoteRepositories.createRemoteRepository(r, r, MAVEN_LAYOUT_DEFAULT);
                        repo.setChecksumPolicy(MavenChecksumPolicy.CHECKSUM_POLICY_IGNORE);
                        repo.setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_NEVER);
                        resolver.withRemoteRepo(repo);
                    });
        }


        ShrinkwrapArtifactResolvingHelper helper = new ShrinkwrapArtifactResolvingHelper(resolver);
        helper.session().setCache(new SimpleRepositoryCache());
        helper.session().setUpdatePolicy(RepositoryPolicy.UPDATE_POLICY_DAILY);
        helper.session().setChecksumPolicy(RepositoryPolicy.CHECKSUM_POLICY_IGNORE);

        return helper;
    });
}
 
Example #6
Source File: Build.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 4 votes vote down vote up
public File run() throws Exception {
    final String[] parts = this.source.getName().split("\\.(?=[^\\.]+$)");
    final String baseName = parts[0];
    final String type = parts[1] == null ? "jar" : parts[1];
    final MavenRemoteRepository jbossPublic =
            MavenRemoteRepositories.createRemoteRepository("jboss-public-repository-group",
                    "http://repository.jboss.org/nexus/content/groups/public/",
                    "default");
    jbossPublic.setChecksumPolicy(MavenChecksumPolicy.CHECKSUM_POLICY_IGNORE);
    jbossPublic.setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_NEVER);

    final ConfigurableMavenResolverSystem resolver = Maven.configureResolver()
            .withMavenCentralRepo(true)
            .withRemoteRepo(jbossPublic);

    final BuildTool tool = new BuildTool()
            .artifactResolvingHelper(new ShrinkwrapArtifactResolvingHelper(resolver))
            .projectArtifact("", baseName, "", type, this.source)
            .resolveTransitiveDependencies(true)
            .properties(this.properties);

    if (this.autoDetectFractions) {
        this.swarmDependencies.addAll(new PackageAnalyzer(this.source).detectNeededFractions());
    } else {
        System.err.println("Skipping fraction auto-detection");
    }

    for (String dep : this.swarmDependencies) {
        tool.dependency("compile", "org.wildfly.swarm", dep, this.version, "jar", null, null, true);
    }

    final String jarName = this.name != null ? this.name : baseName;
    final String outDir = this.outputDir.getCanonicalPath();
    System.err.println(String.format("Building %s/%s-swarm.jar with fractions: %s",
            outDir,
            jarName,
            String.join(", ",
                    allRequiredFractions()
                            .stream()
                            .sorted()
                            .collect(Collectors.toList()))));

    return tool.build(jarName, Paths.get(outDir));
}
 
Example #7
Source File: LibraryResolverMaven.java    From jqm with Apache License 2.0 4 votes vote down vote up
ConfigurableMavenResolverSystem getMavenResolver()
{
    // Retrieve resolver configuration
    if (REPO_LIST == null)
    {
        REPO_LIST = new ArrayList<>(5);
        for (String gp : mavenRepos)
        {
            REPO_LIST.add(gp);
        }

        MAVEN_SETTINGS_CL = mavenSettingsClPath;
        MAVEN_SETTINGS_FILE = mavenSettingsFilePath;
    }

    // Resolver
    ConfigurableMavenResolverSystem resolver = Maven.configureResolver();

    // settings.xml?
    if (MAVEN_SETTINGS_CL != null && MAVEN_SETTINGS_FILE == null)
    {
        jqmlogger.trace("Custom settings file from class-path will be used: " + MAVEN_SETTINGS_CL);
        resolver.fromClassloaderResource(MAVEN_SETTINGS_CL);
    }
    if (MAVEN_SETTINGS_FILE != null)
    {
        jqmlogger.trace("Custom settings file from file system will be used: " + MAVEN_SETTINGS_FILE);
        resolver.fromFile(MAVEN_SETTINGS_FILE);
    }

    // Repositories to use.
    boolean withCentral = false;
    for (String repo : REPO_LIST)
    {
        if (repo.contains("repo1.maven.org"))
        {
            withCentral = true;
            jqmlogger.trace("Using Maven central as a Maven repository");
            continue;
        }
        jqmlogger.trace("Using Maven repository {}", repo);
        resolver = resolver
                .withRemoteRepo(MavenRemoteRepositories.createRemoteRepository("repo" + Math.abs(repo.hashCode()), repo, "default")
                        .setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_NEVER));
    }
    resolver.withMavenCentralRepo(withCentral);
    return resolver;
}