Search in sources :

Example 16 with ArtifactRepository

use of org.apache.maven.artifact.repository.ArtifactRepository in project unleash-maven-plugin by shillner.

the class ReleaseMetadata method init.

@PostConstruct
public void init() {
    // setting the artifact version to a release version temporarily since the dist repository checks for a snapshot
    // version of the artifact. Maybe this can be implemented in a different manner but then we would have to setup the
    // repository manually
    org.apache.maven.artifact.Artifact projectArtifact = this.project.getArtifact();
    String oldVersion = projectArtifact.getVersion();
    projectArtifact.setVersion("1");
    // replace properties in remote repository URL and getting the remote repo
    ArtifactRepository artifactRepository = this.project.getDistributionManagementArtifactRepository();
    if (artifactRepository != null) {
        PomPropertyResolver propertyResolver = new PomPropertyResolver(this.project, this.settings, this.profiles, this.releaseArgs);
        artifactRepository.setUrl(propertyResolver.expandPropertyReferences(artifactRepository.getUrl()));
        this.deploymentRepository = RepositoryUtils.toRepo(artifactRepository);
    }
    // resetting the artifact version
    projectArtifact.setVersion(oldVersion);
    for (MavenProject p : this.reactorProjects) {
        // puts the initial module artifact coordinates into the cache
        addArtifactCoordinates(ProjectToCoordinates.POM.apply(p), ReleasePhase.PRE_RELEASE);
        // caching of SCM settings of every POM in order to go back to it before setting next dev version
        this.cachedScmSettings.put(ProjectToCoordinates.EMPTY_VERSION.apply(p), p.getModel().getScm());
        Optional<Document> parsedPOM = PomUtil.parsePOM(p);
        if (parsedPOM.isPresent()) {
            this.originalPOMs.put(ProjectToCoordinates.EMPTY_VERSION.apply(p), parsedPOM.get());
        }
    }
}
Also used : PomPropertyResolver(com.itemis.maven.plugins.unleash.util.PomPropertyResolver) MavenProject(org.apache.maven.project.MavenProject) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) Document(org.w3c.dom.Document) PostConstruct(javax.annotation.PostConstruct)

Example 17 with ArtifactRepository

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

the class JdkLibraryInfoProvider method getLibDetectorJar.

protected File getLibDetectorJar() {
    if (libDetectorJar != null) {
        return libDetectorJar;
    }
    Artifact libDetectorArtifact = repositorySystem.createArtifact("org.eclipse.tycho", "tycho-lib-detector", TychoVersion.getTychoVersion(), "jar");
    ArtifactRepository localRepository = legacySupport.getSession().getLocalRepository();
    return libDetectorJar = new File(localRepository.getBasedir(), localRepository.pathOf(libDetectorArtifact));
}
Also used : ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact)

Example 18 with ArtifactRepository

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

the class AbstractTychoMojoTestCase method getLocalRepository.

protected ArtifactRepository getLocalRepository() throws Exception {
    RepositorySystem repoSystem = lookup(RepositorySystem.class);
    File path = new File("target/local-repo").getAbsoluteFile();
    ArtifactRepository r = repoSystem.createLocalRepository(path);
    return r;
}
Also used : RepositorySystem(org.apache.maven.repository.RepositorySystem) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) File(java.io.File)

Example 19 with ArtifactRepository

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

the class P2DependencyResolver method computePreliminaryTargetPlatform.

@Override
public TargetPlatform computePreliminaryTargetPlatform(MavenSession session, MavenProject project, List<ReactorProject> reactorProjects) {
    TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(project);
    ExecutionEnvironmentConfiguration ee = TychoProjectUtils.getExecutionEnvironmentConfiguration(project);
    TargetPlatformConfigurationStub tpConfiguration = new TargetPlatformConfigurationStub();
    tpConfiguration.setIncludePackedArtifacts(configuration.isIncludePackedArtifacts());
    PomDependencyCollector pomDependencies = null;
    if (TargetPlatformConfiguration.POM_DEPENDENCIES_CONSIDER.equals(configuration.getPomDependencies())) {
        pomDependencies = collectPomDependencies(project, reactorProjects, session);
    } else {
        // TODO 412416 remove this when the setProjectLocation is no longer needed
        pomDependencies = resolverFactory.newPomDependencyCollector();
        pomDependencies.setProjectLocation(project.getBasedir());
    }
    for (ArtifactRepository repository : project.getRemoteArtifactRepositories()) {
        addEntireP2RepositoryToTargetPlatform(repository, tpConfiguration);
    }
    tpConfiguration.setEnvironments(configuration.getEnvironments());
    for (File file : configuration.getTargets()) {
        addTargetFileContentToTargetPlatform(file, configuration.getTargetDefinitionIncludeSourceMode(), tpConfiguration);
    }
    tpConfiguration.addFilters(configuration.getFilters());
    return reactorRepositoryManager.computePreliminaryTargetPlatform(DefaultReactorProject.adapt(project), tpConfiguration, ee, reactorProjects, pomDependencies);
}
Also used : TargetPlatformConfigurationStub(org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub) ExecutionEnvironmentConfiguration(org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfiguration) PomDependencyCollector(org.eclipse.tycho.p2.target.facade.PomDependencyCollector) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) File(java.io.File)

