http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java new file mode 100644 index 0000000..1b11cb3 --- /dev/null +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java @@ -0,0 +1,145 @@ +package org.apache.maven.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.util.Properties; + +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.artifact.DefaultArtifactType; +import org.eclipse.aether.collection.DependencyGraphTransformer; +import org.eclipse.aether.collection.DependencyManager; +import org.eclipse.aether.collection.DependencySelector; +import org.eclipse.aether.collection.DependencyTraverser; +import org.eclipse.aether.impl.ArtifactDescriptorReader; +import org.eclipse.aether.impl.DefaultServiceLocator; +import org.eclipse.aether.impl.MetadataGeneratorFactory; +import org.eclipse.aether.impl.VersionRangeResolver; +import org.eclipse.aether.impl.VersionResolver; +import org.eclipse.aether.util.artifact.DefaultArtifactTypeRegistry; +import org.eclipse.aether.util.graph.manager.ClassicDependencyManager; +import org.eclipse.aether.util.graph.selector.AndDependencySelector; +import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector; +import org.eclipse.aether.util.graph.selector.OptionalDependencySelector; +import org.eclipse.aether.util.graph.selector.ScopeDependencySelector; +import org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer; +import org.eclipse.aether.util.graph.transformer.ConflictResolver; +import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner; +import org.eclipse.aether.util.graph.transformer.JavaScopeDeriver; +import org.eclipse.aether.util.graph.transformer.JavaScopeSelector; +import org.eclipse.aether.util.graph.transformer.NearestVersionSelector; +import org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector; +import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser; +import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy; + +/** + * A utility class to assist in setting up a Maven-like repository system. <em>Note:</em> This component is meant to + * assist those clients that employ the repository system outside of an IoC container, Maven plugins should instead + * always use regular dependency injection to acquire the repository system. + * + * @author Benjamin Bentmann + */ +public final class MavenRepositorySystemUtils +{ + + private MavenRepositorySystemUtils() + { + // hide constructor + } + + /** + * Creates a new service locator that already knows about all service implementations included in this library. To + * acquire a complete repository system, clients need to add some repository connectors for remote transfers. + * + * @return The new service locator, never {@code null}. + */ + public static DefaultServiceLocator newServiceLocator() + { + DefaultServiceLocator locator = new DefaultServiceLocator(); + locator.addService( ArtifactDescriptorReader.class, DefaultArtifactDescriptorReader.class ); + locator.addService( VersionResolver.class, DefaultVersionResolver.class ); + locator.addService( VersionRangeResolver.class, DefaultVersionRangeResolver.class ); + locator.addService( MetadataGeneratorFactory.class, SnapshotMetadataGeneratorFactory.class ); + locator.addService( MetadataGeneratorFactory.class, VersionsMetadataGeneratorFactory.class ); + return locator; + } + + /** + * Creates a new Maven-like repository system session by initializing the session with values typical for + * Maven-based resolution. In more detail, this method configures settings relevant for the processing of dependency + * graphs, most other settings remain at their generic default value. Use the various setters to further configure + * the session with authentication, mirror, proxy and other information required for your environment. + * + * @return The new repository system session, never {@code null}. + */ + public static DefaultRepositorySystemSession newSession() + { + DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(); + + DependencyTraverser depTraverser = new FatArtifactTraverser(); + session.setDependencyTraverser( depTraverser ); + + DependencyManager depManager = new ClassicDependencyManager(); + session.setDependencyManager( depManager ); + + DependencySelector depFilter = + new AndDependencySelector( new ScopeDependencySelector( "test", "provided" ), + new OptionalDependencySelector(), new ExclusionDependencySelector() ); + session.setDependencySelector( depFilter ); + + DependencyGraphTransformer transformer = + new ConflictResolver( new NearestVersionSelector(), new JavaScopeSelector(), + new SimpleOptionalitySelector(), new JavaScopeDeriver() ); + new ChainedDependencyGraphTransformer( transformer, new JavaDependencyContextRefiner() ); + session.setDependencyGraphTransformer( transformer ); + + DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry(); + stereotypes.add( new DefaultArtifactType( "pom" ) ); + stereotypes.add( new DefaultArtifactType( "maven-plugin", "jar", "", "java" ) ); + stereotypes.add( new DefaultArtifactType( "jar", "jar", "", "java" ) ); + stereotypes.add( new DefaultArtifactType( "ejb", "jar", "", "java" ) ); + stereotypes.add( new DefaultArtifactType( "ejb-client", "jar", "client", "java" ) ); + stereotypes.add( new DefaultArtifactType( "test-jar", "jar", "tests", "java" ) ); + stereotypes.add( new DefaultArtifactType( "javadoc", "jar", "javadoc", "java" ) ); + stereotypes.add( new DefaultArtifactType( "java-source", "jar", "sources", "java", false, false ) ); + stereotypes.add( new DefaultArtifactType( "war", "war", "", "java", false, true ) ); + stereotypes.add( new DefaultArtifactType( "ear", "ear", "", "java", false, true ) ); + stereotypes.add( new DefaultArtifactType( "rar", "rar", "", "java", false, true ) ); + stereotypes.add( new DefaultArtifactType( "par", "par", "", "java", false, true ) ); + session.setArtifactTypeRegistry( stereotypes ); + + session.setArtifactDescriptorPolicy( new SimpleArtifactDescriptorPolicy( true, true ) ); + + final Properties systemProperties = new Properties(); + + // MNG-5670 guard against ConcurrentModificationException + // MNG-6053 guard against key without value + Properties sysProp = System.getProperties(); + synchronized ( sysProp ) + { + systemProperties.putAll( sysProp ); + } + + session.setSystemProperties( systemProperties ); + session.setConfigProperties( systemProperties ); + + return session; + } + +}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenResolverModule.java ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenResolverModule.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenResolverModule.java new file mode 100644 index 0000000..070b91c --- /dev/null +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenResolverModule.java @@ -0,0 +1,70 @@ +package org.apache.maven.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.util.Collections; +import java.util.HashSet; +import java.util.Set; +import javax.inject.Named; +import javax.inject.Singleton; +import com.google.inject.AbstractModule; +import com.google.inject.Provides; +import com.google.inject.name.Names; +import org.apache.maven.model.building.DefaultModelBuilderFactory; +import org.apache.maven.model.building.ModelBuilder; +import org.eclipse.aether.impl.ArtifactDescriptorReader; +import org.eclipse.aether.impl.MetadataGeneratorFactory; +import org.eclipse.aether.impl.VersionRangeResolver; +import org.eclipse.aether.impl.VersionResolver; +import org.eclipse.aether.impl.guice.AetherModule; + +public final class MavenResolverModule + extends AbstractModule +{ + + @Override + protected void configure() + { + install( new AetherModule() ); + bind( ArtifactDescriptorReader.class ).to( DefaultArtifactDescriptorReader.class ).in( Singleton.class ); + bind( VersionResolver.class ).to( DefaultVersionResolver.class ).in( Singleton.class ); + bind( VersionRangeResolver.class ).to( DefaultVersionRangeResolver.class ).in( Singleton.class ); + bind( MetadataGeneratorFactory.class ).annotatedWith( Names.named( "snapshot" ) ) + .to( SnapshotMetadataGeneratorFactory.class ).in( Singleton.class ); + + bind( MetadataGeneratorFactory.class ).annotatedWith( Names.named( "versions" ) ) + .to( VersionsMetadataGeneratorFactory.class ).in( Singleton.class ); + + bind( ModelBuilder.class ).toInstance( new DefaultModelBuilderFactory().newInstance() ); + } + + @Provides + @Singleton + Set<MetadataGeneratorFactory> provideMetadataGeneratorFactories( + @Named( "snapshot" ) MetadataGeneratorFactory snapshot, + @Named( "versions" ) MetadataGeneratorFactory versions ) + { + Set<MetadataGeneratorFactory> factories = new HashSet<>( 2 ); + factories.add( snapshot ); + factories.add( versions ); + return Collections.unmodifiableSet( factories ); + } + +} http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java new file mode 100644 index 0000000..e4c9a7e --- /dev/null +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java @@ -0,0 +1,100 @@ +package org.apache.maven.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 java.util.ArrayList; +import java.util.Collection; + +import org.apache.maven.artifact.repository.metadata.Metadata; +import org.eclipse.aether.artifact.Artifact; + +/** + * @author Hervé Boutemy + */ +abstract class MavenSnapshotMetadata + extends MavenMetadata +{ + static final String SNAPSHOT = "SNAPSHOT"; + + protected final Collection<Artifact> artifacts = new ArrayList<>(); + + protected final boolean legacyFormat; + + protected MavenSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat ) + { + super( metadata, file ); + this.legacyFormat = legacyFormat; + } + + protected static Metadata createRepositoryMetadata( Artifact artifact, boolean legacyFormat ) + { + Metadata metadata = new Metadata(); + if ( !legacyFormat ) + { + metadata.setModelVersion( "1.1.0" ); + } + metadata.setGroupId( artifact.getGroupId() ); + metadata.setArtifactId( artifact.getArtifactId() ); + metadata.setVersion( artifact.getBaseVersion() ); + + return metadata; + } + + public void bind( Artifact artifact ) + { + artifacts.add( artifact ); + } + + public Object getKey() + { + return getGroupId() + ':' + getArtifactId() + ':' + getVersion(); + } + + public static Object getKey( Artifact artifact ) + { + return artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getBaseVersion(); + } + + protected String getKey( String classifier, String extension ) + { + return classifier + ':' + extension; + } + + public String getGroupId() + { + return metadata.getGroupId(); + } + + public String getArtifactId() + { + return metadata.getArtifactId(); + } + + public String getVersion() + { + return metadata.getVersion(); + } + + public Nature getNature() + { + return Nature.SNAPSHOT; + } +} http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenWorkspaceReader.java ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenWorkspaceReader.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenWorkspaceReader.java new file mode 100644 index 0000000..270cf58 --- /dev/null +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenWorkspaceReader.java @@ -0,0 +1,32 @@ +package org.apache.maven.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 org.apache.maven.model.Model; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.repository.WorkspaceReader; + +public interface MavenWorkspaceReader + extends WorkspaceReader +{ + + Model findModel( Artifact artifact ); + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java new file mode 100644 index 0000000..c6ef3aa --- /dev/null +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java @@ -0,0 +1,114 @@ +package org.apache.maven.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 java.util.Map; + +import org.apache.commons.lang3.Validate; +import org.eclipse.aether.artifact.AbstractArtifact; +import org.eclipse.aether.artifact.Artifact; + +/** + * @author Benjamin Bentmann + */ +final class RelocatedArtifact + extends AbstractArtifact +{ + + private final Artifact artifact; + + private final String groupId; + + private final String artifactId; + + private final String version; + + public RelocatedArtifact( Artifact artifact, String groupId, String artifactId, String version ) + { + this.artifact = Validate.notNull( artifact, "artifact cannot be null" ); + // TODO Use StringUtils here + this.groupId = ( groupId != null && groupId.length() > 0 ) ? groupId : null; + this.artifactId = ( artifactId != null && artifactId.length() > 0 ) ? artifactId : null; + this.version = ( version != null && version.length() > 0 ) ? version : null; + } + + public String getGroupId() + { + if ( groupId != null ) + { + return groupId; + } + else + { + return artifact.getGroupId(); + } + } + + public String getArtifactId() + { + if ( artifactId != null ) + { + return artifactId; + } + else + { + return artifact.getArtifactId(); + } + } + + public String getVersion() + { + if ( version != null ) + { + return version; + } + else + { + return artifact.getVersion(); + } + } + + public String getClassifier() + { + return artifact.getClassifier(); + } + + public String getExtension() + { + return artifact.getExtension(); + } + + public File getFile() + { + return artifact.getFile(); + } + + public String getProperty( String key, String defaultValue ) + { + return artifact.getProperty( key, defaultValue ); + } + + public Map<String, String> getProperties() + { + return artifact.getProperties(); + } + +} http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java new file mode 100644 index 0000000..1e791d8 --- /dev/null +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java @@ -0,0 +1,157 @@ +package org.apache.maven.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 java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.TimeZone; + +import org.apache.maven.artifact.repository.metadata.Metadata; +import org.apache.maven.artifact.repository.metadata.Snapshot; +import org.apache.maven.artifact.repository.metadata.SnapshotVersion; +import org.apache.maven.artifact.repository.metadata.Versioning; +import org.eclipse.aether.artifact.Artifact; + +/** + * @author Benjamin Bentmann + */ +final class RemoteSnapshotMetadata + extends MavenSnapshotMetadata +{ + public static final String DEFAULT_SNAPSHOT_TIMESTAMP_FORMAT = "yyyyMMdd.HHmmss"; + + public static final TimeZone DEFAULT_SNAPSHOT_TIME_ZONE = TimeZone.getTimeZone( "Etc/UTC" ); + + private final Map<String, SnapshotVersion> versions = new LinkedHashMap<>(); + + public RemoteSnapshotMetadata( Artifact artifact, boolean legacyFormat ) + { + super( createRepositoryMetadata( artifact, legacyFormat ), null, legacyFormat ); + } + + private RemoteSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat ) + { + super( metadata, file, legacyFormat ); + } + + public MavenMetadata setFile( File file ) + { + return new RemoteSnapshotMetadata( metadata, file, legacyFormat ); + } + + public String getExpandedVersion( Artifact artifact ) + { + String key = getKey( artifact.getClassifier(), artifact.getExtension() ); + return versions.get( key ).getVersion(); + } + + @Override + protected void merge( Metadata recessive ) + { + Snapshot snapshot; + String lastUpdated; + + if ( metadata.getVersioning() == null ) + { + DateFormat utcDateFormatter = new SimpleDateFormat( DEFAULT_SNAPSHOT_TIMESTAMP_FORMAT ); + utcDateFormatter.setCalendar( new GregorianCalendar() ); + utcDateFormatter.setTimeZone( DEFAULT_SNAPSHOT_TIME_ZONE ); + + snapshot = new Snapshot(); + snapshot.setBuildNumber( getBuildNumber( recessive ) + 1 ); + snapshot.setTimestamp( utcDateFormatter.format( new Date() ) ); + + Versioning versioning = new Versioning(); + versioning.setSnapshot( snapshot ); + versioning.setLastUpdated( snapshot.getTimestamp().replace( ".", "" ) ); + lastUpdated = versioning.getLastUpdated(); + + metadata.setVersioning( versioning ); + } + else + { + snapshot = metadata.getVersioning().getSnapshot(); + lastUpdated = metadata.getVersioning().getLastUpdated(); + } + + for ( Artifact artifact : artifacts ) + { + String version = artifact.getVersion(); + + if ( version.endsWith( SNAPSHOT ) ) + { + String qualifier = snapshot.getTimestamp() + '-' + snapshot.getBuildNumber(); + version = version.substring( 0, version.length() - SNAPSHOT.length() ) + qualifier; + } + + SnapshotVersion sv = new SnapshotVersion(); + sv.setClassifier( artifact.getClassifier() ); + sv.setExtension( artifact.getExtension() ); + sv.setVersion( version ); + sv.setUpdated( lastUpdated ); + + versions.put( getKey( sv.getClassifier(), sv.getExtension() ), sv ); + } + + artifacts.clear(); + + Versioning versioning = recessive.getVersioning(); + if ( versioning != null ) + { + for ( SnapshotVersion sv : versioning.getSnapshotVersions() ) + { + String key = getKey( sv.getClassifier(), sv.getExtension() ); + if ( !versions.containsKey( key ) ) + { + versions.put( key, sv ); + } + } + } + + if ( !legacyFormat ) + { + metadata.getVersioning().setSnapshotVersions( new ArrayList<>( versions.values() ) ); + } + } + + private static int getBuildNumber( Metadata metadata ) + { + int number = 0; + + Versioning versioning = metadata.getVersioning(); + if ( versioning != null ) + { + Snapshot snapshot = versioning.getSnapshot(); + if ( snapshot != null && snapshot.getBuildNumber() > 0 ) + { + number = snapshot.getBuildNumber(); + } + } + + return number; + } + +} http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java new file mode 100644 index 0000000..8258966 --- /dev/null +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java @@ -0,0 +1,107 @@ +package org.apache.maven.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.util.Collection; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.deployment.DeployRequest; +import org.eclipse.aether.impl.MetadataGenerator; +import org.eclipse.aether.metadata.Metadata; +import org.eclipse.aether.util.ConfigUtils; + +/** + * @author Benjamin Bentmann + */ +class RemoteSnapshotMetadataGenerator + implements MetadataGenerator +{ + + private final Map<Object, RemoteSnapshotMetadata> snapshots; + + private final boolean legacyFormat; + + public RemoteSnapshotMetadataGenerator( RepositorySystemSession session, DeployRequest request ) + { + legacyFormat = ConfigUtils.getBoolean( session.getConfigProperties(), false, "maven.metadata.legacy" ); + + snapshots = new LinkedHashMap<>(); + + /* + * NOTE: This should be considered a quirk to support interop with Maven's legacy ArtifactDeployer which + * processes one artifact at a time and hence cannot associate the artifacts from the same project to use the + * same timestamp+buildno for the snapshot versions. Allowing the caller to pass in metadata from a previous + * deployment allows to re-establish the association between the artifacts of the same project. + */ + for ( Metadata metadata : request.getMetadata() ) + { + if ( metadata instanceof RemoteSnapshotMetadata ) + { + RemoteSnapshotMetadata snapshotMetadata = (RemoteSnapshotMetadata) metadata; + snapshots.put( snapshotMetadata.getKey(), snapshotMetadata ); + } + } + } + + public Collection<? extends Metadata> prepare( Collection<? extends Artifact> artifacts ) + { + for ( Artifact artifact : artifacts ) + { + if ( artifact.isSnapshot() ) + { + Object key = RemoteSnapshotMetadata.getKey( artifact ); + RemoteSnapshotMetadata snapshotMetadata = snapshots.get( key ); + if ( snapshotMetadata == null ) + { + snapshotMetadata = new RemoteSnapshotMetadata( artifact, legacyFormat ); + snapshots.put( key, snapshotMetadata ); + } + snapshotMetadata.bind( artifact ); + } + } + + return snapshots.values(); + } + + public Artifact transformArtifact( Artifact artifact ) + { + if ( artifact.isSnapshot() && artifact.getVersion().equals( artifact.getBaseVersion() ) ) + { + Object key = RemoteSnapshotMetadata.getKey( artifact ); + RemoteSnapshotMetadata snapshotMetadata = snapshots.get( key ); + if ( snapshotMetadata != null ) + { + artifact = artifact.setVersion( snapshotMetadata.getExpandedVersion( artifact ) ); + } + } + + return artifact; + } + + public Collection<? extends Metadata> finish( Collection<? extends Artifact> artifacts ) + { + return Collections.emptyList(); + } + +} http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/SnapshotMetadataGeneratorFactory.java ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/SnapshotMetadataGeneratorFactory.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/SnapshotMetadataGeneratorFactory.java new file mode 100644 index 0000000..79ffaad --- /dev/null +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/SnapshotMetadataGeneratorFactory.java @@ -0,0 +1,52 @@ +package org.apache.maven.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 org.codehaus.plexus.component.annotations.Component; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.deployment.DeployRequest; +import org.eclipse.aether.impl.MetadataGenerator; +import org.eclipse.aether.impl.MetadataGeneratorFactory; +import org.eclipse.aether.installation.InstallRequest; + +/** + * @author Benjamin Bentmann + */ +@Component( role = MetadataGeneratorFactory.class, hint = "snapshot" ) +public class SnapshotMetadataGeneratorFactory + implements MetadataGeneratorFactory +{ + + public MetadataGenerator newInstance( RepositorySystemSession session, InstallRequest request ) + { + return new LocalSnapshotMetadataGenerator( session, request ); + } + + public MetadataGenerator newInstance( RepositorySystemSession session, DeployRequest request ) + { + return new RemoteSnapshotMetadataGenerator( session, request ); + } + + public float getPriority() + { + return 10; + } + +} http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java new file mode 100644 index 0000000..f5e13be --- /dev/null +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java @@ -0,0 +1,133 @@ +package org.apache.maven.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 java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashSet; + +import org.apache.maven.artifact.repository.metadata.Metadata; +import org.apache.maven.artifact.repository.metadata.Versioning; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.ArtifactProperties; + +/** + * @author Benjamin Bentmann + */ +final class VersionsMetadata + extends MavenMetadata +{ + + private final Artifact artifact; + + public VersionsMetadata( Artifact artifact ) + { + super( createRepositoryMetadata( artifact ), null ); + this.artifact = artifact; + } + + public VersionsMetadata( Artifact artifact, File file ) + { + super( createRepositoryMetadata( artifact ), file ); + this.artifact = artifact; + } + + private static Metadata createRepositoryMetadata( Artifact artifact ) + { + Metadata metadata = new Metadata(); + metadata.setGroupId( artifact.getGroupId() ); + metadata.setArtifactId( artifact.getArtifactId() ); + + Versioning versioning = new Versioning(); + versioning.addVersion( artifact.getBaseVersion() ); + if ( !artifact.isSnapshot() ) + { + versioning.setRelease( artifact.getBaseVersion() ); + } + if ( "maven-plugin".equals( artifact.getProperty( ArtifactProperties.TYPE, "" ) ) ) + { + versioning.setLatest( artifact.getBaseVersion() ); + } + + metadata.setVersioning( versioning ); + + return metadata; + } + + @Override + protected void merge( Metadata recessive ) + { + Versioning versioning = metadata.getVersioning(); + versioning.updateTimestamp(); + + if ( recessive.getVersioning() != null ) + { + if ( versioning.getLatest() == null ) + { + versioning.setLatest( recessive.getVersioning().getLatest() ); + } + if ( versioning.getRelease() == null ) + { + versioning.setRelease( recessive.getVersioning().getRelease() ); + } + + Collection<String> versions = new LinkedHashSet<>( recessive.getVersioning().getVersions() ); + versions.addAll( versioning.getVersions() ); + versioning.setVersions( new ArrayList<>( versions ) ); + } + } + + public Object getKey() + { + return getGroupId() + ':' + getArtifactId(); + } + + public static Object getKey( Artifact artifact ) + { + return artifact.getGroupId() + ':' + artifact.getArtifactId(); + } + + public MavenMetadata setFile( File file ) + { + return new VersionsMetadata( artifact, file ); + } + + public String getGroupId() + { + return artifact.getGroupId(); + } + + public String getArtifactId() + { + return artifact.getArtifactId(); + } + + public String getVersion() + { + return ""; + } + + public Nature getNature() + { + return artifact.isSnapshot() ? Nature.RELEASE_OR_SNAPSHOT : Nature.RELEASE; + } + +} http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java new file mode 100644 index 0000000..5173001 --- /dev/null +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java @@ -0,0 +1,108 @@ +package org.apache.maven.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.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.deployment.DeployRequest; +import org.eclipse.aether.impl.MetadataGenerator; +import org.eclipse.aether.installation.InstallRequest; +import org.eclipse.aether.metadata.Metadata; + +/** + * @author Benjamin Bentmann + */ +class VersionsMetadataGenerator + implements MetadataGenerator +{ + + private Map<Object, VersionsMetadata> versions; + + private Map<Object, VersionsMetadata> processedVersions; + + public VersionsMetadataGenerator( RepositorySystemSession session, InstallRequest request ) + { + this( session, request.getMetadata() ); + } + + public VersionsMetadataGenerator( RepositorySystemSession session, DeployRequest request ) + { + this( session, request.getMetadata() ); + } + + private VersionsMetadataGenerator( RepositorySystemSession session, Collection<? extends Metadata> metadatas ) + { + versions = new LinkedHashMap<>(); + processedVersions = new LinkedHashMap<>(); + + /* + * NOTE: This should be considered a quirk to support interop with Maven's legacy ArtifactDeployer which + * processes one artifact at a time and hence cannot associate the artifacts from the same project to use the + * same version index. Allowing the caller to pass in metadata from a previous deployment allows to re-establish + * the association between the artifacts of the same project. + */ + for ( Iterator<? extends Metadata> it = metadatas.iterator(); it.hasNext(); ) + { + Metadata metadata = it.next(); + if ( metadata instanceof VersionsMetadata ) + { + it.remove(); + VersionsMetadata versionsMetadata = (VersionsMetadata) metadata; + processedVersions.put( versionsMetadata.getKey(), versionsMetadata ); + } + } + } + + public Collection<? extends Metadata> prepare( Collection<? extends Artifact> artifacts ) + { + return Collections.emptyList(); + } + + public Artifact transformArtifact( Artifact artifact ) + { + return artifact; + } + + public Collection<? extends Metadata> finish( Collection<? extends Artifact> artifacts ) + { + for ( Artifact artifact : artifacts ) + { + Object key = VersionsMetadata.getKey( artifact ); + if ( processedVersions.get( key ) == null ) + { + VersionsMetadata versionsMetadata = versions.get( key ); + if ( versionsMetadata == null ) + { + versionsMetadata = new VersionsMetadata( artifact ); + versions.put( key, versionsMetadata ); + } + } + } + + return versions.values(); + } + +} http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGeneratorFactory.java ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGeneratorFactory.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGeneratorFactory.java new file mode 100644 index 0000000..47ef360 --- /dev/null +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGeneratorFactory.java @@ -0,0 +1,52 @@ +package org.apache.maven.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 org.codehaus.plexus.component.annotations.Component; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.deployment.DeployRequest; +import org.eclipse.aether.impl.MetadataGenerator; +import org.eclipse.aether.impl.MetadataGeneratorFactory; +import org.eclipse.aether.installation.InstallRequest; + +/** + * @author Benjamin Bentmann + */ +@Component( role = MetadataGeneratorFactory.class, hint = "versions" ) +public class VersionsMetadataGeneratorFactory + implements MetadataGeneratorFactory +{ + + public MetadataGenerator newInstance( RepositorySystemSession session, InstallRequest request ) + { + return new VersionsMetadataGenerator( session, request ); + } + + public MetadataGenerator newInstance( RepositorySystemSession session, DeployRequest request ) + { + return new VersionsMetadataGenerator( session, request ); + } + + public float getPriority() + { + return 5; + } + +} http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/package-info.java ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/package-info.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/package-info.java new file mode 100644 index 0000000..7309c2b --- /dev/null +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/package-info.java @@ -0,0 +1,25 @@ +// CHECKSTYLE_OFF: RegexpHeader +/** + * <a href="https://maven.apache.org/resolver/">Maven Resolver</a> extensions for utilizing the Maven POM and Maven + * repository metadata. + */ +package org.apache.maven.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. + */ http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/site/apt/index.apt ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/site/apt/index.apt b/maven-resolver-provider/src/site/apt/index.apt new file mode 100644 index 0000000..b50ea1d --- /dev/null +++ b/maven-resolver-provider/src/site/apt/index.apt @@ -0,0 +1,33 @@ +~~ 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. + + ----- + Introduction + ----- + Hervé Boutemy + ----- + 2012-09-29 + ----- + +Maven Artifact Resolver Provider + + Maven Artifact Resolver Provider is a {{{/resolver/}Maven Artifact Resolver}} extension to support + Maven POMs and local+remote repositories. + + Main component is <<<MavenRepositorySystemUtils>>> + ({{{./apidocs/org/apache/maven/repository/internal/MavenRepositorySystemUtils.html}javadoc}}, + {{{./xref/org/apache/maven/repository/internal/MavenRepositorySystemUtils.html}source}}). http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/site/site.xml ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/site/site.xml b/maven-resolver-provider/src/site/site.xml new file mode 100644 index 0000000..3a16bf9 --- /dev/null +++ b/maven-resolver-provider/src/site/site.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +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. +--> + +<project xmlns="http://maven.apache.org/DECORATION/1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"> + <body> + <menu name="Overview"> + <item name="Introduction" href="index.html"/> + <item name="JavaDocs" href="apidocs/index.html"/> + <item name="Source Xref" href="xref/index.html"/> + <!--item name="FAQ" href="faq.html"/--> + </menu> + + <menu ref="parent"/> + <menu ref="reports"/> + </body> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java new file mode 100644 index 0000000..b81450c --- /dev/null +++ b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java @@ -0,0 +1,87 @@ +package org.apache.maven.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.net.MalformedURLException; + +import org.apache.maven.repository.internal.util.ConsoleRepositoryListener; +import org.apache.maven.repository.internal.util.ConsoleTransferListener; +import org.codehaus.plexus.ContainerConfiguration; +import org.codehaus.plexus.PlexusConstants; +import org.codehaus.plexus.PlexusTestCase; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.RemoteRepository; + +public abstract class AbstractRepositoryTestCase + extends PlexusTestCase +{ + protected RepositorySystem system; + + protected RepositorySystemSession session; + + @Override + protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) + { + super.customizeContainerConfiguration( containerConfiguration ); + containerConfiguration.setAutoWiring( true ); + containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); + } + + @Override + protected void setUp() + throws Exception + { + super.setUp(); + system = lookup( RepositorySystem.class ); + session = newMavenRepositorySystemSession( system ); + } + + @Override + protected void tearDown() + throws Exception + { + session = null; + system = null; + super.tearDown(); + } + + public static RepositorySystemSession newMavenRepositorySystemSession( RepositorySystem system ) + { + DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); + + LocalRepository localRepo = new LocalRepository( "target/local-repo" ); + session.setLocalRepositoryManager( system.newLocalRepositoryManager( session, localRepo ) ); + + session.setTransferListener( new ConsoleTransferListener() ); + session.setRepositoryListener( new ConsoleRepositoryListener() ); + + return session; + } + + public static RemoteRepository newTestRepository() + throws MalformedURLException + { + return new RemoteRepository.Builder( "repo", "default", + getTestFile( "target/test-classes/repo" ).toURI().toURL().toString() ).build(); + } +} http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReaderTest.java ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReaderTest.java b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReaderTest.java new file mode 100644 index 0000000..e873138 --- /dev/null +++ b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReaderTest.java @@ -0,0 +1,77 @@ +package org.apache.maven.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 static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +import org.eclipse.aether.RepositoryEvent; +import org.eclipse.aether.RepositoryEvent.EventType; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.impl.ArtifactDescriptorReader; +import org.eclipse.aether.impl.RepositoryEventDispatcher; +import org.eclipse.aether.resolution.ArtifactDescriptorRequest; +import org.mockito.ArgumentCaptor; + +public class DefaultArtifactDescriptorReaderTest + extends AbstractRepositoryTestCase +{ + + public void testMng5459() + throws Exception + { + // prepare + DefaultArtifactDescriptorReader reader = (DefaultArtifactDescriptorReader) lookup( ArtifactDescriptorReader.class ); + + RepositoryEventDispatcher eventDispatcher = mock( RepositoryEventDispatcher.class ); + + ArgumentCaptor<RepositoryEvent> event = ArgumentCaptor.forClass( RepositoryEvent.class ); + + reader.setRepositoryEventDispatcher( eventDispatcher ); + + ArtifactDescriptorRequest request = new ArtifactDescriptorRequest(); + + request.addRepository( newTestRepository() ); + + request.setArtifact( new DefaultArtifact( "org.apache.maven.its", "dep-mng5459", "jar", "0.4.0-SNAPSHOT" ) ); + + // execute + reader.readArtifactDescriptor( session, request ); + + // verify + verify( eventDispatcher ).dispatch( event.capture() ); + + boolean missingArtifactDescriptor = false; + + for( RepositoryEvent evt : event.getAllValues() ) + { + if ( EventType.ARTIFACT_DESCRIPTOR_MISSING.equals( evt.getType() ) ) + { + assertEquals( "Could not find artifact org.apache.maven.its:dep-mng5459:pom:0.4.0-20130404.090532-2 in repo (" + newTestRepository().getUrl() + ")", evt.getException().getMessage() ); + missingArtifactDescriptor = true; + } + } + + if( !missingArtifactDescriptor ) + { + fail( "Expected missing artifact descriptor for org.apache.maven.its:dep-mng5459:pom:0.4.0-20130404.090532-2" ); + } + } +} http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/DefaultVersionResolverTest.java ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/DefaultVersionResolverTest.java b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/DefaultVersionResolverTest.java new file mode 100644 index 0000000..90dd6a4 --- /dev/null +++ b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/DefaultVersionResolverTest.java @@ -0,0 +1,96 @@ +package org.apache.maven.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 org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.impl.VersionResolver; +import org.eclipse.aether.resolution.VersionRequest; +import org.eclipse.aether.resolution.VersionResult; +import org.eclipse.aether.artifact.DefaultArtifact; + +public class DefaultVersionResolverTest + extends AbstractRepositoryTestCase +{ + private DefaultVersionResolver versionResolver; + + @Override + protected void setUp() + throws Exception + { + super.setUp(); + // be sure we're testing the right class, i.e. DefaultVersionResolver.class + versionResolver = (DefaultVersionResolver) lookup( VersionResolver.class, "default" ); + } + + @Override + protected void tearDown() + throws Exception + { + versionResolver = null; + super.tearDown(); + } + + public void testResolveSeparateInstalledClassifiedNonUniqueVersionedArtifacts() + throws Exception + { + VersionRequest requestB = new VersionRequest(); + requestB.addRepository( newTestRepository() ); + Artifact artifactB = + new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierB", "jar", "07.20.3-SNAPSHOT" ); + requestB.setArtifact( artifactB ); + + VersionResult resultB = versionResolver.resolveVersion( session, requestB ); + assertEquals( "07.20.3-20120809.112920-97", resultB.getVersion() ); + + VersionRequest requestA = new VersionRequest(); + requestA.addRepository( newTestRepository() ); + + Artifact artifactA = + new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierA", "jar", "07.20.3-SNAPSHOT" ); + requestA.setArtifact( artifactA ); + + VersionResult resultA = versionResolver.resolveVersion( session, requestA ); + assertEquals( "07.20.3-20120809.112124-88", resultA.getVersion() ); + } + + public void testResolveSeparateInstalledClassifiedNonVersionedArtifacts() + throws Exception + { + VersionRequest requestA = new VersionRequest(); + requestA.addRepository( newTestRepository() ); + String versionA = "07.20.3-20120809.112124-88"; + Artifact artifactA = + new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierA", "jar", versionA ); + requestA.setArtifact( artifactA ); + + VersionResult resultA = versionResolver.resolveVersion( session, requestA ); + assertEquals( versionA, resultA.getVersion() ); + + VersionRequest requestB = new VersionRequest(); + requestB.addRepository( newTestRepository() ); + String versionB = "07.20.3-20120809.112920-97"; + Artifact artifactB = + new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierB", "jar", versionB ); + requestB.setArtifact( artifactB ); + + VersionResult resultB = versionResolver.resolveVersion( session, requestB ); + assertEquals( versionB, resultB.getVersion() ); + } +} http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/MavenRepositorySystemUtilsTest.java ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/MavenRepositorySystemUtilsTest.java b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/MavenRepositorySystemUtilsTest.java new file mode 100644 index 0000000..768835a --- /dev/null +++ b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/MavenRepositorySystemUtilsTest.java @@ -0,0 +1,45 @@ +package org.apache.maven.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 org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.impl.MetadataGeneratorFactory; +import org.eclipse.aether.spi.locator.ServiceLocator; + +import junit.framework.TestCase; + +public class MavenRepositorySystemUtilsTest + extends TestCase +{ + + public void testGetRepositorySystem() + { + ServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); + RepositorySystem repoSys = locator.getService( RepositorySystem.class ); + assertNotNull( repoSys ); + } + + public void testGetMetadataGeneratorFactories() + { + ServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); + assertEquals( 2, locator.getServices( MetadataGeneratorFactory.class ).size() ); + } + +} http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataTest.java ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataTest.java b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataTest.java new file mode 100644 index 0000000..278231f --- /dev/null +++ b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataTest.java @@ -0,0 +1,82 @@ +package org.apache.maven.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 static org.junit.Assert.assertTrue; + +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.HashSet; +import java.util.Locale; +import java.util.Set; + +import org.apache.maven.artifact.repository.metadata.Metadata; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class RemoteSnapshotMetadataTest +{ + private Locale defaultLocale; + + @Before + public void setLocaleToUseBuddhistCalendar() + { + defaultLocale = Locale.getDefault(); + Locale.setDefault( new Locale( "th", "TH" ) ); + } + + @After + public void restoreLocale() + { + Locale.setDefault( defaultLocale ); + } + + static String gregorianDate() + { + SimpleDateFormat df = new SimpleDateFormat( "yyyyMMdd" ); + df.setCalendar( new GregorianCalendar() ); + df.setTimeZone( RemoteSnapshotMetadata.DEFAULT_SNAPSHOT_TIME_ZONE ); + return df.format( new Date() ); + } + + @Test + public void gregorianCalendarIsUsed() + { + String dateBefore = gregorianDate(); + + RemoteSnapshotMetadata metadata = new RemoteSnapshotMetadata( + new DefaultArtifact( "a:b:1-SNAPSHOT" ), false); + metadata.merge( new Metadata() ); + + String dateAfter = gregorianDate(); + + String ts = metadata.metadata.getVersioning().getSnapshot().getTimestamp(); + String datePart = ts.replaceAll( "\\..*", "" ); + + /* Allow for this test running across midnight */ + Set<String> expected = new HashSet<String>( Arrays.asList( dateBefore, dateAfter ) ); + assertTrue( "Expected " + datePart + " to be in " + expected, + expected.contains( datePart ) ); + } +} http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java new file mode 100644 index 0000000..db77a44 --- /dev/null +++ b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java @@ -0,0 +1,220 @@ +package org.apache.maven.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.util.Arrays; +import java.util.List; + +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.collection.CollectRequest; +import org.eclipse.aether.collection.CollectResult; +import org.eclipse.aether.graph.Dependency; +import org.eclipse.aether.graph.DependencyNode; +import org.eclipse.aether.resolution.ArtifactDescriptorRequest; +import org.eclipse.aether.resolution.ArtifactDescriptorResult; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResult; +import org.eclipse.aether.artifact.DefaultArtifact; + +public class RepositorySystemTest + extends AbstractRepositoryTestCase +{ + public void testResolveVersionRange() + throws Exception + { + //VersionRangeResult resolveVersionRange( RepositorySystemSession session, VersionRangeRequest request ) + // throws VersionRangeResolutionException; + + } + + public void testResolveVersion() + throws Exception + { + //VersionResult resolveVersion( RepositorySystemSession session, VersionRequest request ) + // throws VersionResolutionException; + } + + public void testReadArtifactDescriptor() + throws Exception + { + Artifact artifact = new DefaultArtifact( "ut.simple:artifact:extension:classifier:1.0" ); + + ArtifactDescriptorRequest request = new ArtifactDescriptorRequest(); + request.setArtifact( artifact ); + request.addRepository( newTestRepository() ); + + ArtifactDescriptorResult result = system.readArtifactDescriptor( session, request ); + + List<Dependency> deps = result.getDependencies(); + assertEquals( 2, deps.size() ); + checkUtSimpleArtifactDependencies( deps.get( 0 ), deps.get( 1 ) ); + } + + /** + * check ut.simple:artifact:1.0 dependencies + */ + private void checkUtSimpleArtifactDependencies( Dependency dep1, Dependency dep2 ) + { + assertEquals( "compile", dep1.getScope() ); + assertFalse( dep1.isOptional() ); + assertEquals( 0, dep1.getExclusions().size() ); + Artifact depArtifact = dep1.getArtifact(); + assertEquals( "ut.simple", depArtifact.getGroupId() ); + assertEquals( "dependency", depArtifact.getArtifactId() ); + assertEquals( "1.0", depArtifact.getVersion() ); + assertEquals( "1.0", depArtifact.getBaseVersion() ); + assertNull( depArtifact.getFile() ); + assertFalse( depArtifact.isSnapshot() ); + assertEquals( "", depArtifact.getClassifier() ); + assertEquals( "jar", depArtifact.getExtension() ); + assertEquals( "java", depArtifact.getProperty( "language", null ) ); + assertEquals( "jar", depArtifact.getProperty( "type", null ) ); + assertEquals( "true", depArtifact.getProperty( "constitutesBuildPath", null ) ); + assertEquals( "false", depArtifact.getProperty( "includesDependencies", null ) ); + assertEquals( 4, depArtifact.getProperties().size() ); + + assertEquals( "compile", dep2.getScope() ); + assertFalse( dep2.isOptional() ); + assertEquals( 0, dep2.getExclusions().size() ); + depArtifact = dep2.getArtifact(); + assertEquals( "ut.simple", depArtifact.getGroupId() ); + assertEquals( "dependency", depArtifact.getArtifactId() ); + assertEquals( "1.0", depArtifact.getVersion() ); + assertEquals( "1.0", depArtifact.getBaseVersion() ); + assertNull( depArtifact.getFile() ); + assertFalse( depArtifact.isSnapshot() ); + assertEquals( "sources", depArtifact.getClassifier() ); + assertEquals( "jar", depArtifact.getExtension() ); + assertEquals( "java", depArtifact.getProperty( "language", null ) ); + assertEquals( "jar", depArtifact.getProperty( "type", null ) ); // shouldn't it be java-sources given the classifier? + assertEquals( "true", depArtifact.getProperty( "constitutesBuildPath", null ) ); // shouldn't it be false given the classifier? + assertEquals( "false", depArtifact.getProperty( "includesDependencies", null ) ); + assertEquals( 4, depArtifact.getProperties().size() ); + } + + public void testCollectDependencies() + throws Exception + { + Artifact artifact = new DefaultArtifact( "ut.simple:artifact:extension:classifier:1.0" ); + // notice: extension and classifier not really used in this test... + + CollectRequest collectRequest = new CollectRequest(); + collectRequest.setRoot( new Dependency( artifact, null ) ); + collectRequest.addRepository( newTestRepository() ); + + CollectResult collectResult = system.collectDependencies( session, collectRequest ); + + List<DependencyNode> nodes = collectResult.getRoot().getChildren(); + assertEquals( 2, nodes.size() ); + checkUtSimpleArtifactDependencies( nodes.get( 0 ).getDependency(), nodes.get( 1 ).getDependency() ); + } + + public void testResolveArtifact() + throws Exception + { + Artifact artifact = new DefaultArtifact( "ut.simple:artifact:1.0" ); + + ArtifactRequest artifactRequest = new ArtifactRequest(); + artifactRequest.setArtifact( artifact ); + artifactRequest.addRepository( newTestRepository() ); + + ArtifactResult artifactResult = system.resolveArtifact( session, artifactRequest ); + checkArtifactResult( artifactResult, "artifact-1.0.jar" ); + + artifact = new DefaultArtifact( "ut.simple:artifact:zip:1.0" ); + artifactRequest.setArtifact( artifact ); + artifactResult = system.resolveArtifact( session, artifactRequest ); + checkArtifactResult( artifactResult, "artifact-1.0.zip" ); + + artifact = new DefaultArtifact( "ut.simple:artifact:zip:classifier:1.0" ); + artifactRequest.setArtifact( artifact ); + artifactResult = system.resolveArtifact( session, artifactRequest ); + checkArtifactResult( artifactResult, "artifact-1.0-classifier.zip" ); + } + + private void checkArtifactResult( ArtifactResult result, String filename ) + { + assertFalse( result.isMissing() ); + assertTrue( result.isResolved() ); + Artifact artifact = result.getArtifact(); + assertNotNull( artifact.getFile() ); + assertEquals( filename, artifact.getFile().getName() ); + } + + public void testResolveArtifacts() + throws Exception + { + ArtifactRequest req1 = new ArtifactRequest(); + req1.setArtifact( new DefaultArtifact( "ut.simple:artifact:1.0" ) ); + req1.addRepository( newTestRepository() ); + + ArtifactRequest req2 = new ArtifactRequest(); + req2.setArtifact( new DefaultArtifact( "ut.simple:artifact:zip:1.0" ) ); + req2.addRepository( newTestRepository() ); + + ArtifactRequest req3 = new ArtifactRequest(); + req3.setArtifact( new DefaultArtifact( "ut.simple:artifact:zip:classifier:1.0" ) ); + req3.addRepository( newTestRepository() ); + + List<ArtifactRequest> requests = Arrays.asList( req1, req2, req3 ); + + List<ArtifactResult> results = system.resolveArtifacts( session, requests ); + + assertEquals( 3, results.size() ); + checkArtifactResult( results.get( 0 ), "artifact-1.0.jar" ); + checkArtifactResult( results.get( 1 ), "artifact-1.0.zip" ); + checkArtifactResult( results.get( 2 ), "artifact-1.0-classifier.zip" ); + } + + public void testResolveMetadata() + throws Exception + { + //List<MetadataResult> resolveMetadata( RepositorySystemSession session, + // Collection<? extends MetadataRequest> requests ); + } + + public void testInstall() + throws Exception + { + //InstallResult install( RepositorySystemSession session, InstallRequest request ) + // throws InstallationException; + // release, snapshot unique ou non unique, attachement + } + + public void testDeploy() + throws Exception + { + //DeployResult deploy( RepositorySystemSession session, DeployRequest request ) + // throws DeploymentException; + } + + public void testNewLocalRepositoryManager() + throws Exception + { + //LocalRepositoryManager newLocalRepositoryManager( LocalRepository localRepository ); + } + + public void testNewSyncContext() + throws Exception + { + //SyncContext newSyncContext( RepositorySystemSession session, boolean shared ); + } + +} http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleRepositoryListener.java ---------------------------------------------------------------------- diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleRepositoryListener.java b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleRepositoryListener.java new file mode 100644 index 0000000..2879a9f --- /dev/null +++ b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleRepositoryListener.java @@ -0,0 +1,132 @@ +package org.apache.maven.repository.internal.util; + +/* + * 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.PrintStream; + +import org.eclipse.aether.AbstractRepositoryListener; +import org.eclipse.aether.RepositoryEvent; + +public class ConsoleRepositoryListener + extends AbstractRepositoryListener +{ + + private PrintStream out; + + public ConsoleRepositoryListener() + { + this( null ); + } + + public ConsoleRepositoryListener( PrintStream out ) + { + this.out = ( out != null ) ? out : System.out; + } + + public void artifactDeployed( RepositoryEvent event ) + { + println( "artifactDeployed", event.getArtifact() + " to " + event.getRepository() ); + } + + public void artifactDeploying( RepositoryEvent event ) + { + println( "artifactDeploying", event.getArtifact() + " to " + event.getRepository() ); + } + + public void artifactDescriptorInvalid( RepositoryEvent event ) + { + println( "artifactDescriptorInvalid", "for " + event.getArtifact() + ": " + event.getException().getMessage() ); + } + + public void artifactDescriptorMissing( RepositoryEvent event ) + { + println( "artifactDescriptorMissing", "for " + event.getArtifact() ); + } + + public void artifactInstalled( RepositoryEvent event ) + { + println( "artifactInstalled", event.getArtifact() + " to " + event.getFile() ); + } + + public void artifactInstalling( RepositoryEvent event ) + { + println( "artifactInstalling", event.getArtifact() + " to " + event.getFile() ); + } + + public void artifactResolved( RepositoryEvent event ) + { + println( "artifactResolved", event.getArtifact() + " from " + event.getRepository() ); + } + + public void artifactDownloading( RepositoryEvent event ) + { + println( "artifactDownloading", event.getArtifact() + " from " + event.getRepository() ); + } + + public void artifactDownloaded( RepositoryEvent event ) + { + println( "artifactDownloaded", event.getArtifact() + " from " + event.getRepository() ); + } + + public void artifactResolving( RepositoryEvent event ) + { + println( "artifactResolving", event.getArtifact().toString() ); + } + + public void metadataDeployed( RepositoryEvent event ) + { + println( "metadataDeployed", event.getMetadata() + " to " + event.getRepository() ); + } + + public void metadataDeploying( RepositoryEvent event ) + { + println( "metadataDeploying", event.getMetadata() + " to " + event.getRepository() ); + } + + public void metadataInstalled( RepositoryEvent event ) + { + println( "metadataInstalled", event.getMetadata() + " to " + event.getFile() ); + } + + public void metadataInstalling( RepositoryEvent event ) + { + println( "metadataInstalling", event.getMetadata() + " to " + event.getFile() ); + } + + public void metadataInvalid( RepositoryEvent event ) + { + println( "metadataInvalid", event.getMetadata().toString() ); + } + + public void metadataResolved( RepositoryEvent event ) + { + println( "metadataResolved", event.getMetadata() + " from " + event.getRepository() ); + } + + public void metadataResolving( RepositoryEvent event ) + { + println( "metadataResolving", event.getMetadata() + " from " + event.getRepository() ); + } + + private void println( String event, String message ) + { + out.println( "Aether Repository - " + event + ": " + message ); + } +}