Search in sources :

Example 61 with ArtifactRepository

use of org.apache.maven.artifact.repository.ArtifactRepository in project intellij-community by JetBrains.

the class Maven3ServerEmbedderImpl method convertRepositories.

@NotNull
protected List<ArtifactRepository> convertRepositories(List<MavenRemoteRepository> repositories) throws RemoteException {
    List<ArtifactRepository> result = new ArrayList<ArtifactRepository>();
    for (MavenRemoteRepository each : repositories) {
        try {
            ArtifactRepositoryFactory factory = getComponent(ArtifactRepositoryFactory.class);
            result.add(ProjectUtils.buildArtifactRepository(MavenModelConverter.toNativeRepository(each), factory, myContainer));
        } catch (InvalidRepositoryException e) {
            Maven3ServerGlobals.getLogger().warn(e);
        }
    }
    return result;
}
Also used : InvalidRepositoryException(org.apache.maven.artifact.InvalidRepositoryException) ArtifactRepositoryFactory(org.apache.maven.artifact.repository.ArtifactRepositoryFactory) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) NotNull(org.jetbrains.annotations.NotNull)

Example 62 with ArtifactRepository

use of org.apache.maven.artifact.repository.ArtifactRepository in project intellij-community by JetBrains.

the class Maven2ServerEmbedderImpl method convertRepositories.

private List<ArtifactRepository> convertRepositories(List<MavenRemoteRepository> repositories) throws RemoteException {
    List<ArtifactRepository> result = new ArrayList<ArtifactRepository>();
    for (MavenRemoteRepository each : repositories) {
        try {
            ArtifactRepositoryFactory factory = getComponent(ArtifactRepositoryFactory.class);
            result.add(ProjectUtils.buildArtifactRepository(Maven2ModelConverter.toNativeRepository(each), factory, getContainer()));
        } catch (InvalidRepositoryException e) {
            Maven2ServerGlobals.getLogger().warn(e);
        }
    }
    return result;
}
Also used : InvalidRepositoryException(org.apache.maven.artifact.InvalidRepositoryException) ArtifactRepositoryFactory(org.apache.maven.artifact.repository.ArtifactRepositoryFactory) DefaultArtifactRepository(org.apache.maven.artifact.repository.DefaultArtifactRepository) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository)

Example 63 with ArtifactRepository

use of org.apache.maven.artifact.repository.ArtifactRepository in project intellij-community by JetBrains.

the class Maven30ServerEmbedderImpl method createLocalRepository.

private ArtifactRepository createLocalRepository() {
    try {
        final ArtifactRepository localRepository = getComponent(RepositorySystem.class).createLocalRepository(new File(myMavenSettings.getLocalRepository()));
        final String customRepoId = System.getProperty("maven3.localRepository.id", "localIntelliJ");
        if (customRepoId != null) {
            // see details at https://youtrack.jetbrains.com/issue/IDEA-121292
            localRepository.setId(customRepoId);
        }
        return localRepository;
    } catch (InvalidRepositoryException e) {
        throw new RuntimeException(e);
    // Legacy code.
    }
//ArtifactRepositoryLayout layout = getComponent(ArtifactRepositoryLayout.class, "default");
//ArtifactRepositoryFactory factory = getComponent(ArtifactRepositoryFactory.class);
//
//String url = myMavenSettings.getLocalRepository();
//if (!url.startsWith("file:")) url = "file://" + url;
//
//ArtifactRepository localRepository = factory.createArtifactRepository("local", url, layout, null, null);
//
//boolean snapshotPolicySet = myMavenSettings.isOffline();
//if (!snapshotPolicySet && snapshotUpdatePolicy == MavenServerSettings.UpdatePolicy.ALWAYS_UPDATE) {
//  factory.setGlobalUpdatePolicy(ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS);
//}
//factory.setGlobalChecksumPolicy(ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN);
//
//return localRepository;
}
Also used : RepositorySystem(org.apache.maven.repository.RepositorySystem) InvalidRepositoryException(org.apache.maven.artifact.InvalidRepositoryException) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) File(java.io.File)