Example 20 with ArtifactRepository

use of org.apache.maven.artifact.repository.ArtifactRepository in project wildfly-swarm by wildfly-swarm.

the class MavenArtifactResolvingHelperTest method propagateRepositoryPolicies.

@Test
public // SWARM-1173: swarm-plugin trying to download SNAPSHOTs from Maven Central
void propagateRepositoryPolicies() {
    RepositorySystemSession sessionMock = Mockito.mock(RepositorySystemSession.class);
    MirrorSelector mirrorSelectorMock = Mockito.mock(MirrorSelector.class);
    Mockito.when(sessionMock.getMirrorSelector()).thenReturn(mirrorSelectorMock);
    ProxySelector proxySelectorMock = Mockito.mock(ProxySelector.class);
    Mockito.when(sessionMock.getProxySelector()).thenReturn(proxySelectorMock);
    MavenArtifactResolvingHelper artifactResolverHelper = new MavenArtifactResolvingHelper(null, null, sessionMock, null);
    ArtifactRepositoryPolicy testSnapshotPolicy = new ArtifactRepositoryPolicy(false, "hourly", "warn");
    ArtifactRepositoryPolicy testReleasesPolicy = new ArtifactRepositoryPolicy(true, "never", "warn");
    ArtifactRepository testingRepo = new MavenArtifactRepository("testing-repo", "http://testing-repo.org", new DefaultRepositoryLayout(), testSnapshotPolicy, testReleasesPolicy);
    artifactResolverHelper.remoteRepository(testingRepo);
    List<RemoteRepository> remoteRepos = artifactResolverHelper.getRemoteRepositories();
    Assert.assertTrue("Remote repositories " + remoteRepos + " do not contain expected testing repo " + testingRepo, remoteRepos.stream().anyMatch(remoteRepo -> {
        RepositoryPolicy snapshotsPolicy = remoteRepo.getPolicy(true);
        RepositoryPolicy releasesPolicy = remoteRepo.getPolicy(false);
        return remoteRepo.getId().equals(testingRepo.getId()) && !snapshotsPolicy.isEnabled() && snapshotsPolicy.getUpdatePolicy().equals(testSnapshotPolicy.getUpdatePolicy()) && snapshotsPolicy.getChecksumPolicy().equals(testSnapshotPolicy.getChecksumPolicy()) && releasesPolicy.isEnabled() && releasesPolicy.getUpdatePolicy().equals(testReleasesPolicy.getUpdatePolicy()) && releasesPolicy.getChecksumPolicy().equals(testReleasesPolicy.getChecksumPolicy());
    }));
}
Also used : ProxySelector(org.eclipse.aether.repository.ProxySelector) RepositoryPolicy(org.eclipse.aether.repository.RepositoryPolicy) DefaultRepositoryLayout(org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout) ProxySelector(org.eclipse.aether.repository.ProxySelector) Test(org.junit.Test) RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) ArtifactRepositoryPolicy(org.apache.maven.artifact.repository.ArtifactRepositoryPolicy) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) Mockito(org.mockito.Mockito) List(java.util.List) MirrorSelector(org.eclipse.aether.repository.MirrorSelector) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) Assert(org.junit.Assert) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository) RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) MirrorSelector(org.eclipse.aether.repository.MirrorSelector) ArtifactRepositoryPolicy(org.apache.maven.artifact.repository.ArtifactRepositoryPolicy) RepositoryPolicy(org.eclipse.aether.repository.RepositoryPolicy) ArtifactRepositoryPolicy(org.apache.maven.artifact.repository.ArtifactRepositoryPolicy) DefaultRepositoryLayout(org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) Test(org.junit.Test)

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