Modified: maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/resolve/internal/Maven31ArtifactResolver.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/resolve/internal/Maven31ArtifactResolver.java?rev=1685372&r1=1685371&r2=1685372&view=diff ============================================================================== --- maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/resolve/internal/Maven31ArtifactResolver.java (original) +++ maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/resolve/internal/Maven31ArtifactResolver.java Sun Jun 14 09:40:45 2015 @@ -1,173 +1,173 @@ -package org.apache.maven.shared.artifact.resolve.internal; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.apache.maven.RepositoryUtils; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter; -import org.apache.maven.shared.artifact.resolve.ArtifactResolver; -import org.apache.maven.shared.artifact.resolve.ArtifactResolverException; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.collection.CollectRequest; -import org.eclipse.aether.graph.DependencyFilter; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.resolution.ArtifactDescriptorException; -import org.eclipse.aether.resolution.ArtifactDescriptorRequest; -import org.eclipse.aether.resolution.ArtifactDescriptorResult; -import org.eclipse.aether.resolution.ArtifactRequest; -import org.eclipse.aether.resolution.ArtifactResolutionException; -import org.eclipse.aether.resolution.ArtifactResult; -import org.eclipse.aether.resolution.DependencyRequest; -import org.eclipse.aether.resolution.DependencyResolutionException; - -/** - * - */ -@Component( role = ArtifactResolver.class, hint = "maven31" ) -public class Maven31ArtifactResolver - implements ArtifactResolver -{ - @Requirement - private RepositorySystem repositorySystem; - - public org.apache.maven.artifact.Artifact resolveArtifact( ProjectBuildingRequest buildingRequest, - org.apache.maven.artifact.Artifact mavenArtifact, - List<ArtifactRepository> remoteRepositories ) - throws ArtifactResolverException - { - Artifact aetherArtifact = - (Artifact) Invoker.invoke( RepositoryUtils.class, "toArtifact", org.apache.maven.artifact.Artifact.class, - mavenArtifact ); - - @SuppressWarnings( "unchecked" ) - List<RemoteRepository> aetherRepositories = - (List<RemoteRepository>) Invoker.invoke( RepositoryUtils.class, "toRepos", List.class, remoteRepositories ); - - RepositorySystemSession session = - (RepositorySystemSession) Invoker.invoke( buildingRequest, "getRepositorySession" ); - - try - { - // use descriptor to respect relocation - ArtifactDescriptorRequest descriptorRequest = - new ArtifactDescriptorRequest( aetherArtifact, aetherRepositories, null ); - - ArtifactDescriptorResult descriptorResult = - repositorySystem.readArtifactDescriptor( session, descriptorRequest ); - - ArtifactRequest request = new ArtifactRequest( descriptorResult.getArtifact(), aetherRepositories, null ); - - Artifact resolvedArtifact = repositorySystem.resolveArtifact( session, request ).getArtifact(); - - return (org.apache.maven.artifact.Artifact) Invoker.invoke( RepositoryUtils.class, "toArtifact", - Artifact.class, resolvedArtifact ); - } - catch ( ArtifactResolutionException e ) - { - throw new ArtifactResolverException( e.getMessage(), e ); - } - catch ( ArtifactDescriptorException e ) - { - throw new ArtifactResolverException( e.getMessage(), e ); - } - } - - public void resolveTransitively( ProjectBuildingRequest buildingRequest, - org.apache.maven.artifact.Artifact mavenArtifact, - List<ArtifactRepository> remoteRepositories ) - throws ArtifactResolverException - { - resolveTransitively( buildingRequest, mavenArtifact, remoteRepositories, null ); - } - - public void resolveTransitively( ProjectBuildingRequest buildingRequest, - org.apache.maven.artifact.Artifact mavenArtifact, - List<ArtifactRepository> remoteRepositories, TransformableFilter dependencyFilter ) - throws ArtifactResolverException - { - Artifact aetherArtifact = - (Artifact) Invoker.invoke( RepositoryUtils.class, "toArtifact", org.apache.maven.artifact.Artifact.class, - mavenArtifact ); - - @SuppressWarnings( "unchecked" ) - List<RemoteRepository> aetherRepositories = - (List<RemoteRepository>) Invoker.invoke( RepositoryUtils.class, "toRepos", List.class, remoteRepositories ); - - RepositorySystemSession session = - (RepositorySystemSession) Invoker.invoke( buildingRequest, "getRepositorySession" ); - - try - { - // use descriptor to respect relocation - ArtifactDescriptorRequest descriptorRequest = - new ArtifactDescriptorRequest( aetherArtifact, aetherRepositories, null ); - - ArtifactDescriptorResult descriptorResult = - repositorySystem.readArtifactDescriptor( session, descriptorRequest ); - - CollectRequest request = - new CollectRequest( descriptorResult.getDependencies(), descriptorResult.getManagedDependencies(), - aetherRepositories ); - - DependencyFilter depFilter = null; - if ( dependencyFilter != null ) - { - depFilter = dependencyFilter.transform( new EclipseAetherFilterTransformer() ); - } - - DependencyRequest depRequest = new DependencyRequest( request, depFilter ); - - List<ArtifactResult> artifactResults = - repositorySystem.resolveDependencies( session, depRequest ).getArtifactResults(); - - Collection<ArtifactRequest> artifactRequests = new ArrayList<ArtifactRequest>( 1 + artifactResults.size() ); - - artifactRequests.add( new ArtifactRequest( descriptorResult.getArtifact(), aetherRepositories, null ) ); - - for ( ArtifactResult artifactResult : artifactResults ) - { - artifactRequests.add( new ArtifactRequest( artifactResult.getArtifact(), aetherRepositories, null ) ); - } - - repositorySystem.resolveArtifacts( session, artifactRequests ); - } - catch ( ArtifactDescriptorException e ) - { - throw new ArtifactResolverException( e.getMessage(), e ); - } - catch ( ArtifactResolutionException e ) - { - throw new ArtifactResolverException( e.getMessage(), e ); - } - catch ( DependencyResolutionException e ) - { - throw new ArtifactResolverException( e.getMessage(), e ); - } - } -} +package org.apache.maven.shared.artifact.resolve.internal; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.apache.maven.RepositoryUtils; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.project.ProjectBuildingRequest; +import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter; +import org.apache.maven.shared.artifact.resolve.ArtifactResolver; +import org.apache.maven.shared.artifact.resolve.ArtifactResolverException; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.collection.CollectRequest; +import org.eclipse.aether.graph.DependencyFilter; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.resolution.ArtifactDescriptorException; +import org.eclipse.aether.resolution.ArtifactDescriptorRequest; +import org.eclipse.aether.resolution.ArtifactDescriptorResult; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResolutionException; +import org.eclipse.aether.resolution.ArtifactResult; +import org.eclipse.aether.resolution.DependencyRequest; +import org.eclipse.aether.resolution.DependencyResolutionException; + +/** + * + */ +@Component( role = ArtifactResolver.class, hint = "maven31" ) +public class Maven31ArtifactResolver + implements ArtifactResolver +{ + @Requirement + private RepositorySystem repositorySystem; + + public org.apache.maven.artifact.Artifact resolveArtifact( ProjectBuildingRequest buildingRequest, + org.apache.maven.artifact.Artifact mavenArtifact, + List<ArtifactRepository> remoteRepositories ) + throws ArtifactResolverException + { + Artifact aetherArtifact = + (Artifact) Invoker.invoke( RepositoryUtils.class, "toArtifact", org.apache.maven.artifact.Artifact.class, + mavenArtifact ); + + @SuppressWarnings( "unchecked" ) + List<RemoteRepository> aetherRepositories = + (List<RemoteRepository>) Invoker.invoke( RepositoryUtils.class, "toRepos", List.class, remoteRepositories ); + + RepositorySystemSession session = + (RepositorySystemSession) Invoker.invoke( buildingRequest, "getRepositorySession" ); + + try + { + // use descriptor to respect relocation + ArtifactDescriptorRequest descriptorRequest = + new ArtifactDescriptorRequest( aetherArtifact, aetherRepositories, null ); + + ArtifactDescriptorResult descriptorResult = + repositorySystem.readArtifactDescriptor( session, descriptorRequest ); + + ArtifactRequest request = new ArtifactRequest( descriptorResult.getArtifact(), aetherRepositories, null ); + + Artifact resolvedArtifact = repositorySystem.resolveArtifact( session, request ).getArtifact(); + + return (org.apache.maven.artifact.Artifact) Invoker.invoke( RepositoryUtils.class, "toArtifact", + Artifact.class, resolvedArtifact ); + } + catch ( ArtifactResolutionException e ) + { + throw new ArtifactResolverException( e.getMessage(), e ); + } + catch ( ArtifactDescriptorException e ) + { + throw new ArtifactResolverException( e.getMessage(), e ); + } + } + + public void resolveTransitively( ProjectBuildingRequest buildingRequest, + org.apache.maven.artifact.Artifact mavenArtifact, + List<ArtifactRepository> remoteRepositories ) + throws ArtifactResolverException + { + resolveTransitively( buildingRequest, mavenArtifact, remoteRepositories, null ); + } + + public void resolveTransitively( ProjectBuildingRequest buildingRequest, + org.apache.maven.artifact.Artifact mavenArtifact, + List<ArtifactRepository> remoteRepositories, TransformableFilter dependencyFilter ) + throws ArtifactResolverException + { + Artifact aetherArtifact = + (Artifact) Invoker.invoke( RepositoryUtils.class, "toArtifact", org.apache.maven.artifact.Artifact.class, + mavenArtifact ); + + @SuppressWarnings( "unchecked" ) + List<RemoteRepository> aetherRepositories = + (List<RemoteRepository>) Invoker.invoke( RepositoryUtils.class, "toRepos", List.class, remoteRepositories ); + + RepositorySystemSession session = + (RepositorySystemSession) Invoker.invoke( buildingRequest, "getRepositorySession" ); + + try + { + // use descriptor to respect relocation + ArtifactDescriptorRequest descriptorRequest = + new ArtifactDescriptorRequest( aetherArtifact, aetherRepositories, null ); + + ArtifactDescriptorResult descriptorResult = + repositorySystem.readArtifactDescriptor( session, descriptorRequest ); + + CollectRequest request = + new CollectRequest( descriptorResult.getDependencies(), descriptorResult.getManagedDependencies(), + aetherRepositories ); + + DependencyFilter depFilter = null; + if ( dependencyFilter != null ) + { + depFilter = dependencyFilter.transform( new EclipseAetherFilterTransformer() ); + } + + DependencyRequest depRequest = new DependencyRequest( request, depFilter ); + + List<ArtifactResult> artifactResults = + repositorySystem.resolveDependencies( session, depRequest ).getArtifactResults(); + + Collection<ArtifactRequest> artifactRequests = new ArrayList<ArtifactRequest>( 1 + artifactResults.size() ); + + artifactRequests.add( new ArtifactRequest( descriptorResult.getArtifact(), aetherRepositories, null ) ); + + for ( ArtifactResult artifactResult : artifactResults ) + { + artifactRequests.add( new ArtifactRequest( artifactResult.getArtifact(), aetherRepositories, null ) ); + } + + repositorySystem.resolveArtifacts( session, artifactRequests ); + } + catch ( ArtifactDescriptorException e ) + { + throw new ArtifactResolverException( e.getMessage(), e ); + } + catch ( ArtifactResolutionException e ) + { + throw new ArtifactResolverException( e.getMessage(), e ); + } + catch ( DependencyResolutionException e ) + { + throw new ArtifactResolverException( e.getMessage(), e ); + } + } +}
Modified: maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/resolve/internal/SonatypeAetherFilterTransformer.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/resolve/internal/SonatypeAetherFilterTransformer.java?rev=1685372&r1=1685371&r2=1685372&view=diff ============================================================================== --- maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/resolve/internal/SonatypeAetherFilterTransformer.java (original) +++ maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/resolve/internal/SonatypeAetherFilterTransformer.java Sun Jun 14 09:40:45 2015 @@ -1,88 +1,88 @@ -package org.apache.maven.shared.artifact.resolve.internal; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.ArrayList; -import java.util.Collection; - -import org.apache.maven.shared.artifact.filter.resolve.AndFilter; -import org.apache.maven.shared.artifact.filter.resolve.ExclusionsFilter; -import org.apache.maven.shared.artifact.filter.resolve.FilterTransformer; -import org.apache.maven.shared.artifact.filter.resolve.OrFilter; -import org.apache.maven.shared.artifact.filter.resolve.PatternExclusionsFilter; -import org.apache.maven.shared.artifact.filter.resolve.PatternInclusionsFilter; -import org.apache.maven.shared.artifact.filter.resolve.ScopeFilter; -import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter; -import org.sonatype.aether.graph.DependencyFilter; -import org.sonatype.aether.util.filter.AndDependencyFilter; -import org.sonatype.aether.util.filter.ExclusionsDependencyFilter; -import org.sonatype.aether.util.filter.OrDependencyFilter; -import org.sonatype.aether.util.filter.PatternExclusionsDependencyFilter; -import org.sonatype.aether.util.filter.PatternInclusionsDependencyFilter; -import org.sonatype.aether.util.filter.ScopeDependencyFilter; - -/** - * - */ -class SonatypeAetherFilterTransformer - implements FilterTransformer<DependencyFilter> -{ - public AndDependencyFilter transform( AndFilter filter ) - { - Collection<DependencyFilter> filters = new ArrayList<DependencyFilter>( filter.getFilters().size() ); - for ( TransformableFilter dependencyFilter : filter.getFilters() ) - { - filters.add( dependencyFilter.transform( this ) ); - } - return new AndDependencyFilter( filters ); - } - - - public ExclusionsDependencyFilter transform( ExclusionsFilter filter ) - { - return new ExclusionsDependencyFilter( filter.getExcludes() ); - } - - public OrDependencyFilter transform( OrFilter filter ) - { - Collection<DependencyFilter> filters = new ArrayList<DependencyFilter>( filter.getFilters().size() ); - for ( TransformableFilter dependencyFilter : filter.getFilters() ) - { - filters.add( dependencyFilter.transform( this ) ); - } - return new OrDependencyFilter( filters ); - } - - public ScopeDependencyFilter transform( ScopeFilter filter ) - { - return new ScopeDependencyFilter( filter.getIncluded(), filter.getExcluded() ); - } - - public DependencyFilter transform( PatternExclusionsFilter filter ) - { - return new PatternExclusionsDependencyFilter( filter.getExcludes() ); - } - - public DependencyFilter transform( PatternInclusionsFilter filter ) - { - return new PatternInclusionsDependencyFilter( filter.getIncludes() ); - } - -} +package org.apache.maven.shared.artifact.resolve.internal; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.ArrayList; +import java.util.Collection; + +import org.apache.maven.shared.artifact.filter.resolve.AndFilter; +import org.apache.maven.shared.artifact.filter.resolve.ExclusionsFilter; +import org.apache.maven.shared.artifact.filter.resolve.FilterTransformer; +import org.apache.maven.shared.artifact.filter.resolve.OrFilter; +import org.apache.maven.shared.artifact.filter.resolve.PatternExclusionsFilter; +import org.apache.maven.shared.artifact.filter.resolve.PatternInclusionsFilter; +import org.apache.maven.shared.artifact.filter.resolve.ScopeFilter; +import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter; +import org.sonatype.aether.graph.DependencyFilter; +import org.sonatype.aether.util.filter.AndDependencyFilter; +import org.sonatype.aether.util.filter.ExclusionsDependencyFilter; +import org.sonatype.aether.util.filter.OrDependencyFilter; +import org.sonatype.aether.util.filter.PatternExclusionsDependencyFilter; +import org.sonatype.aether.util.filter.PatternInclusionsDependencyFilter; +import org.sonatype.aether.util.filter.ScopeDependencyFilter; + +/** + * + */ +class SonatypeAetherFilterTransformer + implements FilterTransformer<DependencyFilter> +{ + public AndDependencyFilter transform( AndFilter filter ) + { + Collection<DependencyFilter> filters = new ArrayList<DependencyFilter>( filter.getFilters().size() ); + for ( TransformableFilter dependencyFilter : filter.getFilters() ) + { + filters.add( dependencyFilter.transform( this ) ); + } + return new AndDependencyFilter( filters ); + } + + + public ExclusionsDependencyFilter transform( ExclusionsFilter filter ) + { + return new ExclusionsDependencyFilter( filter.getExcludes() ); + } + + public OrDependencyFilter transform( OrFilter filter ) + { + Collection<DependencyFilter> filters = new ArrayList<DependencyFilter>( filter.getFilters().size() ); + for ( TransformableFilter dependencyFilter : filter.getFilters() ) + { + filters.add( dependencyFilter.transform( this ) ); + } + return new OrDependencyFilter( filters ); + } + + public ScopeDependencyFilter transform( ScopeFilter filter ) + { + return new ScopeDependencyFilter( filter.getIncluded(), filter.getExcluded() ); + } + + public DependencyFilter transform( PatternExclusionsFilter filter ) + { + return new PatternExclusionsDependencyFilter( filter.getExcludes() ); + } + + public DependencyFilter transform( PatternInclusionsFilter filter ) + { + return new PatternInclusionsDependencyFilter( filter.getIncludes() ); + } + +} Modified: maven/shared/trunk/maven-artifact-transfer/src/test/java/org/apache/maven/shared/artifact/install/internal/Maven30ArtifactInstallerTest.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-artifact-transfer/src/test/java/org/apache/maven/shared/artifact/install/internal/Maven30ArtifactInstallerTest.java?rev=1685372&r1=1685371&r2=1685372&view=diff ============================================================================== --- maven/shared/trunk/maven-artifact-transfer/src/test/java/org/apache/maven/shared/artifact/install/internal/Maven30ArtifactInstallerTest.java (original) +++ maven/shared/trunk/maven-artifact-transfer/src/test/java/org/apache/maven/shared/artifact/install/internal/Maven30ArtifactInstallerTest.java Sun Jun 14 09:40:45 2015 @@ -1,75 +1,75 @@ -package org.apache.maven.shared.artifact.install.internal; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.util.Arrays; -import java.util.Collection; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.artifact.handler.DefaultArtifactHandler; -import org.apache.maven.project.DefaultProjectBuildingRequest; -import org.apache.maven.repository.internal.MavenRepositorySystemSession; -import org.apache.maven.shared.artifact.install.ArtifactInstaller; -import org.codehaus.plexus.PlexusTestCase; -import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager; - -public class Maven30ArtifactInstallerTest extends PlexusTestCase -{ - private final File localRepo = new File( "target/tests/local-repo" ); - - private Maven30ArtifactInstaller installer; - - @Override - public void setUp() throws Exception - { - super.setUp(); - installer = (Maven30ArtifactInstaller) super.lookup( ArtifactInstaller.class, "maven3" ); - } - - public void testInstall() throws Exception - { - DefaultProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(); - MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); - repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepo ) ); - buildingRequest.setRepositorySession( repositorySession ); - - DefaultArtifactHandler artifactHandler = new DefaultArtifactHandler(); - artifactHandler.setExtension( "EXTENSION" ); - - File artifactsDirectory = new File( "target/tests/artifacts" ); - artifactsDirectory.mkdirs(); - File tmpFile = File.createTempFile( "test-install", ".jar", artifactsDirectory ); - - DefaultArtifact artifact = new DefaultArtifact( "GROUPID", "ARTIFACTID", "VERSION", "compile", "jar", null, artifactHandler ); - artifact.setFile( tmpFile ); - DefaultArtifact artifactWithClassifier = new DefaultArtifact( "GROUPID", "ARTIFACTID", "VERSION", "compile", "jar", "CLASSIFIER", artifactHandler ); - artifactWithClassifier.setFile( tmpFile ); - - Collection<Artifact> mavenArtifacts = Arrays.<Artifact>asList( artifact, artifactWithClassifier ); - - installer.install( buildingRequest, mavenArtifacts ); - - assertTrue( new File( localRepo, "GROUPID/ARTIFACTID/VERSION/ARTIFACTID-VERSION.EXTENSION" ).exists() ); - assertTrue( new File( localRepo, "GROUPID/ARTIFACTID/VERSION/ARTIFACTID-VERSION-CLASSIFIER.EXTENSION" ).exists() ); - assertTrue( new File( localRepo, "GROUPID/ARTIFACTID/maven-metadata-local.xml" ).exists() ); //?? - } -} +package org.apache.maven.shared.artifact.install.internal; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.util.Arrays; +import java.util.Collection; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.artifact.handler.DefaultArtifactHandler; +import org.apache.maven.project.DefaultProjectBuildingRequest; +import org.apache.maven.repository.internal.MavenRepositorySystemSession; +import org.apache.maven.shared.artifact.install.ArtifactInstaller; +import org.codehaus.plexus.PlexusTestCase; +import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager; + +public class Maven30ArtifactInstallerTest extends PlexusTestCase +{ + private final File localRepo = new File( "target/tests/local-repo" ); + + private Maven30ArtifactInstaller installer; + + @Override + public void setUp() throws Exception + { + super.setUp(); + installer = (Maven30ArtifactInstaller) super.lookup( ArtifactInstaller.class, "maven3" ); + } + + public void testInstall() throws Exception + { + DefaultProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(); + MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); + repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepo ) ); + buildingRequest.setRepositorySession( repositorySession ); + + DefaultArtifactHandler artifactHandler = new DefaultArtifactHandler(); + artifactHandler.setExtension( "EXTENSION" ); + + File artifactsDirectory = new File( "target/tests/artifacts" ); + artifactsDirectory.mkdirs(); + File tmpFile = File.createTempFile( "test-install", ".jar", artifactsDirectory ); + + DefaultArtifact artifact = new DefaultArtifact( "GROUPID", "ARTIFACTID", "VERSION", "compile", "jar", null, artifactHandler ); + artifact.setFile( tmpFile ); + DefaultArtifact artifactWithClassifier = new DefaultArtifact( "GROUPID", "ARTIFACTID", "VERSION", "compile", "jar", "CLASSIFIER", artifactHandler ); + artifactWithClassifier.setFile( tmpFile ); + + Collection<Artifact> mavenArtifacts = Arrays.<Artifact>asList( artifact, artifactWithClassifier ); + + installer.install( buildingRequest, mavenArtifacts ); + + assertTrue( new File( localRepo, "GROUPID/ARTIFACTID/VERSION/ARTIFACTID-VERSION.EXTENSION" ).exists() ); + assertTrue( new File( localRepo, "GROUPID/ARTIFACTID/VERSION/ARTIFACTID-VERSION-CLASSIFIER.EXTENSION" ).exists() ); + assertTrue( new File( localRepo, "GROUPID/ARTIFACTID/maven-metadata-local.xml" ).exists() ); //?? + } +} Modified: maven/shared/trunk/maven-artifact-transfer/src/test/java/org/apache/maven/shared/artifact/repository/internal/Maven30RepositoryManagerTest.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-artifact-transfer/src/test/java/org/apache/maven/shared/artifact/repository/internal/Maven30RepositoryManagerTest.java?rev=1685372&r1=1685371&r2=1685372&view=diff ============================================================================== --- maven/shared/trunk/maven-artifact-transfer/src/test/java/org/apache/maven/shared/artifact/repository/internal/Maven30RepositoryManagerTest.java (original) +++ maven/shared/trunk/maven-artifact-transfer/src/test/java/org/apache/maven/shared/artifact/repository/internal/Maven30RepositoryManagerTest.java Sun Jun 14 09:40:45 2015 @@ -1,76 +1,76 @@ -package org.apache.maven.shared.artifact.repository.internal; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; - -import org.apache.maven.project.DefaultProjectBuildingRequest; -import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.repository.internal.MavenRepositorySystemSession; -import org.apache.maven.shared.artifact.repository.RepositoryManager; -import org.codehaus.plexus.PlexusTestCase; -import org.sonatype.aether.impl.internal.EnhancedLocalRepositoryManager; -import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager; - -public class Maven30RepositoryManagerTest extends PlexusTestCase -{ - - private final File localRepo = new File( "target/tests/local-repo" ); - - private Maven30RepositoryManager repositoryManager; - - @Override - public void setUp() throws Exception - { - super.setUp(); - repositoryManager = (Maven30RepositoryManager) super.lookup( RepositoryManager.class, "maven3" ); - } - - public void testSetLocalRepositoryBasedirSimple() throws Exception - { - DefaultProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(); - MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); - repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepo ) ); - buildingRequest.setRepositorySession( repositorySession ); - - File basedir = new File( "NEW/LOCAL/REPO" ); - - ProjectBuildingRequest newBuildingRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest, basedir ); - - assertEquals( basedir.getAbsoluteFile(), newBuildingRequest.getRepositorySession().getLocalRepository().getBasedir() ); - - } - - public void testSetLocalRepositoryBasedirEnhanced() throws Exception - { - DefaultProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(); - MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); - repositorySession.setLocalRepositoryManager( new EnhancedLocalRepositoryManager( localRepo ) ); - buildingRequest.setRepositorySession( repositorySession ); - - File basedir = new File( "NEW/LOCAL/REPO" ); - - ProjectBuildingRequest newBuildingRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest, basedir ); - - assertEquals( basedir.getAbsoluteFile(), newBuildingRequest.getRepositorySession().getLocalRepository().getBasedir() ); - - } - -} +package org.apache.maven.shared.artifact.repository.internal; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; + +import org.apache.maven.project.DefaultProjectBuildingRequest; +import org.apache.maven.project.ProjectBuildingRequest; +import org.apache.maven.repository.internal.MavenRepositorySystemSession; +import org.apache.maven.shared.artifact.repository.RepositoryManager; +import org.codehaus.plexus.PlexusTestCase; +import org.sonatype.aether.impl.internal.EnhancedLocalRepositoryManager; +import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager; + +public class Maven30RepositoryManagerTest extends PlexusTestCase +{ + + private final File localRepo = new File( "target/tests/local-repo" ); + + private Maven30RepositoryManager repositoryManager; + + @Override + public void setUp() throws Exception + { + super.setUp(); + repositoryManager = (Maven30RepositoryManager) super.lookup( RepositoryManager.class, "maven3" ); + } + + public void testSetLocalRepositoryBasedirSimple() throws Exception + { + DefaultProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(); + MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); + repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepo ) ); + buildingRequest.setRepositorySession( repositorySession ); + + File basedir = new File( "NEW/LOCAL/REPO" ); + + ProjectBuildingRequest newBuildingRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest, basedir ); + + assertEquals( basedir.getAbsoluteFile(), newBuildingRequest.getRepositorySession().getLocalRepository().getBasedir() ); + + } + + public void testSetLocalRepositoryBasedirEnhanced() throws Exception + { + DefaultProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(); + MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); + repositorySession.setLocalRepositoryManager( new EnhancedLocalRepositoryManager( localRepo ) ); + buildingRequest.setRepositorySession( repositorySession ); + + File basedir = new File( "NEW/LOCAL/REPO" ); + + ProjectBuildingRequest newBuildingRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest, basedir ); + + assertEquals( basedir.getAbsoluteFile(), newBuildingRequest.getRepositorySession().getLocalRepository().getBasedir() ); + + } + +}