Example 64 with ArtifactRepository

use of org.apache.maven.artifact.repository.ArtifactRepository in project intellij-community by JetBrains.

the class MavenEmbedder method createLocalRepository.

private ArtifactRepository createLocalRepository(MavenEmbedderSettings generalSettings) {
    ArtifactRepositoryLayout layout = getComponent(ArtifactRepositoryLayout.class, "default");
    ArtifactRepositoryFactory factory = getComponent(ArtifactRepositoryFactory.class);
    String url = mySettings.getLocalRepository();
    if (!url.startsWith("file:"))
        url = "file://" + url;
    ArtifactRepository localRepository = new DefaultArtifactRepository("local", url, layout);
    boolean snapshotPolicySet = mySettings.isOffline();
    if (!snapshotPolicySet && generalSettings.getSnapshotUpdatePolicy() == MavenEmbedderSettings.UpdatePolicy.ALWAYS_UPDATE) {
        factory.setGlobalUpdatePolicy(ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS);
    }
    factory.setGlobalChecksumPolicy(ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN);
    return localRepository;
}
Also used : ArtifactRepositoryLayout(org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout) DefaultArtifactRepository(org.apache.maven.artifact.repository.DefaultArtifactRepository) ArtifactRepositoryFactory(org.apache.maven.artifact.repository.ArtifactRepositoryFactory) DefaultArtifactRepository(org.apache.maven.artifact.repository.DefaultArtifactRepository) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository)

Example 65 with ArtifactRepository

use of org.apache.maven.artifact.repository.ArtifactRepository in project asterixdb by apache.

the class SourcePointerResolver method collectSourcePointers.

private void collectSourcePointers() throws ProjectBuildingException, IOException {
    try (StubArtifactRepository stubRepo = new StubArtifactRepository()) {
        DefaultRepositoryRequest rr = new DefaultRepositoryRequest();
        rr.setLocalRepository(stubRepo);
        ArtifactRepository central = getCentralRepository();
        rr.setRemoteRepositories(Collections.singletonList(central));
        ArtifactResolutionRequest request = new ArtifactResolutionRequest(rr);
        for (LicensedProjects lp : mojo.getLicenseMap().values()) {
            if (lp.getLicense().getDisplayName() != null && lp.getLicense().getDisplayName().toLowerCase().contains("cddl")) {
                ensureCDDLSourcesPointer(lp.getProjects(), central, request);
            }
        }
    }
}
Also used : LicensedProjects(org.apache.hyracks.maven.license.project.LicensedProjects) ArtifactResolutionRequest(org.apache.maven.artifact.resolver.ArtifactResolutionRequest) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) DefaultRepositoryRequest(org.apache.maven.artifact.repository.DefaultRepositoryRequest)

Aggregations

ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)108 File (java.io.File)46 Artifact (org.apache.maven.artifact.Artifact)26 MavenArtifactRepository (org.apache.maven.artifact.repository.MavenArtifactRepository)26 ArrayList (java.util.ArrayList)23 MavenProject (org.apache.maven.project.MavenProject)20 ArtifactRepositoryPolicy (org.apache.maven.artifact.repository.ArtifactRepositoryPolicy)17 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)15 IOException (java.io.IOException)13 DefaultRepositoryLayout (org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout)13 DefaultArtifact (org.apache.maven.artifact.DefaultArtifact)11 Properties (java.util.Properties)10 InvalidRepositoryException (org.apache.maven.artifact.InvalidRepositoryException)9 DefaultArtifactRepository (org.apache.maven.artifact.repository.DefaultArtifactRepository)9 Model (org.apache.maven.model.Model)9 DefaultArtifactHandler (org.apache.maven.artifact.handler.DefaultArtifactHandler)8 MojoFailureException (org.apache.maven.plugin.MojoFailureException)8 DefaultProjectBuildingRequest (org.apache.maven.project.DefaultProjectBuildingRequest)8 ProjectBuildingRequest (org.apache.maven.project.ProjectBuildingRequest)8 MavenProjectResourcesStub (org.apache.maven.plugin.resources.remote.stub.MavenProjectResourcesStub)7