diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index 40917d534322..8fe74ccd5a3f 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -47,10 +47,6 @@ under the License. org.apache.maven maven-core - - org.apache.maven - maven-compat - org.eclipse.sisu org.eclipse.sisu.plexus diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactNotFoundException.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactNotFoundException.java index 76f7b584c5d0..7157748bf2e4 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactNotFoundException.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactNotFoundException.java @@ -45,7 +45,7 @@ public ArtifactNotFoundException( String message, Artifact artifact ) artifact.getClassifier(), null, artifact.getDownloadUrl(), artifact.getDependencyTrail() ); } - protected ArtifactNotFoundException( String message, Artifact artifact, + public ArtifactNotFoundException( String message, Artifact artifact, List remoteRepositories, Throwable cause ) { this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml deleted file mode 100644 index ed909475b0a4..000000000000 --- a/maven-compat/pom.xml +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.maven - maven - 4.0.0-alpha-1-SNAPSHOT - - - maven-compat - - Maven Compat - Maven2 classes maintained as compatibility layer. - - - - org.apache.maven - maven-model - - - org.apache.maven - maven-model-builder - - - org.apache.maven - maven-settings - - - org.apache.maven - maven-settings-builder - - - org.apache.maven - maven-artifact - - - org.apache.maven - maven-core - - - org.apache.maven - maven-resolver-provider - - - org.apache.maven - maven-repository-metadata - - - org.apache.maven.resolver - maven-resolver-api - - - org.apache.maven.resolver - maven-resolver-util - - - org.apache.maven.resolver - maven-resolver-impl - - - javax.inject - javax.inject - - - org.codehaus.plexus - plexus-utils - - - org.codehaus.plexus - plexus-interpolation - - - org.eclipse.sisu - org.eclipse.sisu.plexus - - - org.codehaus.plexus - plexus-component-annotations - - - org.apache.maven.wagon - wagon-provider-api - - - - org.codehaus.plexus - plexus-testing - test - - - org.apache.maven.wagon - wagon-file - test - - - org.apache.maven.resolver - maven-resolver-connector-basic - test - - - org.apache.maven.resolver - maven-resolver-transport-wagon - test - - - - - - - org.codehaus.plexus - plexus-component-metadata - - - org.codehaus.modello - modello-maven-plugin - - 1.0.0 - - src/main/mdo/profiles.mdo - src/main/mdo/paramdoc.mdo - - - - - - - diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/ArtifactScopeEnum.java b/maven-compat/src/main/java/org/apache/maven/artifact/ArtifactScopeEnum.java deleted file mode 100644 index df9b9107c6b1..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/ArtifactScopeEnum.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.apache.maven.artifact; - -/* - * 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. - */ - -/** - * Type safe reincarnation of Artifact scope. Also supplies the {@code DEFAULT_SCOPE} as well - * as convenience method to deal with scope relationships. - * - * @author Oleg Gusakov - * - */ - -public enum ArtifactScopeEnum -{ - compile( 1 ), test( 2 ), runtime( 3 ), provided( 4 ), system( 5 ), runtime_plus_system( 6 ); - - public static final ArtifactScopeEnum DEFAULT_SCOPE = compile; - - private int id; - - // Constructor - ArtifactScopeEnum( int id ) - { - this.id = id; - } - - int getId() - { - return id; - } - - - /** - * Helper method to simplify null processing - */ - public static ArtifactScopeEnum checkScope( ArtifactScopeEnum scope ) - { - return scope == null ? DEFAULT_SCOPE : scope; - } - - /** - * - * @return unsafe String representation of this scope. - */ - public String getScope() - { - if ( id == 1 ) - { - return Artifact.SCOPE_COMPILE; - } - else if ( id == 2 ) - { - return Artifact.SCOPE_TEST; - - } - else if ( id == 3 ) - { - return Artifact.SCOPE_RUNTIME; - - } - else if ( id == 4 ) - { - return Artifact.SCOPE_PROVIDED; - } - else if ( id == 5 ) - { - return Artifact.SCOPE_SYSTEM; - } - else - { - return Artifact.SCOPE_RUNTIME_PLUS_SYSTEM; - } - } - - private static final ArtifactScopeEnum [][][] COMPLIANCY_SETS = { - { { compile }, { compile, provided, system } } - , { { test }, { compile, test, provided, system } } - , { { runtime }, { compile, runtime, system } } - , { { provided }, { compile, test, provided } } - }; - - /** - * scope relationship function. Used by the graph conflict resolution policies - * - * @param scope - * @return true is supplied scope is an inclusive sub-scope of current one. - */ - public boolean encloses( ArtifactScopeEnum scope ) - { - final ArtifactScopeEnum s = checkScope( scope ); - - // system scope is historic only - and simple - if ( id == system.id ) - { - return scope.id == system.id; - } - - for ( ArtifactScopeEnum[][] set : COMPLIANCY_SETS ) - { - if ( id == set[0][0].id ) - { - for ( ArtifactScopeEnum ase : set[1] ) - { - if ( s.id == ase.id ) - { - return true; - } - } - break; - } - } - return false; - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/ArtifactStatus.java b/maven-compat/src/main/java/org/apache/maven/artifact/ArtifactStatus.java deleted file mode 100644 index 1705d6654ac6..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/ArtifactStatus.java +++ /dev/null @@ -1,124 +0,0 @@ -package org.apache.maven.artifact; - -/* - * 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.HashMap; -import java.util.Map; - -/** - * Type safe enumeration for the artifact status field. - * - * @author Brett Porter - */ -public final class ArtifactStatus - implements Comparable -{ - /** - * No trust - no information about status. - */ - public static final ArtifactStatus NONE = new ArtifactStatus( "none", 0 ); - - /** - * No trust - information was generated with defaults. - */ - public static final ArtifactStatus GENERATED = new ArtifactStatus( "generated", 1 ); - - /** - * Low trust - was converted from the Maven 1.x repository. - */ - public static final ArtifactStatus CONVERTED = new ArtifactStatus( "converted", 2 ); - - /** - * Moderate trust - it was deployed directly from a partner. - */ - public static final ArtifactStatus PARTNER = new ArtifactStatus( "partner", 3 ); - - /** - * Moderate trust - it was deployed directly by a user. - */ - public static final ArtifactStatus DEPLOYED = new ArtifactStatus( "deployed", 4 ); - - /** - * Trusted, as it has had its data verified by hand. - */ - public static final ArtifactStatus VERIFIED = new ArtifactStatus( "verified", 5 ); - - private final int rank; - - private final String key; - - private static Map map; - - private ArtifactStatus( String key, int rank ) - { - this.rank = rank; - this.key = key; - - if ( map == null ) - { - map = new HashMap<>(); - } - map.put( key, this ); - } - - public static ArtifactStatus valueOf( String status ) - { - ArtifactStatus retVal = null; - - if ( status != null ) - { - retVal = map.get( status ); - } - - return retVal != null ? retVal : NONE; - } - - public boolean equals( Object o ) - { - if ( this == o ) - { - return true; - } - if ( o == null || getClass() != o.getClass() ) - { - return false; - } - - final ArtifactStatus that = (ArtifactStatus) o; - - return rank == that.rank; - - } - - public int hashCode() - { - return rank; - } - - public String toString() - { - return key; - } - - public int compareTo( ArtifactStatus s ) - { - return rank - s.rank; - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/UnknownRepositoryLayoutException.java b/maven-compat/src/main/java/org/apache/maven/artifact/UnknownRepositoryLayoutException.java deleted file mode 100644 index e23bea9a8925..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/UnknownRepositoryLayoutException.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.apache.maven.artifact; - -/* - * 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.repository.exception.ComponentLookupException; - -/** - * Exception which is meant to occur when a layout specified for a particular - * repository doesn't have a corresponding {@link org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout} - * component in the current container. - * - * @author jdcasey - */ -public class UnknownRepositoryLayoutException - extends InvalidRepositoryException -{ - - private final String layoutId; - - public UnknownRepositoryLayoutException( String repositoryId, String layoutId ) - { - super( "Cannot find ArtifactRepositoryLayout instance for: " + layoutId, repositoryId ); - this.layoutId = layoutId; - } - - public UnknownRepositoryLayoutException( String repositoryId, String layoutId, ComponentLookupException e ) - { - super( "Cannot find ArtifactRepositoryLayout instance for: " + layoutId, repositoryId, e ); - this.layoutId = layoutId; - } - - public String getLayoutId() - { - return layoutId; - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/deployer/ArtifactDeployer.java b/maven-compat/src/main/java/org/apache/maven/artifact/deployer/ArtifactDeployer.java deleted file mode 100644 index bf1520695864..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/deployer/ArtifactDeployer.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.apache.maven.artifact.deployer; - -/* - * 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.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; - -/** - * ArtifactDeployer - */ -public interface ArtifactDeployer -{ - String ROLE = ArtifactDeployer.class.getName(); - - /** - * Deploy an artifact from a particular directory. The artifact handler is used to determine the - * filename of the source file. - * - * @param basedir the directory where the artifact is stored - * @param finalName the name of the artifact without extension - * @param artifact the artifact definition - * @param deploymentRepository the repository to deploy to - * @param localRepository the local repository to install into - * @throws ArtifactDeploymentException if an error occurred deploying the artifact - * @deprecated to be removed before 2.0 after the install/deploy plugins use the alternate - * method - */ - @Deprecated - void deploy( String basedir, String finalName, Artifact artifact, ArtifactRepository deploymentRepository, - ArtifactRepository localRepository ) - throws ArtifactDeploymentException; - - /** - * Deploy an artifact from a particular file. - * - * @param source the file to deploy - * @param artifact the artifact definition - * @param deploymentRepository the repository to deploy to - * @param localRepository the local repository to install into - * @throws ArtifactDeploymentException if an error occurred deploying the artifact - */ - void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository, - ArtifactRepository localRepository ) - throws ArtifactDeploymentException; -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/deployer/ArtifactDeploymentException.java b/maven-compat/src/main/java/org/apache/maven/artifact/deployer/ArtifactDeploymentException.java deleted file mode 100644 index 6e44ed3c4507..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/deployer/ArtifactDeploymentException.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.apache.maven.artifact.deployer; - -/* - * 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. - */ - -/** - * @author Jason van Zyl - */ -public class ArtifactDeploymentException - extends Exception -{ - public ArtifactDeploymentException( String message ) - { - super( message ); - } - - public ArtifactDeploymentException( Throwable cause ) - { - super( cause ); - } - - public ArtifactDeploymentException( String message, - Throwable cause ) - { - super( message, cause ); - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java b/maven-compat/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java deleted file mode 100644 index 87d9c46df2df..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java +++ /dev/null @@ -1,164 +0,0 @@ -package org.apache.maven.artifact.deployer; - -/* - * 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 java.util.concurrent.ConcurrentHashMap; - -import org.apache.maven.RepositoryUtils; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadata; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.DefaultArtifactRepository; -import org.apache.maven.artifact.repository.LegacyLocalRepositoryManager; -import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; -import org.apache.maven.artifact.repository.metadata.MetadataBridge; -import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; -import org.apache.maven.plugin.LegacySupport; -import org.apache.maven.project.artifact.ProjectArtifactMetadata; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.RequestTrace; -import org.eclipse.aether.deployment.DeployRequest; -import org.eclipse.aether.deployment.DeployResult; -import org.eclipse.aether.deployment.DeploymentException; -import org.eclipse.aether.metadata.MergeableMetadata; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.util.artifact.SubArtifact; - -/** - * DefaultArtifactDeployer - */ -@Component( role = ArtifactDeployer.class, instantiationStrategy = "per-lookup" ) -public class DefaultArtifactDeployer - extends AbstractLogEnabled - implements ArtifactDeployer -{ - - @Requirement - private RepositorySystem repoSystem; - - @Requirement - private LegacySupport legacySupport; - - private Map relatedMetadata = new ConcurrentHashMap<>(); - - /** - * @deprecated we want to use the artifact method only, and ensure artifact.file is set - * correctly. - */ - @Deprecated - public void deploy( String basedir, String finalName, Artifact artifact, ArtifactRepository deploymentRepository, - ArtifactRepository localRepository ) - throws ArtifactDeploymentException - { - String extension = artifact.getArtifactHandler().getExtension(); - File source = new File( basedir, finalName + "." + extension ); - deploy( source, artifact, deploymentRepository, localRepository ); - } - - public void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository, - ArtifactRepository localRepository ) - throws ArtifactDeploymentException - { - RepositorySystemSession session = - LegacyLocalRepositoryManager.overlay( localRepository, legacySupport.getRepositorySession(), repoSystem ); - - DeployRequest request = new DeployRequest(); - - request.setTrace( RequestTrace.newChild( null, legacySupport.getSession().getCurrentProject() ) ); - - org.eclipse.aether.artifact.Artifact mainArtifact = RepositoryUtils.toArtifact( artifact ); - mainArtifact = mainArtifact.setFile( source ); - request.addArtifact( mainArtifact ); - - String versionKey = artifact.getGroupId() + ':' + artifact.getArtifactId(); - String snapshotKey = null; - if ( artifact.isSnapshot() ) - { - snapshotKey = versionKey + ':' + artifact.getBaseVersion(); - request.addMetadata( relatedMetadata.get( snapshotKey ) ); - } - request.addMetadata( relatedMetadata.get( versionKey ) ); - - for ( ArtifactMetadata metadata : artifact.getMetadataList() ) - { - if ( metadata instanceof ProjectArtifactMetadata ) - { - org.eclipse.aether.artifact.Artifact pomArtifact = new SubArtifact( mainArtifact, "", "pom" ); - pomArtifact = pomArtifact.setFile( ( (ProjectArtifactMetadata) metadata ).getFile() ); - request.addArtifact( pomArtifact ); - } - else if ( metadata instanceof SnapshotArtifactRepositoryMetadata - || metadata instanceof ArtifactRepositoryMetadata ) - { - // eaten, handled by repo system - } - else - { - request.addMetadata( new MetadataBridge( metadata ) ); - } - } - - RemoteRepository remoteRepo = RepositoryUtils.toRepo( deploymentRepository ); - /* - * NOTE: This provides backward-compat with maven-deploy-plugin:2.4 which bypasses the repository factory when - * using an alternative deployment location. - */ - if ( deploymentRepository instanceof DefaultArtifactRepository - && deploymentRepository.getAuthentication() == null ) - { - RemoteRepository.Builder builder = new RemoteRepository.Builder( remoteRepo ); - builder.setAuthentication( session.getAuthenticationSelector().getAuthentication( remoteRepo ) ); - builder.setProxy( session.getProxySelector().getProxy( remoteRepo ) ); - remoteRepo = builder.build(); - } - request.setRepository( remoteRepo ); - - DeployResult result; - try - { - result = repoSystem.deploy( session, request ); - } - catch ( DeploymentException e ) - { - throw new ArtifactDeploymentException( e.getMessage(), e ); - } - - for ( Object metadata : result.getMetadata() ) - { - if ( metadata.getClass().getName().endsWith( ".internal.VersionsMetadata" ) ) - { - relatedMetadata.put( versionKey, (MergeableMetadata) metadata ); - } - if ( snapshotKey != null && metadata.getClass().getName().endsWith( ".internal.RemoteSnapshotMetadata" ) ) - { - relatedMetadata.put( snapshotKey, (MergeableMetadata) metadata ); - } - } - - artifact.setResolvedVersion( result.getArtifacts().iterator().next().getVersion() ); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/installer/ArtifactInstallationException.java b/maven-compat/src/main/java/org/apache/maven/artifact/installer/ArtifactInstallationException.java deleted file mode 100644 index 9f1e45b9ae18..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/installer/ArtifactInstallationException.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.apache.maven.artifact.installer; - -/* - * 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. - */ - -/** - * @author Jason van Zyl - */ -public class ArtifactInstallationException - extends Exception -{ - public ArtifactInstallationException( String message ) - { - super( message ); - } - - public ArtifactInstallationException( Throwable cause ) - { - super( cause ); - } - - public ArtifactInstallationException( String message, - Throwable cause ) - { - super( message, cause ); - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/installer/ArtifactInstaller.java b/maven-compat/src/main/java/org/apache/maven/artifact/installer/ArtifactInstaller.java deleted file mode 100644 index ca6bb206a220..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/installer/ArtifactInstaller.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.apache.maven.artifact.installer; - -/* - * 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.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; - -/** - * @author Michal Maczka - */ -public interface ArtifactInstaller -{ - String ROLE = ArtifactInstaller.class.getName(); - - /** - * Install an artifact from a particular directory. The artifact handler is used to determine - * the filename of the source file. - * - * @param basedir the directory where the artifact is stored - * @param finalName the name of the artifact sans extension - * @param artifact the artifact definition - * @param localRepository the local repository to install into - * @throws ArtifactInstallationException if an error occurred installing the artifact - * @deprecated to be removed before 2.0 after the install/deploy plugins use the alternate - * method - */ - @Deprecated - void install( String basedir, String finalName, Artifact artifact, ArtifactRepository localRepository ) - throws ArtifactInstallationException; - - /** - * Install an artifact from a particular file. - * - * @param source the file to install - * @param artifact the artifact definition - * @param localRepository the local repository to install into - * @throws ArtifactInstallationException if an error occurred installing the artifact - */ - void install( File source, Artifact artifact, ArtifactRepository localRepository ) - throws ArtifactInstallationException; -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java b/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java deleted file mode 100644 index 5deee382f948..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java +++ /dev/null @@ -1,136 +0,0 @@ -package org.apache.maven.artifact.installer; - -/* - * 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.RepositoryUtils; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadata; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.LegacyLocalRepositoryManager; -import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; -import org.apache.maven.artifact.repository.metadata.MetadataBridge; -import org.apache.maven.artifact.repository.metadata.Snapshot; -import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; -import org.apache.maven.artifact.repository.metadata.Versioning; -import org.apache.maven.plugin.LegacySupport; -import org.apache.maven.project.artifact.ProjectArtifactMetadata; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.RequestTrace; -import org.eclipse.aether.installation.InstallRequest; -import org.eclipse.aether.installation.InstallationException; -import org.eclipse.aether.util.artifact.SubArtifact; - -/** - * @author Jason van Zyl - */ -@Component( role = ArtifactInstaller.class ) -public class DefaultArtifactInstaller - extends AbstractLogEnabled - implements ArtifactInstaller -{ - - @Requirement - private RepositorySystem repoSystem; - - @Requirement - private LegacySupport legacySupport; - - /** @deprecated we want to use the artifact method only, and ensure artifact.file is set correctly. */ - @Deprecated - public void install( String basedir, String finalName, Artifact artifact, ArtifactRepository localRepository ) - throws ArtifactInstallationException - { - String extension = artifact.getArtifactHandler().getExtension(); - File source = new File( basedir, finalName + "." + extension ); - - install( source, artifact, localRepository ); - } - - public void install( File source, Artifact artifact, ArtifactRepository localRepository ) - throws ArtifactInstallationException - { - RepositorySystemSession session = - LegacyLocalRepositoryManager.overlay( localRepository, legacySupport.getRepositorySession(), repoSystem ); - - InstallRequest request = new InstallRequest(); - - request.setTrace( RequestTrace.newChild( null, legacySupport.getSession().getCurrentProject() ) ); - - org.eclipse.aether.artifact.Artifact mainArtifact = RepositoryUtils.toArtifact( artifact ); - mainArtifact = mainArtifact.setFile( source ); - request.addArtifact( mainArtifact ); - - for ( ArtifactMetadata metadata : artifact.getMetadataList() ) - { - if ( metadata instanceof ProjectArtifactMetadata ) - { - org.eclipse.aether.artifact.Artifact pomArtifact = new SubArtifact( mainArtifact, "", "pom" ); - pomArtifact = pomArtifact.setFile( ( (ProjectArtifactMetadata) metadata ).getFile() ); - request.addArtifact( pomArtifact ); - } - else if ( metadata instanceof SnapshotArtifactRepositoryMetadata - || metadata instanceof ArtifactRepositoryMetadata ) - { - // eaten, handled by repo system - } - else - { - request.addMetadata( new MetadataBridge( metadata ) ); - } - } - - try - { - repoSystem.install( session, request ); - } - catch ( InstallationException e ) - { - throw new ArtifactInstallationException( e.getMessage(), e ); - } - - /* - * NOTE: Not used by Maven core, only here to provide backward-compat with plugins like the Install Plugin. - */ - - if ( artifact.isSnapshot() ) - { - Snapshot snapshot = new Snapshot(); - snapshot.setLocalCopy( true ); - artifact.addMetadata( new SnapshotArtifactRepositoryMetadata( artifact, snapshot ) ); - } - - Versioning versioning = new Versioning(); - // TODO Should this be changed for MNG-6754 too? - versioning.updateTimestamp(); - versioning.addVersion( artifact.getBaseVersion() ); - if ( artifact.isRelease() ) - { - versioning.setRelease( artifact.getBaseVersion() ); - } - artifact.addMetadata( new ArtifactRepositoryMetadata( artifact, versioning ) ); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java b/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java deleted file mode 100644 index 5f7957e7063e..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java +++ /dev/null @@ -1,185 +0,0 @@ -package org.apache.maven.artifact.manager; - -/* - * 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.List; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; -import org.apache.maven.execution.MavenExecutionRequest; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.LegacySupport; -import org.apache.maven.repository.MirrorSelector; -import org.apache.maven.settings.Mirror; -import org.apache.maven.settings.Proxy; -import org.apache.maven.settings.Server; -import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest; -import org.apache.maven.settings.crypto.SettingsDecrypter; -import org.apache.maven.settings.crypto.SettingsDecryptionResult; -import org.apache.maven.wagon.ResourceDoesNotExistException; -import org.apache.maven.wagon.TransferFailedException; -import org.apache.maven.wagon.authentication.AuthenticationInfo; -import org.apache.maven.wagon.proxy.ProxyInfo; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.logging.Logger; - -/** - * Manages Wagon related operations in Maven. - */ -@Component( role = WagonManager.class ) -public class DefaultWagonManager - extends org.apache.maven.repository.legacy.DefaultWagonManager - implements WagonManager -{ - - // NOTE: This must use a different field name than in the super class or IoC has no chance to inject the loggers - @Requirement - private Logger log; - - @Requirement - private LegacySupport legacySupport; - - @Requirement - private SettingsDecrypter settingsDecrypter; - - @Requirement - private MirrorSelector mirrorSelector; - - @Requirement - private ArtifactRepositoryFactory artifactRepositoryFactory; - - public AuthenticationInfo getAuthenticationInfo( String id ) - { - MavenSession session = legacySupport.getSession(); - - if ( session != null && id != null ) - { - MavenExecutionRequest request = session.getRequest(); - - if ( request != null ) - { - List servers = request.getServers(); - - if ( servers != null ) - { - for ( Server server : servers ) - { - if ( id.equalsIgnoreCase( server.getId() ) ) - { - SettingsDecryptionResult result = - settingsDecrypter.decrypt( new DefaultSettingsDecryptionRequest( server ) ); - server = result.getServer(); - - AuthenticationInfo authInfo = new AuthenticationInfo(); - authInfo.setUserName( server.getUsername() ); - authInfo.setPassword( server.getPassword() ); - authInfo.setPrivateKey( server.getPrivateKey() ); - authInfo.setPassphrase( server.getPassphrase() ); - - return authInfo; - } - } - } - } - } - - // empty one to prevent NPE - return new AuthenticationInfo(); - } - - public ProxyInfo getProxy( String protocol ) - { - MavenSession session = legacySupport.getSession(); - - if ( session != null && protocol != null ) - { - MavenExecutionRequest request = session.getRequest(); - - if ( request != null ) - { - List proxies = request.getProxies(); - - if ( proxies != null ) - { - for ( Proxy proxy : proxies ) - { - if ( proxy.isActive() && protocol.equalsIgnoreCase( proxy.getProtocol() ) ) - { - SettingsDecryptionResult result = - settingsDecrypter.decrypt( new DefaultSettingsDecryptionRequest( proxy ) ); - proxy = result.getProxy(); - - ProxyInfo proxyInfo = new ProxyInfo(); - proxyInfo.setHost( proxy.getHost() ); - proxyInfo.setType( proxy.getProtocol() ); - proxyInfo.setPort( proxy.getPort() ); - proxyInfo.setNonProxyHosts( proxy.getNonProxyHosts() ); - proxyInfo.setUserName( proxy.getUsername() ); - proxyInfo.setPassword( proxy.getPassword() ); - - return proxyInfo; - } - } - } - } - } - - return null; - } - - public void getArtifact( Artifact artifact, ArtifactRepository repository ) - throws TransferFailedException, ResourceDoesNotExistException - { - getArtifact( artifact, repository, null, false ); - } - - public void getArtifact( Artifact artifact, List remoteRepositories ) - throws TransferFailedException, ResourceDoesNotExistException - { - getArtifact( artifact, remoteRepositories, null, false ); - } - - @Deprecated - public ArtifactRepository getMirrorRepository( ArtifactRepository repository ) - { - - Mirror mirror = mirrorSelector.getMirror( repository, legacySupport.getSession().getSettings().getMirrors() ); - - if ( mirror != null ) - { - String id = mirror.getId(); - if ( id == null ) - { - // TODO this should be illegal in settings.xml - id = repository.getId(); - } - - log.debug( "Using mirror: " + mirror.getUrl() + " (id: " + id + ")" ); - - repository = artifactRepositoryFactory.createArtifactRepository( id, mirror.getUrl(), - repository.getLayout(), repository.getSnapshots(), - repository.getReleases() ); - } - return repository; - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/manager/WagonConfigurationException.java b/maven-compat/src/main/java/org/apache/maven/artifact/manager/WagonConfigurationException.java deleted file mode 100644 index 8065116f7bf9..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/manager/WagonConfigurationException.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.apache.maven.artifact.manager; - -/* - * 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. - */ - -/** - * @author Olivier Lamy - */ -@Deprecated -public class WagonConfigurationException - extends org.apache.maven.repository.legacy.WagonConfigurationException -{ - public WagonConfigurationException( String repositoryId, String message, Throwable cause ) - { - super( repositoryId, message, cause ); - } - - public WagonConfigurationException( String repositoryId, String message ) - { - super( repositoryId, message ); - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/manager/WagonManager.java b/maven-compat/src/main/java/org/apache/maven/artifact/manager/WagonManager.java deleted file mode 100644 index 4337bb610999..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/manager/WagonManager.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.apache.maven.artifact.manager; - -/* - * 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.List; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.wagon.ResourceDoesNotExistException; -import org.apache.maven.wagon.TransferFailedException; -import org.apache.maven.wagon.authentication.AuthenticationInfo; -import org.apache.maven.wagon.proxy.ProxyInfo; - -/** - * Manages Wagon related operations in Maven. - * - * @author Michal Maczka - */ -@Deprecated -public interface WagonManager - extends org.apache.maven.repository.legacy.WagonManager -{ - /** - * this method is only here for backward compat (project-info-reports:dependencies) - * the default implementation will return an empty AuthenticationInfo - */ - AuthenticationInfo getAuthenticationInfo( String id ); - - ProxyInfo getProxy( String protocol ); - - void getArtifact( Artifact artifact, ArtifactRepository repository ) - throws TransferFailedException, ResourceDoesNotExistException; - - void getArtifact( Artifact artifact, List remoteRepositories ) - throws TransferFailedException, ResourceDoesNotExistException; - - ArtifactRepository getMirrorRepository( ArtifactRepository repository ); - -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryFactory.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryFactory.java deleted file mode 100644 index 446ec49561a2..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryFactory.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.apache.maven.artifact.repository; - -/* - * 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.artifact.UnknownRepositoryLayoutException; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; - -/** - * @author jdcasey - */ -public interface ArtifactRepositoryFactory -{ - String ROLE = ArtifactRepositoryFactory.class.getName(); - - String DEFAULT_LAYOUT_ID = "default"; - - String LOCAL_REPOSITORY_ID = "local"; - - @Deprecated - ArtifactRepositoryLayout getLayout( String layoutId ) - throws UnknownRepositoryLayoutException; - - @Deprecated - ArtifactRepository createDeploymentArtifactRepository( String id, String url, String layoutId, - boolean uniqueVersion ) - throws UnknownRepositoryLayoutException; - - ArtifactRepository createDeploymentArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, - boolean uniqueVersion ); - - ArtifactRepository createArtifactRepository( String id, String url, String layoutId, - ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ) - throws UnknownRepositoryLayoutException; - - ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout, - ArtifactRepositoryPolicy snapshots, - ArtifactRepositoryPolicy releases ); - - void setGlobalUpdatePolicy( String snapshotPolicy ); - - void setGlobalChecksumPolicy( String checksumPolicy ); -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java deleted file mode 100644 index ef487b8ad347..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java +++ /dev/null @@ -1,279 +0,0 @@ -package org.apache.maven.artifact.repository; - -/* - * 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.Collections; -import java.util.List; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadata; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.repository.Proxy; -import org.apache.maven.wagon.repository.Repository; - -/** - * This class is an abstraction of the location from/to resources can be - * transfered. - * - * @author Michal Maczka - */ -@Deprecated -public class DefaultArtifactRepository - extends Repository - implements ArtifactRepository -{ - private ArtifactRepositoryLayout layout; - - private ArtifactRepositoryPolicy snapshots; - - private ArtifactRepositoryPolicy releases; - - private boolean blacklisted; - - private Authentication authentication; - - private Proxy proxy; - - private List mirroredRepositories = Collections.emptyList(); - - private boolean blocked; - - /** - * Create a local repository or a test repository. - * - * @param id the unique identifier of the repository - * @param url the URL of the repository - * @param layout the layout of the repository - */ - public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout ) - { - this( id, url, layout, null, null ); - } - - /** - * Create a remote deployment repository. - * - * @param id the unique identifier of the repository - * @param url the URL of the repository - * @param layout the layout of the repository - * @param uniqueVersion whether to assign each snapshot a unique version - */ - public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, boolean uniqueVersion ) - { - super( id, url ); - this.layout = layout; - } - - /** - * Create a remote download repository. - * - * @param id the unique identifier of the repository - * @param url the URL of the repository - * @param layout the layout of the repository - * @param snapshots the policies to use for snapshots - * @param releases the policies to use for releases - */ - public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, - ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ) - { - super( id, url ); - - this.layout = layout; - - if ( snapshots == null ) - { - snapshots = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, - ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE ); - } - - this.snapshots = snapshots; - - if ( releases == null ) - { - releases = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, - ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE ); - } - - this.releases = releases; - } - - public String pathOf( Artifact artifact ) - { - return layout.pathOf( artifact ); - } - - public String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata ) - { - return layout.pathOfRemoteRepositoryMetadata( artifactMetadata ); - } - - public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) - { - return layout.pathOfLocalRepositoryMetadata( metadata, repository ); - } - - public void setLayout( ArtifactRepositoryLayout layout ) - { - this.layout = layout; - } - - public ArtifactRepositoryLayout getLayout() - { - return layout; - } - - public void setSnapshotUpdatePolicy( ArtifactRepositoryPolicy snapshots ) - { - this.snapshots = snapshots; - } - - public ArtifactRepositoryPolicy getSnapshots() - { - return snapshots; - } - - public void setReleaseUpdatePolicy( ArtifactRepositoryPolicy releases ) - { - this.releases = releases; - } - - public ArtifactRepositoryPolicy getReleases() - { - return releases; - } - - public String getKey() - { - return getId(); - } - - public boolean isBlacklisted() - { - return blacklisted; - } - - public void setBlacklisted( boolean blacklisted ) - { - this.blacklisted = blacklisted; - } - - public String toString() - { - StringBuilder sb = new StringBuilder( 256 ); - - sb.append( " id: " ).append( getId() ).append( '\n' ); - sb.append( " url: " ).append( getUrl() ).append( '\n' ); - sb.append( " layout: " ).append( layout != null ? layout : "none" ).append( '\n' ); - - if ( snapshots != null ) - { - sb.append( "snapshots: [enabled => " ).append( snapshots.isEnabled() ); - sb.append( ", update => " ).append( snapshots.getUpdatePolicy() ).append( "]\n" ); - } - - if ( releases != null ) - { - sb.append( " releases: [enabled => " ).append( releases.isEnabled() ); - sb.append( ", update => " ).append( releases.getUpdatePolicy() ).append( "]\n" ); - } - - return sb.toString(); - } - - public Artifact find( Artifact artifact ) - { - File artifactFile = new File( getBasedir(), pathOf( artifact ) ); - - // We need to set the file here or the resolver will fail with an NPE, not fully equipped to deal - // with multiple local repository implementations yet. - artifact.setFile( artifactFile ); - - if ( artifactFile.exists() ) - { - artifact.setResolved( true ); - } - - return artifact; - } - - public List findVersions( Artifact artifact ) - { - return Collections.emptyList(); - } - - public boolean isProjectAware() - { - return false; - } - - public Authentication getAuthentication() - { - return authentication; - } - - public void setAuthentication( Authentication authentication ) - { - this.authentication = authentication; - } - - public Proxy getProxy() - { - return proxy; - } - - public void setProxy( Proxy proxy ) - { - this.proxy = proxy; - } - - public boolean isUniqueVersion() - { - return true; - } - - public List getMirroredRepositories() - { - return mirroredRepositories; - } - - public void setMirroredRepositories( List mirroredRepositories ) - { - if ( mirroredRepositories != null ) - { - this.mirroredRepositories = Collections.unmodifiableList( mirroredRepositories ); - } - else - { - this.mirroredRepositories = Collections.emptyList(); - } - } - - public boolean isBlocked() - { - return blocked; - } - - public void setBlocked( boolean blocked ) - { - this.blocked = blocked; - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java deleted file mode 100644 index 0f69835c4546..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.apache.maven.artifact.repository; - -/* - * 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.apache.maven.artifact.UnknownRepositoryLayoutException; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.plugin.LegacySupport; -import org.apache.maven.repository.RepositorySystem; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.eclipse.aether.RepositorySystemSession; - -/** - * @author jdcasey - */ -@Component( role = ArtifactRepositoryFactory.class ) -public class DefaultArtifactRepositoryFactory - implements ArtifactRepositoryFactory -{ - - @Requirement - private org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory factory; - - @Requirement - private LegacySupport legacySupport; - - @Requirement - private RepositorySystem repositorySystem; - - public ArtifactRepositoryLayout getLayout( String layoutId ) - throws UnknownRepositoryLayoutException - { - return factory.getLayout( layoutId ); - } - - public ArtifactRepository createDeploymentArtifactRepository( String id, String url, String layoutId, - boolean uniqueVersion ) - throws UnknownRepositoryLayoutException - { - return injectSession( factory.createDeploymentArtifactRepository( id, url, layoutId, uniqueVersion ), false ); - } - - public ArtifactRepository createDeploymentArtifactRepository( String id, String url, - ArtifactRepositoryLayout repositoryLayout, - boolean uniqueVersion ) - { - return injectSession( factory.createDeploymentArtifactRepository( id, url, repositoryLayout, uniqueVersion ), - false ); - } - - public ArtifactRepository createArtifactRepository( String id, String url, String layoutId, - ArtifactRepositoryPolicy snapshots, - ArtifactRepositoryPolicy releases ) - throws UnknownRepositoryLayoutException - { - return injectSession( factory.createArtifactRepository( id, url, layoutId, snapshots, releases ), true ); - } - - public ArtifactRepository createArtifactRepository( String id, String url, - ArtifactRepositoryLayout repositoryLayout, - ArtifactRepositoryPolicy snapshots, - ArtifactRepositoryPolicy releases ) - { - return injectSession( factory.createArtifactRepository( id, url, repositoryLayout, snapshots, releases ), - true ); - - } - - public void setGlobalUpdatePolicy( String updatePolicy ) - { - factory.setGlobalUpdatePolicy( updatePolicy ); - } - - public void setGlobalChecksumPolicy( String checksumPolicy ) - { - factory.setGlobalChecksumPolicy( checksumPolicy ); - } - - private ArtifactRepository injectSession( ArtifactRepository repository, boolean mirrors ) - { - RepositorySystemSession session = legacySupport.getRepositorySession(); - - if ( session != null && repository != null && !isLocalRepository( repository ) ) - { - List repositories = Arrays.asList( repository ); - - if ( mirrors ) - { - repositorySystem.injectMirror( session, repositories ); - } - - repositorySystem.injectProxy( session, repositories ); - - repositorySystem.injectAuthentication( session, repositories ); - } - - return repository; - } - - private boolean isLocalRepository( ArtifactRepository repository ) - { - // unfortunately, the API doesn't allow to tell a remote repo and the local repo apart... - return "local".equals( repository.getId() ); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/layout/FlatRepositoryLayout.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/layout/FlatRepositoryLayout.java deleted file mode 100644 index 4426611570bc..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/layout/FlatRepositoryLayout.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.apache.maven.artifact.repository.layout; - -/* - * 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.artifact.Artifact; -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.metadata.ArtifactMetadata; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.codehaus.plexus.component.annotations.Component; - -/** - * FlatRepositoryLayout - */ -@Component( role = ArtifactRepositoryLayout.class, hint = "flat" ) -public class FlatRepositoryLayout - implements ArtifactRepositoryLayout -{ - - private static final char ARTIFACT_SEPARATOR = '-'; - - private static final char GROUP_SEPARATOR = '.'; - - public String getId() - { - return "flat"; - } - - public String pathOf( Artifact artifact ) - { - ArtifactHandler artifactHandler = artifact.getArtifactHandler(); - - StringBuilder path = new StringBuilder( 128 ); - - path.append( artifact.getArtifactId() ).append( ARTIFACT_SEPARATOR ).append( artifact.getVersion() ); - - if ( artifact.hasClassifier() ) - { - path.append( ARTIFACT_SEPARATOR ).append( artifact.getClassifier() ); - } - - if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 ) - { - path.append( GROUP_SEPARATOR ).append( artifactHandler.getExtension() ); - } - - return path.toString(); - } - - public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) - { - return pathOfRepositoryMetadata( metadata.getLocalFilename( repository ) ); - } - - private String pathOfRepositoryMetadata( String filename ) - { - StringBuilder path = new StringBuilder( 128 ); - - path.append( filename ); - - return path.toString(); - } - - public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata ) - { - return pathOfRepositoryMetadata( metadata.getRemoteFilename() ); - } - - @Override - public String toString() - { - return getId(); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java deleted file mode 100644 index 28ba94df6b72..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java +++ /dev/null @@ -1,536 +0,0 @@ -package org.apache.maven.artifact.repository.metadata; - -/* - * 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.artifact.metadata.ArtifactMetadata; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; -import org.apache.maven.artifact.repository.DefaultRepositoryRequest; -import org.apache.maven.artifact.repository.RepositoryRequest; -import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; -import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer; -import org.apache.maven.repository.legacy.UpdateCheckManager; -import org.apache.maven.repository.legacy.WagonManager; -import org.apache.maven.wagon.ResourceDoesNotExistException; -import org.apache.maven.wagon.TransferFailedException; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.util.ReaderFactory; -import org.codehaus.plexus.util.WriterFactory; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.Reader; -import java.io.Writer; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author Jason van Zyl - */ -@Component( role = RepositoryMetadataManager.class ) -public class DefaultRepositoryMetadataManager - extends AbstractLogEnabled - implements RepositoryMetadataManager -{ - @Requirement - private WagonManager wagonManager; - - @Requirement - private UpdateCheckManager updateCheckManager; - - public void resolve( RepositoryMetadata metadata, List remoteRepositories, - ArtifactRepository localRepository ) - throws RepositoryMetadataResolutionException - { - RepositoryRequest request = new DefaultRepositoryRequest(); - request.setLocalRepository( localRepository ); - request.setRemoteRepositories( remoteRepositories ); - resolve( metadata, request ); - } - - public void resolve( RepositoryMetadata metadata, RepositoryRequest request ) - throws RepositoryMetadataResolutionException - { - ArtifactRepository localRepo = request.getLocalRepository(); - List remoteRepositories = request.getRemoteRepositories(); - - if ( !request.isOffline() ) - { - Date localCopyLastModified = null; - if ( metadata.getBaseVersion() != null ) - { - localCopyLastModified = getLocalCopyLastModified( localRepo, metadata ); - } - - for ( ArtifactRepository repository : remoteRepositories ) - { - ArtifactRepositoryPolicy policy = metadata.getPolicy( repository ); - - File file = - new File( localRepo.getBasedir(), localRepo.pathOfLocalRepositoryMetadata( metadata, repository ) ); - boolean update; - - if ( !policy.isEnabled() ) - { - update = false; - - if ( getLogger().isDebugEnabled() ) - { - getLogger().debug( "Skipping update check for " + metadata.getKey() + " (" + file - + ") from disabled repository " + repository.getId() + " (" - + repository.getUrl() + ")" ); - } - } - else if ( request.isForceUpdate() ) - { - update = true; - } - else if ( localCopyLastModified != null && !policy.checkOutOfDate( localCopyLastModified ) ) - { - update = false; - - if ( getLogger().isDebugEnabled() ) - { - getLogger().debug( - "Skipping update check for " + metadata.getKey() + " (" + file + ") from repository " - + repository.getId() + " (" + repository.getUrl() + ") in favor of local copy" ); - } - } - else - { - update = updateCheckManager.isUpdateRequired( metadata, repository, file ); - } - - if ( update ) - { - getLogger().info( metadata.getKey() + ": checking for updates from " + repository.getId() ); - try - { - wagonManager.getArtifactMetadata( metadata, repository, file, policy.getChecksumPolicy() ); - } - catch ( ResourceDoesNotExistException e ) - { - getLogger().debug( metadata + " could not be found on repository: " + repository.getId() ); - - // delete the local copy so the old details aren't used. - if ( file.exists() ) - { - if ( !file.delete() ) - { - // sleep for 10ms just in case this is windows holding a file lock - try - { - Thread.sleep( 10 ); - } - catch ( InterruptedException ie ) - { - // ignore - } - file.delete(); // if this fails, forget about it - } - } - } - catch ( TransferFailedException e ) - { - getLogger().warn( metadata + " could not be retrieved from repository: " + repository.getId() - + " due to an error: " + e.getMessage() ); - getLogger().debug( "Exception", e ); - } - finally - { - updateCheckManager.touch( metadata, repository, file ); - } - } - - // TODO should this be inside the above check? - // touch file so that this is not checked again until interval has passed - if ( file.exists() ) - { - file.setLastModified( System.currentTimeMillis() ); - } - } - } - - try - { - mergeMetadata( metadata, remoteRepositories, localRepo ); - } - catch ( RepositoryMetadataStoreException e ) - { - throw new RepositoryMetadataResolutionException( - "Unable to store local copy of metadata: " + e.getMessage(), e ); - } - } - - private Date getLocalCopyLastModified( ArtifactRepository localRepository, RepositoryMetadata metadata ) - { - String metadataPath = localRepository.pathOfLocalRepositoryMetadata( metadata, localRepository ); - File metadataFile = new File( localRepository.getBasedir(), metadataPath ); - return metadataFile.isFile() ? new Date( metadataFile.lastModified() ) : null; - } - - private void mergeMetadata( RepositoryMetadata metadata, List remoteRepositories, - ArtifactRepository localRepository ) - throws RepositoryMetadataStoreException - { - // TODO currently this is first wins, but really we should take the latest by comparing either the - // snapshot timestamp, or some other timestamp later encoded into the metadata. - // TODO this needs to be repeated here so the merging doesn't interfere with the written metadata - // - we'd be much better having a pristine input, and an ongoing metadata for merging instead - - Map previousMetadata = new HashMap<>(); - ArtifactRepository selected = null; - for ( ArtifactRepository repository : remoteRepositories ) - { - ArtifactRepositoryPolicy policy = metadata.getPolicy( repository ); - - if ( policy.isEnabled() && loadMetadata( metadata, repository, localRepository, previousMetadata ) ) - { - metadata.setRepository( repository ); - selected = repository; - } - } - if ( loadMetadata( metadata, localRepository, localRepository, previousMetadata ) ) - { - metadata.setRepository( null ); - selected = localRepository; - } - - updateSnapshotMetadata( metadata, previousMetadata, selected, localRepository ); - } - - private void updateSnapshotMetadata( RepositoryMetadata metadata, - Map previousMetadata, - ArtifactRepository selected, ArtifactRepository localRepository ) - throws RepositoryMetadataStoreException - { - // TODO this could be a lot nicer... should really be in the snapshot transformation? - if ( metadata.isSnapshot() ) - { - Metadata prevMetadata = metadata.getMetadata(); - - for ( ArtifactRepository repository : previousMetadata.keySet() ) - { - Metadata m = previousMetadata.get( repository ); - if ( repository.equals( selected ) ) - { - if ( m.getVersioning() == null ) - { - m.setVersioning( new Versioning() ); - } - - if ( m.getVersioning().getSnapshot() == null ) - { - m.getVersioning().setSnapshot( new Snapshot() ); - } - } - else - { - if ( ( m.getVersioning() != null ) && ( m.getVersioning().getSnapshot() != null ) - && m.getVersioning().getSnapshot().isLocalCopy() ) - { - m.getVersioning().getSnapshot().setLocalCopy( false ); - metadata.setMetadata( m ); - metadata.storeInLocalRepository( localRepository, repository ); - } - } - } - - metadata.setMetadata( prevMetadata ); - } - } - - private boolean loadMetadata( RepositoryMetadata repoMetadata, ArtifactRepository remoteRepository, - ArtifactRepository localRepository, - Map previousMetadata ) - { - boolean setRepository = false; - - File metadataFile = new File( localRepository.getBasedir(), - localRepository.pathOfLocalRepositoryMetadata( repoMetadata, remoteRepository ) ); - - if ( metadataFile.exists() ) - { - Metadata metadata; - - try - { - metadata = readMetadata( metadataFile ); - } - catch ( RepositoryMetadataReadException e ) - { - if ( getLogger().isDebugEnabled() ) - { - getLogger().warn( e.getMessage(), e ); - } - else - { - getLogger().warn( e.getMessage() ); - } - return setRepository; - } - - if ( repoMetadata.isSnapshot() && ( previousMetadata != null ) ) - { - previousMetadata.put( remoteRepository, metadata ); - } - - if ( repoMetadata.getMetadata() != null ) - { - setRepository = repoMetadata.getMetadata().merge( metadata ); - } - else - { - repoMetadata.setMetadata( metadata ); - setRepository = true; - } - } - return setRepository; - } - - /** - * TODO share with DefaultPluginMappingManager. - */ - protected Metadata readMetadata( File mappingFile ) - throws RepositoryMetadataReadException - { - Metadata result; - - try ( Reader reader = ReaderFactory.newXmlReader( mappingFile ) ) - { - MetadataXpp3Reader mappingReader = new MetadataXpp3Reader(); - - result = mappingReader.read( reader, false ); - } - catch ( FileNotFoundException e ) - { - throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "'", e ); - } - catch ( IOException | XmlPullParserException e ) - { - throw new RepositoryMetadataReadException( - "Cannot read metadata from '" + mappingFile + "': " + e.getMessage(), e ); - } - return result; - } - - /** - * Ensures the last updated timestamp of the specified metadata does not refer to the future and fixes the local - * metadata if necessary to allow proper merging/updating of metadata during deployment. - */ - private void fixTimestamp( File metadataFile, Metadata metadata, Metadata reference ) - { - boolean changed = false; - - if ( metadata != null && reference != null ) - { - Versioning versioning = metadata.getVersioning(); - Versioning versioningRef = reference.getVersioning(); - if ( versioning != null && versioningRef != null ) - { - String lastUpdated = versioning.getLastUpdated(); - String now = versioningRef.getLastUpdated(); - if ( lastUpdated != null && now != null && now.compareTo( lastUpdated ) < 0 ) - { - getLogger().warn( - "The last updated timestamp in " + metadataFile + " refers to the future (now = " + now - + ", lastUpdated = " + lastUpdated + "). Please verify that the clocks of all" - + " deploying machines are reasonably synchronized." ); - versioning.setLastUpdated( now ); - changed = true; - } - } - } - - if ( changed ) - { - getLogger().debug( "Repairing metadata in " + metadataFile ); - - try ( Writer writer = WriterFactory.newXmlWriter( metadataFile ) ) - { - new MetadataXpp3Writer().write( writer, metadata ); - } - catch ( IOException e ) - { - String msg = "Could not write fixed metadata to " + metadataFile + ": " + e.getMessage(); - if ( getLogger().isDebugEnabled() ) - { - getLogger().warn( msg, e ); - } - else - { - getLogger().warn( msg ); - } - } - } - } - - public void resolveAlways( RepositoryMetadata metadata, ArtifactRepository localRepository, - ArtifactRepository remoteRepository ) - throws RepositoryMetadataResolutionException - { - File file; - try - { - file = getArtifactMetadataFromDeploymentRepository( metadata, localRepository, remoteRepository ); - } - catch ( TransferFailedException e ) - { - throw new RepositoryMetadataResolutionException( - metadata + " could not be retrieved from repository: " + remoteRepository.getId() + " due to an error: " - + e.getMessage(), e ); - } - - try - { - if ( file.exists() ) - { - Metadata prevMetadata = readMetadata( file ); - metadata.setMetadata( prevMetadata ); - } - } - catch ( RepositoryMetadataReadException e ) - { - throw new RepositoryMetadataResolutionException( e.getMessage(), e ); - } - } - - private File getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository localRepo, - ArtifactRepository remoteRepository ) - throws TransferFailedException - { - File file = - new File( localRepo.getBasedir(), localRepo.pathOfLocalRepositoryMetadata( metadata, remoteRepository ) ); - - try - { - wagonManager.getArtifactMetadataFromDeploymentRepository( metadata, remoteRepository, file, - ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN ); - } - catch ( ResourceDoesNotExistException e ) - { - getLogger().info( - metadata + " could not be found on repository: " + remoteRepository.getId() + ", so will be created" ); - - // delete the local copy so the old details aren't used. - if ( file.exists() ) - { - if ( !file.delete() ) - { - // sleep for 10ms just in case this is windows holding a file lock - try - { - Thread.sleep( 10 ); - } - catch ( InterruptedException ie ) - { - // ignore - } - file.delete(); // if this fails, forget about it - } - } - } - finally - { - if ( metadata instanceof RepositoryMetadata ) - { - updateCheckManager.touch( (RepositoryMetadata) metadata, remoteRepository, file ); - } - } - return file; - } - - public void deploy( ArtifactMetadata metadata, ArtifactRepository localRepository, - ArtifactRepository deploymentRepository ) - throws RepositoryMetadataDeploymentException - { - File file; - if ( metadata instanceof RepositoryMetadata ) - { - getLogger().info( "Retrieving previous metadata from " + deploymentRepository.getId() ); - try - { - file = getArtifactMetadataFromDeploymentRepository( metadata, localRepository, deploymentRepository ); - } - catch ( TransferFailedException e ) - { - throw new RepositoryMetadataDeploymentException( - metadata + " could not be retrieved from repository: " + deploymentRepository.getId() - + " due to an error: " + e.getMessage(), e ); - } - - if ( file.isFile() ) - { - try - { - fixTimestamp( file, readMetadata( file ), ( (RepositoryMetadata) metadata ).getMetadata() ); - } - catch ( RepositoryMetadataReadException e ) - { - // will be reported via storeInlocalRepository - } - } - } - else - { - // It's a POM - we don't need to retrieve it first - file = new File( localRepository.getBasedir(), - localRepository.pathOfLocalRepositoryMetadata( metadata, deploymentRepository ) ); - } - - try - { - metadata.storeInLocalRepository( localRepository, deploymentRepository ); - } - catch ( RepositoryMetadataStoreException e ) - { - throw new RepositoryMetadataDeploymentException( "Error installing metadata: " + e.getMessage(), e ); - } - - try - { - wagonManager.putArtifactMetadata( file, metadata, deploymentRepository ); - } - catch ( TransferFailedException e ) - { - throw new RepositoryMetadataDeploymentException( "Error while deploying metadata: " + e.getMessage(), e ); - } - } - - public void install( ArtifactMetadata metadata, ArtifactRepository localRepository ) - throws RepositoryMetadataInstallationException - { - try - { - metadata.storeInLocalRepository( localRepository, localRepository ); - } - catch ( RepositoryMetadataStoreException e ) - { - throw new RepositoryMetadataInstallationException( "Error installing metadata: " + e.getMessage(), e ); - } - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/GroupRepositoryMetadata.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/GroupRepositoryMetadata.java deleted file mode 100644 index fd88ddcb9786..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/GroupRepositoryMetadata.java +++ /dev/null @@ -1,119 +0,0 @@ -package org.apache.maven.artifact.repository.metadata; - -/* - * 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.artifact.repository.ArtifactRepository; - -import java.util.Iterator; -import java.util.List; - -/** - * Metadata for the group directory of the repository. - * - * @author Brett Porter - */ -public class GroupRepositoryMetadata - extends AbstractRepositoryMetadata -{ - private final String groupId; - - public GroupRepositoryMetadata( String groupId ) - { - super( new Metadata() ); - this.groupId = groupId; - } - - public boolean storedInGroupDirectory() - { - return true; - } - - public boolean storedInArtifactVersionDirectory() - { - return false; - } - - public String getGroupId() - { - return groupId; - } - - public String getArtifactId() - { - return null; - } - - public String getBaseVersion() - { - return null; - } - - public void addPluginMapping( String goalPrefix, - String artifactId ) - { - addPluginMapping( goalPrefix, artifactId, artifactId ); - } - - public void addPluginMapping( String goalPrefix, - String artifactId, - String name ) - { - List plugins = getMetadata().getPlugins(); - boolean found = false; - for ( Iterator i = plugins.iterator(); i.hasNext() && !found; ) - { - Plugin plugin = i.next(); - if ( plugin.getPrefix().equals( goalPrefix ) ) - { - found = true; - } - } - if ( !found ) - { - Plugin plugin = new Plugin(); - plugin.setPrefix( goalPrefix ); - plugin.setArtifactId( artifactId ); - plugin.setName( name ); - - - getMetadata().addPlugin( plugin ); - } - } - - public Object getKey() - { - return groupId; - } - - public boolean isSnapshot() - { - return false; - } - - public ArtifactRepository getRepository() - { - return null; - } - - public void setRepository( ArtifactRepository remoteRepository ) - { - // intentionally blank - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java deleted file mode 100644 index 0fd49dd34488..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java +++ /dev/null @@ -1,172 +0,0 @@ -package org.apache.maven.artifact.repository.metadata; - -/* - * 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.Collections; -import java.util.Map; - -import org.apache.maven.artifact.metadata.ArtifactMetadata; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.DefaultArtifactRepository; -import org.codehaus.plexus.util.FileUtils; -import org.eclipse.aether.RepositoryException; -import org.eclipse.aether.metadata.AbstractMetadata; -import org.eclipse.aether.metadata.MergeableMetadata; -import org.eclipse.aether.metadata.Metadata; - -/** - * Warning: This is an internal utility class that is only public for technical reasons, it is not part - * of the public API. In particular, this class can be changed or deleted without prior notice. - * - * @author Benjamin Bentmann - */ -public final class MetadataBridge - extends AbstractMetadata - implements MergeableMetadata -{ - - private ArtifactMetadata metadata; - - private boolean merged; - - public MetadataBridge( ArtifactMetadata metadata ) - { - this.metadata = metadata; - } - - public void merge( File current, File result ) - throws RepositoryException - { - try - { - if ( current.exists() ) - { - FileUtils.copyFile( current, result ); - } - ArtifactRepository localRepo = new MetadataRepository( result ); - metadata.storeInLocalRepository( localRepo, localRepo ); - merged = true; - } - catch ( Exception e ) - { - throw new RepositoryException( e.getMessage(), e ); - } - } - - public boolean isMerged() - { - return merged; - } - - public String getGroupId() - { - return emptify( metadata.getGroupId() ); - } - - public String getArtifactId() - { - return metadata.storedInGroupDirectory() ? "" : emptify( metadata.getArtifactId() ); - } - - public String getVersion() - { - return metadata.storedInArtifactVersionDirectory() ? emptify( metadata.getBaseVersion() ) : ""; - } - - public String getType() - { - return metadata.getRemoteFilename(); - } - - private String emptify( String string ) - { - return ( string != null ) ? string : ""; - } - - public File getFile() - { - return null; - } - - public MetadataBridge setFile( File file ) - { - return this; - } - - public Nature getNature() - { - if ( metadata instanceof RepositoryMetadata ) - { - switch ( ( (RepositoryMetadata) metadata ).getNature() ) - { - case RepositoryMetadata.RELEASE_OR_SNAPSHOT: - return Nature.RELEASE_OR_SNAPSHOT; - case RepositoryMetadata.SNAPSHOT: - return Nature.SNAPSHOT; - default: - return Nature.RELEASE; - } - } - else - { - return Nature.RELEASE; - } - } - - public Map getProperties() - { - return Collections.emptyMap(); - } - - @Override - public Metadata setProperties( Map properties ) - { - return this; - } - - @SuppressWarnings( "deprecation" ) - static class MetadataRepository - extends DefaultArtifactRepository - { - - private File metadataFile; - - MetadataRepository( File metadataFile ) - { - super( "local", "", null ); - this.metadataFile = metadataFile; - } - - @Override - public String getBasedir() - { - return metadataFile.getParent(); - } - - @Override - public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) - { - return metadataFile.getName(); - } - - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataUtils.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataUtils.java deleted file mode 100644 index bdc4a795ad15..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataUtils.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.apache.maven.artifact.repository.metadata; - -/* - * 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. - */ - -/** - * Assists in handling repository metadata. - * - * @author Benjamin Bentmann - */ -class MetadataUtils -{ - - public static Metadata cloneMetadata( Metadata src ) - { - if ( src == null ) - { - return null; - } - return src.clone(); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataReadException.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataReadException.java deleted file mode 100644 index 23e598410ff7..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataReadException.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.maven.artifact.repository.metadata; - -/* - * 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. - */ - -/** - * Problem storing the repository metadata in the local repository. - * - * @author Brett Porter - */ -public class RepositoryMetadataReadException - extends Exception -{ - public RepositoryMetadataReadException( String message ) - { - super( message ); - } - - public RepositoryMetadataReadException( String message, - Exception e ) - { - super( message, e ); - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactCollector.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactCollector.java deleted file mode 100644 index 3526be408129..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactCollector.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.apache.maven.artifact.resolver; - -/* - * 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.List; -import java.util.Set; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.filter.ArtifactFilter; - -/** - * Artifact collector - takes a set of original artifacts and resolves all of the best versions to use - * along with their metadata. No artifacts are downloaded. - */ -@Deprecated -public interface ArtifactCollector - extends org.apache.maven.repository.legacy.resolver.LegacyArtifactCollector -{ - - @Deprecated - ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, - ArtifactRepository localRepository, List remoteRepositories, - ArtifactMetadataSource source, ArtifactFilter filter, - List listeners ) - throws ArtifactResolutionException; - -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java deleted file mode 100644 index 45204f8479d8..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java +++ /dev/null @@ -1,116 +0,0 @@ -package org.apache.maven.artifact.resolver; - -/* - * 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.List; -import java.util.Map; -import java.util.Set; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.filter.ArtifactFilter; -import org.apache.maven.wagon.events.TransferListener; - -/** - * @author Jason van Zyl - */ -// Just hide the one method we want behind the RepositorySystem interface. -public interface ArtifactResolver -{ - - ArtifactResolutionResult resolve( ArtifactResolutionRequest request ); - - // The rest is deprecated - // USED BY MAVEN ASSEMBLY PLUGIN 2.2-beta-2 - @Deprecated - String ROLE = ArtifactResolver.class.getName(); - - // USED BY SUREFIRE, DEPENDENCY PLUGIN - @Deprecated - ArtifactResolutionResult resolveTransitively( - Set artifacts, Artifact originatingArtifact, - ArtifactRepository localRepository, - List remoteRepositories, - ArtifactMetadataSource source, ArtifactFilter filter ) - throws ArtifactResolutionException, ArtifactNotFoundException; - - // USED BY MAVEN ASSEMBLY PLUGIN - @Deprecated - ArtifactResolutionResult resolveTransitively( - Set artifacts, Artifact originatingArtifact, - Map managedVersions, ArtifactRepository localRepository, - List remoteRepositories, - ArtifactMetadataSource source ) - throws ArtifactResolutionException, ArtifactNotFoundException; - - // USED BY MAVEN ASSEMBLY PLUGIN - @Deprecated - ArtifactResolutionResult resolveTransitively( - Set artifacts, Artifact originatingArtifact, - Map managedVersions, ArtifactRepository localRepository, - List remoteRepositories, - ArtifactMetadataSource source, ArtifactFilter filter ) - throws ArtifactResolutionException, ArtifactNotFoundException; - - // USED BY INVOKER PLUGIN - @Deprecated - ArtifactResolutionResult resolveTransitively( - Set artifacts, Artifact originatingArtifact, - List remoteRepositories, - ArtifactRepository localRepository, ArtifactMetadataSource source ) - throws ArtifactResolutionException, ArtifactNotFoundException; - - @Deprecated - @SuppressWarnings( "checkstyle:parameternumber" ) - ArtifactResolutionResult resolveTransitively( - Set artifacts, Artifact originatingArtifact, - Map managedVersions, ArtifactRepository localRepository, - List remoteRepositories, - ArtifactMetadataSource source, ArtifactFilter filter, - List listeners ) - throws ArtifactResolutionException, ArtifactNotFoundException; - - @Deprecated - ArtifactResolutionResult resolveTransitively( - Set artifacts, Artifact originatingArtifact, - List remoteRepositories, - ArtifactRepository localRepository, ArtifactMetadataSource source, - List listeners ) - throws ArtifactResolutionException, ArtifactNotFoundException; - - // USED BY REMOTE RESOURCES PLUGIN, DEPENDENCY PLUGIN, SHADE PLUGIN - @Deprecated - void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) - throws ArtifactResolutionException, ArtifactNotFoundException; - - // USED BY REMOTE RESOURCES PLUGIN - @Deprecated - void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository, - TransferListener downloadMonitor ) - throws ArtifactResolutionException, ArtifactNotFoundException; - - // USED BY DEPENDENCY PLUGIN, ARCHETYPE DOWNLOADER - @Deprecated - void resolveAlways( Artifact artifact, List remoteRepositories, - ArtifactRepository localRepository ) - throws ArtifactResolutionException, ArtifactNotFoundException; - -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java deleted file mode 100644 index 25e92c420260..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.apache.maven.artifact.resolver; - -/* - * 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; - -/** - * Artifact collector - takes a set of original artifacts and resolves all of the best versions to use - * along with their metadata. No artifacts are downloaded. - */ -@Deprecated -@Component( role = ArtifactCollector.class ) -public class DefaultArtifactCollector - extends org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector - implements ArtifactCollector -{ -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/UnresolvedArtifacts.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/UnresolvedArtifacts.java deleted file mode 100644 index b9ccf7067ebf..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/UnresolvedArtifacts.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.apache.maven.artifact.resolver; - -/* - * 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.List; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; - -/** - * A simple recording of the Artifacts that could not be resolved for a given resolution request, along with - * the remote repositories where attempts were made to resolve the artifacts. - * - * @author Jason van Zyl - */ -public class UnresolvedArtifacts -{ - private Artifact originatingArtifact; - - private List artifacts; - - private List remoteRepositories; - - public UnresolvedArtifacts( Artifact originatingArtifact, - List artifacts, - List remoteRepositories ) - { - this.originatingArtifact = originatingArtifact; - - this.artifacts = artifacts; - - this.remoteRepositories = remoteRepositories; - } - - public Artifact getOriginatingArtifact() - { - return originatingArtifact; - } - - public List getArtifacts() - { - return artifacts; - } - - public List getRemoteRepositories() - { - return remoteRepositories; - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/WarningResolutionListener.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/WarningResolutionListener.java deleted file mode 100644 index 825d595a2d09..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/WarningResolutionListener.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.apache.maven.artifact.resolver; - -/* - * 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.artifact.Artifact; -import org.apache.maven.artifact.versioning.VersionRange; -import org.codehaus.plexus.logging.Logger; - -/** - * Send resolution warning events to the warning log. - * - * @author Brett Porter - */ -public class WarningResolutionListener - implements ResolutionListener -{ - private Logger logger; - - public WarningResolutionListener( Logger logger ) - { - this.logger = logger; - } - - public void testArtifact( Artifact node ) - { - } - - public void startProcessChildren( Artifact artifact ) - { - } - - public void endProcessChildren( Artifact artifact ) - { - } - - public void includeArtifact( Artifact artifact ) - { - } - - public void omitForNearer( Artifact omitted, - Artifact kept ) - { - } - - public void omitForCycle( Artifact omitted ) - { - } - - public void updateScopeCurrentPom( Artifact artifact, - String scope ) - { - } - - public void updateScope( Artifact artifact, - String scope ) - { - } - - public void manageArtifact( Artifact artifact, - Artifact replacement ) - { - } - - public void selectVersionFromRange( Artifact artifact ) - { - } - - public void restrictRange( Artifact artifact, - Artifact replacement, - VersionRange newRange ) - { - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/filter/InversionArtifactFilter.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/filter/InversionArtifactFilter.java deleted file mode 100644 index fa66574d60ad..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/filter/InversionArtifactFilter.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.apache.maven.artifact.resolver.filter; - -/* - * 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.artifact.Artifact; - -/** - * InversionArtifactFilter - */ -public class InversionArtifactFilter - implements ArtifactFilter -{ - private final ArtifactFilter toInvert; - - public InversionArtifactFilter( ArtifactFilter toInvert ) - { - this.toInvert = toInvert; - } - - public boolean include( Artifact artifact ) - { - return !toInvert.include( artifact ); - } - - @Override - public int hashCode() - { - int hash = 17; - hash = hash * 31 + toInvert.hashCode(); - return hash; - } - - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - { - return true; - } - - if ( !( obj instanceof InversionArtifactFilter ) ) - { - return false; - } - - InversionArtifactFilter other = (InversionArtifactFilter) obj; - - return toInvert.equals( other.toInvert ); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/filter/OrArtifactFilter.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/filter/OrArtifactFilter.java deleted file mode 100644 index 24bfbf404f88..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/filter/OrArtifactFilter.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.apache.maven.artifact.resolver.filter; - -/* - * 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.LinkedHashSet; -import java.util.Set; - -import org.apache.maven.artifact.Artifact; - -/** - * Apply multiple filters, accepting an artifact if at least one of the filters accepts it. - * - * @author Benjamin Bentmann - */ -public class OrArtifactFilter - implements ArtifactFilter -{ - - private Set filters; - - public OrArtifactFilter() - { - this.filters = new LinkedHashSet<>(); - } - - public OrArtifactFilter( Collection filters ) - { - this.filters = new LinkedHashSet<>( filters ); - } - - public boolean include( Artifact artifact ) - { - for ( ArtifactFilter filter : filters ) - { - if ( filter.include( artifact ) ) - { - return true; - } - } - - return false; - } - - public void add( ArtifactFilter artifactFilter ) - { - filters.add( artifactFilter ); - } - - @Override - public int hashCode() - { - int hash = 17; - hash = hash * 31 + filters.hashCode(); - return hash; - } - - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - { - return true; - } - - if ( !( obj instanceof OrArtifactFilter ) ) - { - return false; - } - - OrArtifactFilter other = (OrArtifactFilter) obj; - - return filters.equals( other.filters ); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/filter/TypeArtifactFilter.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/filter/TypeArtifactFilter.java deleted file mode 100644 index 76c39ec3571e..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/filter/TypeArtifactFilter.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.apache.maven.artifact.resolver.filter; - -/* - * 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.artifact.Artifact; - -/** Artifact Filter which filters on artifact type */ -public class TypeArtifactFilter - implements ArtifactFilter -{ - private String type = "jar"; - - public TypeArtifactFilter( String type ) - { - this.type = type; - } - - public boolean include( Artifact artifact ) - { - return type.equals( artifact.getType() ); - } - - @Override - public int hashCode() - { - int hash = 17; - hash = hash * 31 + type.hashCode(); - return hash; - } - - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - { - return true; - } - - if ( !( obj instanceof TypeArtifactFilter ) ) - { - return false; - } - - TypeArtifactFilter other = (TypeArtifactFilter) obj; - - return type.equals( other.type ); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/execution/DefaultRuntimeInformation.java b/maven-compat/src/main/java/org/apache/maven/execution/DefaultRuntimeInformation.java deleted file mode 100644 index 7767aff1e0d9..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/execution/DefaultRuntimeInformation.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.apache.maven.execution; - -/* - * 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.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; -import org.codehaus.plexus.util.StringUtils; - -/** - * Describes runtime information about the application. - * - * @author Brett Porter - */ -@Deprecated -@Component( role = RuntimeInformation.class ) -public class DefaultRuntimeInformation - implements RuntimeInformation, Initializable -{ - - @Requirement - private org.apache.maven.rtinfo.RuntimeInformation rtInfo; - - private ArtifactVersion applicationVersion; - - public ArtifactVersion getApplicationVersion() - { - return applicationVersion; - } - - public void initialize() - throws InitializationException - { - String mavenVersion = rtInfo.getMavenVersion(); - - if ( StringUtils.isEmpty( mavenVersion ) ) - { - throw new InitializationException( "Unable to read Maven version from maven-core" ); - } - - applicationVersion = new DefaultArtifactVersion( mavenVersion ); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/execution/RuntimeInformation.java b/maven-compat/src/main/java/org/apache/maven/execution/RuntimeInformation.java deleted file mode 100644 index 22e522d28984..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/execution/RuntimeInformation.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.apache.maven.execution; - -/* - * 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.artifact.versioning.ArtifactVersion; - -/** - * Describes runtime information about the application. - * - * @deprecated Use {@link org.apache.maven.rtinfo.RuntimeInformation} instead. - * @author Brett Porter - */ -@Deprecated -public interface RuntimeInformation -{ - ArtifactVersion getApplicationVersion(); -} diff --git a/maven-compat/src/main/java/org/apache/maven/profiles/DefaultMavenProfilesBuilder.java b/maven-compat/src/main/java/org/apache/maven/profiles/DefaultMavenProfilesBuilder.java deleted file mode 100644 index 8ee9001c8954..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/profiles/DefaultMavenProfilesBuilder.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.apache.maven.profiles; - -/* - * 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.profiles.io.xpp3.ProfilesXpp3Reader; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.interpolation.EnvarBasedValueSource; -import org.codehaus.plexus.interpolation.RegexBasedInterpolator; -import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.ReaderFactory; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - -import java.io.File; -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import java.io.StringWriter; - -/** - * DefaultMavenProfilesBuilder - */ -@Deprecated -@Component( role = MavenProfilesBuilder.class ) -public class DefaultMavenProfilesBuilder - extends AbstractLogEnabled - implements MavenProfilesBuilder -{ - private static final String PROFILES_XML_FILE = "profiles.xml"; - - public ProfilesRoot buildProfiles( File basedir ) - throws IOException, XmlPullParserException - { - File profilesXml = new File( basedir, PROFILES_XML_FILE ); - - ProfilesRoot profilesRoot = null; - - if ( profilesXml.exists() ) - { - ProfilesXpp3Reader reader = new ProfilesXpp3Reader(); - try ( Reader profileReader = ReaderFactory.newXmlReader( profilesXml ); - StringWriter sWriter = new StringWriter() ) - { - IOUtil.copy( profileReader, sWriter ); - - String rawInput = sWriter.toString(); - - try - { - RegexBasedInterpolator interpolator = new RegexBasedInterpolator(); - interpolator.addValueSource( new EnvarBasedValueSource() ); - - rawInput = interpolator.interpolate( rawInput, "settings" ); - } - catch ( Exception e ) - { - getLogger().warn( - "Failed to initialize environment variable resolver. Skipping environment " + "substitution in " - + PROFILES_XML_FILE + "." ); - getLogger().debug( "Failed to initialize envar resolver. Skipping resolution.", e ); - } - - StringReader sReader = new StringReader( rawInput ); - - profilesRoot = reader.read( sReader ); - } - - } - - return profilesRoot; - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java b/maven-compat/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java deleted file mode 100644 index 375460aeedeb..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java +++ /dev/null @@ -1,238 +0,0 @@ -package org.apache.maven.profiles; - -/* - * 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.Activation; -import org.apache.maven.model.Profile; -import org.apache.maven.model.building.ModelProblem; -import org.apache.maven.model.profile.DefaultProfileActivationContext; -import org.apache.maven.model.profile.ProfileSelector; -import org.apache.maven.profiles.activation.ProfileActivationException; -import org.codehaus.plexus.MutablePlexusContainer; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.logging.Logger; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -/** - * DefaultProfileManager - */ -@Deprecated -public class DefaultProfileManager - implements ProfileManager -{ - - @Requirement - private Logger logger; - - @Requirement - private ProfileSelector profileSelector; - - private List activatedIds = new ArrayList<>(); - - private List deactivatedIds = new ArrayList<>(); - - private List defaultIds = new ArrayList<>(); - - private Map profilesById = new LinkedHashMap<>(); - - private Properties requestProperties; - - /** - * @deprecated without passing in the system properties, the SystemPropertiesProfileActivator will not work - * correctly in embedded environments. - */ - public DefaultProfileManager( PlexusContainer container ) - { - this( container, null ); - } - - /** - * the properties passed to the profile manager are the props that - * are passed to maven, possibly containing profile activator properties - * - */ - public DefaultProfileManager( PlexusContainer container, Properties props ) - { - try - { - this.profileSelector = container.lookup( ProfileSelector.class ); - this.logger = ( (MutablePlexusContainer) container ).getLogger(); - } - catch ( ComponentLookupException e ) - { - throw new IllegalStateException( e ); - } - this.requestProperties = props; - } - - public Properties getRequestProperties() - { - return requestProperties; - } - - public Map getProfilesById() - { - return profilesById; - } - - /* (non-Javadoc) - * @see org.apache.maven.profiles.ProfileManager#addProfile(org.apache.maven.model.Profile) - */ - public void addProfile( Profile profile ) - { - String profileId = profile.getId(); - - Profile existing = profilesById.get( profileId ); - if ( existing != null ) - { - logger.warn( "Overriding profile: \'" + profileId + "\' (source: " + existing.getSource() - + ") with new instance from source: " + profile.getSource() ); - } - - profilesById.put( profile.getId(), profile ); - - Activation activation = profile.getActivation(); - - if ( activation != null && activation.isActiveByDefault() ) - { - activateAsDefault( profileId ); - } - } - - /* (non-Javadoc) - * @see org.apache.maven.profiles.ProfileManager#explicitlyActivate(java.lang.String) - */ - public void explicitlyActivate( String profileId ) - { - if ( !activatedIds.contains( profileId ) ) - { - logger.debug( "Profile with id: \'" + profileId + "\' has been explicitly activated." ); - - activatedIds.add( profileId ); - } - } - - /* (non-Javadoc) - * @see org.apache.maven.profiles.ProfileManager#explicitlyActivate(java.util.List) - */ - public void explicitlyActivate( List profileIds ) - { - for ( String profileId1 : profileIds ) - { - explicitlyActivate( profileId1 ); - } - } - - /* (non-Javadoc) - * @see org.apache.maven.profiles.ProfileManager#explicitlyDeactivate(java.lang.String) - */ - public void explicitlyDeactivate( String profileId ) - { - if ( !deactivatedIds.contains( profileId ) ) - { - logger.debug( "Profile with id: \'" + profileId + "\' has been explicitly deactivated." ); - - deactivatedIds.add( profileId ); - } - } - - /* (non-Javadoc) - * @see org.apache.maven.profiles.ProfileManager#explicitlyDeactivate(java.util.List) - */ - public void explicitlyDeactivate( List profileIds ) - { - for ( String profileId1 : profileIds ) - { - explicitlyDeactivate( profileId1 ); - } - } - - /* (non-Javadoc) - * @see org.apache.maven.profiles.ProfileManager#getActiveProfiles() - */ - public List getActiveProfiles() - throws ProfileActivationException - { - DefaultProfileActivationContext context = new DefaultProfileActivationContext(); - context.setActiveProfileIds( activatedIds ); - context.setInactiveProfileIds( deactivatedIds ); - context.setSystemProperties( System.getProperties() ); - context.setUserProperties( requestProperties ); - - final List errors = new ArrayList<>(); - - List profiles = profileSelector.getActiveProfiles( profilesById.values(), context, req -> - { - if ( !ModelProblem.Severity.WARNING.equals( req.getSeverity() ) ) - { - errors.add( new ProfileActivationException( req.getMessage(), req.getException() ) ); - } - } ); - - if ( !errors.isEmpty() ) - { - throw errors.get( 0 ); - } - - return profiles; - } - - /* (non-Javadoc) - * @see org.apache.maven.profiles.ProfileManager#addProfiles(java.util.List) - */ - public void addProfiles( List profiles ) - { - for ( Profile profile1 : profiles ) - { - addProfile( profile1 ); - } - } - - public void activateAsDefault( String profileId ) - { - if ( !defaultIds.contains( profileId ) ) - { - defaultIds.add( profileId ); - } - } - - public List getExplicitlyActivatedIds() - { - return activatedIds; - } - - public List getExplicitlyDeactivatedIds() - { - return deactivatedIds; - } - - public List getIdsActivatedByDefault() - { - return defaultIds; - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/profiles/MavenProfilesBuilder.java b/maven-compat/src/main/java/org/apache/maven/profiles/MavenProfilesBuilder.java deleted file mode 100644 index 32fb6aaa426a..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/profiles/MavenProfilesBuilder.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.apache.maven.profiles; - -/* - * 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.util.xml.pull.XmlPullParserException; - -import java.io.File; -import java.io.IOException; - -/** - * @author jdcasey - */ -@Deprecated -public interface MavenProfilesBuilder -{ - String ROLE = MavenProfilesBuilder.class.getName(); - - ProfilesRoot buildProfiles( File basedir ) - throws IOException, XmlPullParserException; -} diff --git a/maven-compat/src/main/java/org/apache/maven/profiles/ProfileManager.java b/maven-compat/src/main/java/org/apache/maven/profiles/ProfileManager.java deleted file mode 100644 index 5fab10068406..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/profiles/ProfileManager.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.apache.maven.profiles; - -/* - * 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.Profile; -import org.apache.maven.profiles.activation.ProfileActivationException; - -import java.util.List; -import java.util.Map; -import java.util.Properties; - -/** - * ProfileManager - */ -@Deprecated -public interface ProfileManager -{ - - void addProfile( Profile profile ); - - void explicitlyActivate( String profileId ); - - void explicitlyActivate( List profileIds ); - - void explicitlyDeactivate( String profileId ); - - void explicitlyDeactivate( List profileIds ); - - List getActiveProfiles() - throws ProfileActivationException; - - void addProfiles( List profiles ); - - Map getProfilesById(); - - List getExplicitlyActivatedIds(); - - List getExplicitlyDeactivatedIds(); - - List getIdsActivatedByDefault(); - - Properties getRequestProperties(); - -} diff --git a/maven-compat/src/main/java/org/apache/maven/profiles/ProfilesConversionUtils.java b/maven-compat/src/main/java/org/apache/maven/profiles/ProfilesConversionUtils.java deleted file mode 100644 index 154176eecf76..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/profiles/ProfilesConversionUtils.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.maven.profiles; - -/* - * 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.Activation; -import org.apache.maven.model.ActivationFile; -import org.apache.maven.model.ActivationProperty; -import org.apache.maven.model.Profile; -import org.apache.maven.model.Repository; - -import java.util.List; - -/** - * ProfilesConversionUtils - */ -@Deprecated -public class ProfilesConversionUtils -{ - private ProfilesConversionUtils() - { - } - - public static Profile convertFromProfileXmlProfile( org.apache.maven.profiles.Profile profileXmlProfile ) - { - Profile profile = new Profile(); - - profile.setId( profileXmlProfile.getId() ); - - profile.setSource( "profiles.xml" ); - - org.apache.maven.profiles.Activation profileActivation = profileXmlProfile.getActivation(); - - if ( profileActivation != null ) - { - Activation activation = new Activation(); - - activation.setActiveByDefault( profileActivation.isActiveByDefault() ); - - activation.setJdk( profileActivation.getJdk() ); - - org.apache.maven.profiles.ActivationProperty profileProp = profileActivation.getProperty(); - - if ( profileProp != null ) - { - ActivationProperty prop = new ActivationProperty(); - - prop.setName( profileProp.getName() ); - prop.setValue( profileProp.getValue() ); - - activation.setProperty( prop ); - } - - - ActivationOS profileOs = profileActivation.getOs(); - - if ( profileOs != null ) - { - org.apache.maven.model.ActivationOS os = new org.apache.maven.model.ActivationOS(); - - os.setArch( profileOs.getArch() ); - os.setFamily( profileOs.getFamily() ); - os.setName( profileOs.getName() ); - os.setVersion( profileOs.getVersion() ); - - activation.setOs( os ); - } - - org.apache.maven.profiles.ActivationFile profileFile = profileActivation.getFile(); - - if ( profileFile != null ) - { - ActivationFile file = new ActivationFile(); - - file.setExists( profileFile.getExists() ); - file.setMissing( profileFile.getMissing() ); - - activation.setFile( file ); - } - - profile.setActivation( activation ); - } - - profile.setProperties( profileXmlProfile.getProperties() ); - - List repos = profileXmlProfile.getRepositories(); - if ( repos != null ) - { - for ( Object repo : repos ) - { - profile.addRepository( convertFromProfileXmlRepository( (org.apache.maven.profiles.Repository) repo ) ); - } - } - - List pluginRepos = profileXmlProfile.getPluginRepositories(); - if ( pluginRepos != null ) - { - for ( Object pluginRepo : pluginRepos ) - { - profile.addPluginRepository( - convertFromProfileXmlRepository( (org.apache.maven.profiles.Repository) pluginRepo ) ); - } - } - - return profile; - } - - private static Repository convertFromProfileXmlRepository( org.apache.maven.profiles.Repository profileXmlRepo ) - { - Repository repo = new Repository(); - - repo.setId( profileXmlRepo.getId() ); - repo.setLayout( profileXmlRepo.getLayout() ); - repo.setName( profileXmlRepo.getName() ); - repo.setUrl( profileXmlRepo.getUrl() ); - - if ( profileXmlRepo.getSnapshots() != null ) - { - repo.setSnapshots( convertRepositoryPolicy( profileXmlRepo.getSnapshots() ) ); - } - if ( profileXmlRepo.getReleases() != null ) - { - repo.setReleases( convertRepositoryPolicy( profileXmlRepo.getReleases() ) ); - } - - return repo; - } - - private static org.apache.maven.model.RepositoryPolicy convertRepositoryPolicy( RepositoryPolicy profileXmlRepo ) - { - org.apache.maven.model.RepositoryPolicy policy = new org.apache.maven.model.RepositoryPolicy(); - policy.setEnabled( profileXmlRepo.isEnabled() ); - policy.setUpdatePolicy( profileXmlRepo.getUpdatePolicy() ); - policy.setChecksumPolicy( profileXmlRepo.getChecksumPolicy() ); - return policy; - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/profiles/activation/DetectedProfileActivator.java b/maven-compat/src/main/java/org/apache/maven/profiles/activation/DetectedProfileActivator.java deleted file mode 100644 index f03424505326..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/profiles/activation/DetectedProfileActivator.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.apache.maven.profiles.activation; - -/* - * 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.Profile; - -/** - * DetectedProfileActivator - */ -@Deprecated -public abstract class DetectedProfileActivator - implements ProfileActivator -{ - public boolean canDetermineActivation( Profile profile ) - { - return canDetectActivation( profile ); - } - - protected abstract boolean canDetectActivation( Profile profile ); - -} diff --git a/maven-compat/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java b/maven-compat/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java deleted file mode 100644 index 586f57f7fb06..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.apache.maven.profiles.activation; - -/* - * 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.IOException; - -import org.apache.maven.model.Activation; -import org.apache.maven.model.ActivationFile; -import org.apache.maven.model.Profile; -import org.codehaus.plexus.interpolation.EnvarBasedValueSource; -import org.codehaus.plexus.interpolation.InterpolationException; -import org.codehaus.plexus.interpolation.MapBasedValueSource; -import org.codehaus.plexus.interpolation.RegexBasedInterpolator; -import org.codehaus.plexus.logging.LogEnabled; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.StringUtils; - -/** - * FileProfileActivator - */ -@Deprecated -public class FileProfileActivator - extends DetectedProfileActivator - implements LogEnabled -{ - private Logger logger; - - protected boolean canDetectActivation( Profile profile ) - { - return profile.getActivation() != null && profile.getActivation().getFile() != null; - } - - public boolean isActive( Profile profile ) - { - Activation activation = profile.getActivation(); - - ActivationFile actFile = activation.getFile(); - - if ( actFile != null ) - { - // check if the file exists, if it does then the profile will be active - String fileString = actFile.getExists(); - - RegexBasedInterpolator interpolator = new RegexBasedInterpolator(); - try - { - interpolator.addValueSource( new EnvarBasedValueSource() ); - } - catch ( IOException e ) - { - // ignored - } - interpolator.addValueSource( new MapBasedValueSource( System.getProperties() ) ); - - try - { - if ( StringUtils.isNotEmpty( fileString ) ) - { - fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" ); - return FileUtils.fileExists( fileString ); - } - - // check if the file is missing, if it is then the profile will be active - fileString = actFile.getMissing(); - - if ( StringUtils.isNotEmpty( fileString ) ) - { - fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" ); - return !FileUtils.fileExists( fileString ); - } - } - catch ( InterpolationException e ) - { - if ( logger.isDebugEnabled() ) - { - logger.debug( "Failed to interpolate missing file location for profile activator: " + fileString, - e ); - } - else - { - logger.warn( "Failed to interpolate missing file location for profile activator: " + fileString - + ", enable verbose output (-X) for more details" ); - } - } - } - - return false; - } - - public void enableLogging( Logger logger ) - { - this.logger = logger; - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/profiles/activation/JdkPrefixProfileActivator.java b/maven-compat/src/main/java/org/apache/maven/profiles/activation/JdkPrefixProfileActivator.java deleted file mode 100644 index 1c835f814be6..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/profiles/activation/JdkPrefixProfileActivator.java +++ /dev/null @@ -1,100 +0,0 @@ -package org.apache.maven.profiles.activation; - -/* - * 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.artifact.versioning.DefaultArtifactVersion; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.maven.model.Activation; -import org.apache.maven.model.Profile; -import org.codehaus.plexus.util.StringUtils; - -/** - * JdkPrefixProfileActivator - */ -@Deprecated -public class JdkPrefixProfileActivator - extends DetectedProfileActivator -{ - private static final String JDK_VERSION = System.getProperty( "java.version" ); - - public boolean isActive( Profile profile ) - throws ProfileActivationException - { - Activation activation = profile.getActivation(); - - String jdk = activation.getJdk(); - - // null case is covered by canDetermineActivation(), so we can do a straight startsWith() here. - if ( jdk.startsWith( "[" ) || jdk.startsWith( "(" ) ) - { - try - { - return matchJdkVersionRange( jdk ); - } - catch ( InvalidVersionSpecificationException e ) - { - throw new ProfileActivationException( "Invalid JDK version in profile '" + profile.getId() + "': " - + e.getMessage() ); - } - } - - boolean reverse = false; - - if ( jdk.startsWith( "!" ) ) - { - reverse = true; - jdk = jdk.substring( 1 ); - } - - if ( getJdkVersion().startsWith( jdk ) ) - { - return !reverse; - } - else - { - return reverse; - } - } - - private boolean matchJdkVersionRange( String jdk ) - throws InvalidVersionSpecificationException - { - VersionRange jdkVersionRange = VersionRange.createFromVersionSpec( convertJdkToMavenVersion( jdk ) ); - DefaultArtifactVersion jdkVersion = new DefaultArtifactVersion( convertJdkToMavenVersion( getJdkVersion() ) ); - return jdkVersionRange.containsVersion( jdkVersion ); - } - - private String convertJdkToMavenVersion( String jdk ) - { - return jdk.replaceAll( "_", "-" ); - } - - protected String getJdkVersion() - { - return JDK_VERSION; - } - - protected boolean canDetectActivation( Profile profile ) - { - return profile.getActivation() != null && StringUtils.isNotEmpty( profile.getActivation().getJdk() ); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/profiles/activation/OperatingSystemProfileActivator.java b/maven-compat/src/main/java/org/apache/maven/profiles/activation/OperatingSystemProfileActivator.java deleted file mode 100644 index 378c3c948139..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/profiles/activation/OperatingSystemProfileActivator.java +++ /dev/null @@ -1,164 +0,0 @@ -package org.apache.maven.profiles.activation; - -/* - * 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.Activation; -import org.apache.maven.model.ActivationOS; -import org.apache.maven.model.Profile; -import org.codehaus.plexus.util.Os; - -/** - * OperatingSystemProfileActivator - */ -@Deprecated -public class OperatingSystemProfileActivator - implements ProfileActivator -{ - - public boolean canDetermineActivation( Profile profile ) - { - Activation activation = profile.getActivation(); - return activation != null && activation.getOs() != null; - } - - public boolean isActive( Profile profile ) - { - Activation activation = profile.getActivation(); - ActivationOS os = activation.getOs(); - - boolean result = ensureAtLeastOneNonNull( os ); - - if ( result && os.getFamily() != null ) - { - result = determineFamilyMatch( os.getFamily() ); - } - if ( result && os.getName() != null ) - { - result = determineNameMatch( os.getName() ); - } - if ( result && os.getArch() != null ) - { - result = determineArchMatch( os.getArch() ); - } - if ( result && os.getVersion() != null ) - { - result = determineVersionMatch( os.getVersion() ); - } - return result; - } - - private boolean ensureAtLeastOneNonNull( ActivationOS os ) - { - return os.getArch() != null || os.getFamily() != null || os.getName() != null || os.getVersion() != null; - } - - private boolean determineVersionMatch( String version ) - { - String test = version; - boolean reverse = false; - - if ( test.startsWith( "!" ) ) - { - reverse = true; - test = test.substring( 1 ); - } - - boolean result = Os.isVersion( test ); - - if ( reverse ) - { - return !result; - } - else - { - return result; - } - } - - private boolean determineArchMatch( String arch ) - { - String test = arch; - boolean reverse = false; - - if ( test.startsWith( "!" ) ) - { - reverse = true; - test = test.substring( 1 ); - } - - boolean result = Os.isArch( test ); - - if ( reverse ) - { - return !result; - } - else - { - return result; - } - } - - private boolean determineNameMatch( String name ) - { - String test = name; - boolean reverse = false; - - if ( test.startsWith( "!" ) ) - { - reverse = true; - test = test.substring( 1 ); - } - - boolean result = Os.isName( test ); - - if ( reverse ) - { - return !result; - } - else - { - return result; - } - } - - private boolean determineFamilyMatch( String family ) - { - String test = family; - boolean reverse = false; - - if ( test.startsWith( "!" ) ) - { - reverse = true; - test = test.substring( 1 ); - } - - boolean result = Os.isFamily( test ); - - if ( reverse ) - { - return !result; - } - else - { - return result; - } - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/profiles/activation/ProfileActivationException.java b/maven-compat/src/main/java/org/apache/maven/profiles/activation/ProfileActivationException.java deleted file mode 100644 index 59f70bed0e4e..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/profiles/activation/ProfileActivationException.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.apache.maven.profiles.activation; - -/* - * 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. - */ - -/** - * ProfileActivationException - */ -@Deprecated -public class ProfileActivationException - extends Exception -{ - - private static final long serialVersionUID = -90820222109103638L; - - public ProfileActivationException( String message, Throwable cause ) - { - super( message, cause ); - } - - public ProfileActivationException( String message ) - { - super( message ); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/profiles/activation/ProfileActivator.java b/maven-compat/src/main/java/org/apache/maven/profiles/activation/ProfileActivator.java deleted file mode 100644 index 648201856080..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/profiles/activation/ProfileActivator.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.apache.maven.profiles.activation; - -/* - * 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.Profile; - -/** - * ProfileActivator - */ -@Deprecated -public interface ProfileActivator -{ - - String ROLE = ProfileActivator.class.getName(); - - boolean canDetermineActivation( Profile profile ); - - boolean isActive( Profile profile ) - throws ProfileActivationException; - -} diff --git a/maven-compat/src/main/java/org/apache/maven/profiles/activation/SystemPropertyProfileActivator.java b/maven-compat/src/main/java/org/apache/maven/profiles/activation/SystemPropertyProfileActivator.java deleted file mode 100644 index d7e400342875..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/profiles/activation/SystemPropertyProfileActivator.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.apache.maven.profiles.activation; - -/* - * 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.apache.maven.model.Activation; -import org.apache.maven.model.ActivationProperty; -import org.apache.maven.model.Profile; -import org.codehaus.plexus.context.Context; -import org.codehaus.plexus.context.ContextException; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; -import org.codehaus.plexus.util.StringUtils; - -/** - * SystemPropertyProfileActivator - */ -@Deprecated -public class SystemPropertyProfileActivator - extends DetectedProfileActivator implements Contextualizable -{ - private Properties properties; - - public void contextualize( Context context ) - throws ContextException - { - properties = (Properties) context.get( "SystemProperties" ); - } - - protected boolean canDetectActivation( Profile profile ) - { - return profile.getActivation() != null && profile.getActivation().getProperty() != null; - } - - public boolean isActive( Profile profile ) - throws ProfileActivationException - { - Activation activation = profile.getActivation(); - - ActivationProperty property = activation.getProperty(); - - if ( property != null ) - { - String name = property.getName(); - boolean reverseName = false; - - if ( name == null ) - { - throw new ProfileActivationException( "The property name is required to activate the profile '" - + profile.getId() + "'" ); - } - - if ( name.startsWith( "!" ) ) - { - reverseName = true; - name = name.substring( 1 ); - } - - String sysValue = properties.getProperty( name ); - - String propValue = property.getValue(); - if ( StringUtils.isNotEmpty( propValue ) ) - { - boolean reverseValue = false; - if ( propValue.startsWith( "!" ) ) - { - reverseValue = true; - propValue = propValue.substring( 1 ); - } - - // we have a value, so it has to match the system value... - boolean result = propValue.equals( sysValue ); - - if ( reverseValue ) - { - return !result; - } - else - { - return result; - } - } - else - { - boolean result = StringUtils.isNotEmpty( sysValue ); - - if ( reverseName ) - { - return !result; - } - else - { - return result; - } - } - } - - return false; - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-compat/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java deleted file mode 100644 index 7bc5a5c3a471..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java +++ /dev/null @@ -1,324 +0,0 @@ -package org.apache.maven.project; - -/* - * 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.Arrays; -import java.util.List; -import java.util.Properties; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.InvalidRepositoryException; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.apache.maven.execution.MavenExecutionRequest; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.model.Repository; -import org.apache.maven.model.building.ModelBuildingException; -import org.apache.maven.model.building.ModelBuildingRequest; -import org.apache.maven.model.building.ModelSource; -import org.apache.maven.model.building.UrlModelSource; -import org.apache.maven.plugin.LegacySupport; -import org.apache.maven.profiles.ProfileManager; -import org.apache.maven.properties.internal.EnvironmentUtils; -import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.wagon.events.TransferListener; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; - -/** - */ -@Component( role = MavenProjectBuilder.class ) -@Deprecated -public class DefaultMavenProjectBuilder - implements MavenProjectBuilder -{ - - @Requirement - private ProjectBuilder projectBuilder; - - @Requirement - private RepositorySystem repositorySystem; - - @Requirement - private LegacySupport legacySupport; - - // ---------------------------------------------------------------------- - // MavenProjectBuilder Implementation - // ---------------------------------------------------------------------- - - private ProjectBuildingRequest toRequest( ProjectBuilderConfiguration configuration ) - { - DefaultProjectBuildingRequest request = new DefaultProjectBuildingRequest(); - - request.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 ); - request.setResolveDependencies( false ); - - request.setLocalRepository( configuration.getLocalRepository() ); - request.setBuildStartTime( configuration.getBuildStartTime() ); - request.setUserProperties( configuration.getUserProperties() ); - request.setSystemProperties( configuration.getExecutionProperties() ); - - ProfileManager profileManager = configuration.getGlobalProfileManager(); - if ( profileManager != null ) - { - request.setActiveProfileIds( profileManager.getExplicitlyActivatedIds() ); - request.setInactiveProfileIds( profileManager.getExplicitlyDeactivatedIds() ); - } - else - { - /* - * MNG-4900: Hack to workaround deficiency of legacy API which makes it impossible for plugins to access the - * global profile manager which is required to build a POM like a CLI invocation does. Failure to consider - * the activated profiles can cause repo declarations to be lost which in turn will result in artifact - * resolution failures, in particular when using the enhanced local repo which guards access to local files - * based on the configured remote repos. - */ - MavenSession session = legacySupport.getSession(); - if ( session != null ) - { - MavenExecutionRequest req = session.getRequest(); - if ( req != null ) - { - request.setActiveProfileIds( req.getActiveProfiles() ); - request.setInactiveProfileIds( req.getInactiveProfiles() ); - } - } - } - - return request; - } - - private ProjectBuildingRequest injectSession( ProjectBuildingRequest request ) - { - MavenSession session = legacySupport.getSession(); - if ( session != null ) - { - request.setRepositorySession( session.getRepositorySession() ); - request.setSystemProperties( session.getSystemProperties() ); - if ( request.getUserProperties().isEmpty() ) - { - request.setUserProperties( session.getUserProperties() ); - } - - MavenExecutionRequest req = session.getRequest(); - if ( req != null ) - { - request.setRemoteRepositories( req.getRemoteRepositories() ); - } - } - else - { - Properties props = new Properties(); - EnvironmentUtils.addEnvVars( props ); - props.putAll( System.getProperties() ); - request.setSystemProperties( props ); - } - - return request; - } - - @SuppressWarnings( "unchecked" ) - private List normalizeToArtifactRepositories( List repositories, - ProjectBuildingRequest request ) - throws ProjectBuildingException - { - /* - * This provides backward-compat with 2.x that allowed plugins like the maven-remote-resources-plugin:1.0 to - * populate the builder configuration with model repositories instead of artifact repositories. - */ - - if ( repositories != null ) - { - boolean normalized = false; - - List repos = new ArrayList<>( repositories.size() ); - - for ( Object repository : repositories ) - { - if ( repository instanceof Repository ) - { - try - { - ArtifactRepository repo = repositorySystem.buildArtifactRepository( (Repository) repository ); - repositorySystem.injectMirror( request.getRepositorySession(), Arrays.asList( repo ) ); - repositorySystem.injectProxy( request.getRepositorySession(), Arrays.asList( repo ) ); - repositorySystem.injectAuthentication( request.getRepositorySession(), Arrays.asList( repo ) ); - repos.add( repo ); - } - catch ( InvalidRepositoryException e ) - { - throw new ProjectBuildingException( "", "Invalid remote repository " + repository, e ); - } - normalized = true; - } - else - { - repos.add( (ArtifactRepository) repository ); - } - } - - if ( normalized ) - { - return repos; - } - } - - return (List) repositories; - } - - private ProjectBuildingException transformError( ProjectBuildingException e ) - { - if ( e.getCause() instanceof ModelBuildingException ) - { - return new InvalidProjectModelException( e.getProjectId(), e.getMessage(), e.getPomFile() ); - } - - return e; - } - - public MavenProject build( File pom, ProjectBuilderConfiguration configuration ) - throws ProjectBuildingException - { - ProjectBuildingRequest request = injectSession( toRequest( configuration ) ); - - try - { - return projectBuilder.build( pom, request ).getProject(); - } - catch ( ProjectBuildingException e ) - { - throw transformError( e ); - } - } - - // This is used by the SITE plugin. - public MavenProject build( File pom, ArtifactRepository localRepository, ProfileManager profileManager ) - throws ProjectBuildingException - { - ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration(); - configuration.setLocalRepository( localRepository ); - configuration.setGlobalProfileManager( profileManager ); - - return build( pom, configuration ); - } - - public MavenProject buildFromRepository( Artifact artifact, List remoteRepositories, - ProjectBuilderConfiguration configuration, boolean allowStubModel ) - throws ProjectBuildingException - { - ProjectBuildingRequest request = injectSession( toRequest( configuration ) ); - request.setRemoteRepositories( normalizeToArtifactRepositories( remoteRepositories, request ) ); - request.setProcessPlugins( false ); - request.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL ); - - try - { - return projectBuilder.build( artifact, allowStubModel, request ).getProject(); - } - catch ( ProjectBuildingException e ) - { - throw transformError( e ); - } - } - - public MavenProject buildFromRepository( Artifact artifact, List remoteRepositories, - ArtifactRepository localRepository, boolean allowStubModel ) - throws ProjectBuildingException - { - ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration(); - configuration.setLocalRepository( localRepository ); - - return buildFromRepository( artifact, remoteRepositories, configuration, allowStubModel ); - } - - public MavenProject buildFromRepository( Artifact artifact, List remoteRepositories, - ArtifactRepository localRepository ) - throws ProjectBuildingException - { - return buildFromRepository( artifact, remoteRepositories, localRepository, true ); - } - - /** - * This is used for pom-less execution like running archetype:generate. I am taking out the profile handling and the - * interpolation of the base directory until we spec this out properly. - */ - public MavenProject buildStandaloneSuperProject( ProjectBuilderConfiguration configuration ) - throws ProjectBuildingException - { - ProjectBuildingRequest request = injectSession( toRequest( configuration ) ); - request.setProcessPlugins( false ); - request.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL ); - - ModelSource modelSource = new UrlModelSource( getClass().getResource( "standalone.xml" ) ); - - MavenProject project = projectBuilder.build( modelSource, request ).getProject(); - project.setExecutionRoot( true ); - return project; - } - - public MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository ) - throws ProjectBuildingException - { - return buildStandaloneSuperProject( localRepository, null ); - } - - public MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository, ProfileManager profileManager ) - throws ProjectBuildingException - { - ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration(); - configuration.setLocalRepository( localRepository ); - configuration.setGlobalProfileManager( profileManager ); - - return buildStandaloneSuperProject( configuration ); - } - - public MavenProject buildWithDependencies( File pom, ArtifactRepository localRepository, - ProfileManager profileManager, TransferListener transferListener ) - throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException - { - ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration(); - configuration.setLocalRepository( localRepository ); - configuration.setGlobalProfileManager( profileManager ); - - ProjectBuildingRequest request = injectSession( toRequest( configuration ) ); - - request.setResolveDependencies( true ); - - try - { - return projectBuilder.build( pom, request ).getProject(); - } - catch ( ProjectBuildingException e ) - { - throw transformError( e ); - } - } - - public MavenProject buildWithDependencies( File pom, ArtifactRepository localRepository, - ProfileManager profileManager ) - throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException - { - return buildWithDependencies( pom, localRepository, profileManager, null ); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java b/maven-compat/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java deleted file mode 100644 index aca6a0342a62..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.apache.maven.project; - -/* - * 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.Date; -import java.util.Properties; - -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.profiles.ProfileManager; - -/** - * DefaultProjectBuilderConfiguration - */ -@Deprecated -public class DefaultProjectBuilderConfiguration - implements ProjectBuilderConfiguration -{ - - private ProfileManager globalProfileManager; - - private ArtifactRepository localRepository; - - private Properties userProperties; - - private Properties executionProperties = System.getProperties(); - - private Date buildStartTime; - - public DefaultProjectBuilderConfiguration() - { - } - - public ProjectBuilderConfiguration setGlobalProfileManager( ProfileManager globalProfileManager ) - { - this.globalProfileManager = globalProfileManager; - return this; - } - - public ProfileManager getGlobalProfileManager() - { - return globalProfileManager; - } - - public ProjectBuilderConfiguration setLocalRepository( ArtifactRepository localRepository ) - { - this.localRepository = localRepository; - return this; - } - - public ArtifactRepository getLocalRepository() - { - return localRepository; - } - - public ProjectBuilderConfiguration setUserProperties( Properties userProperties ) - { - this.userProperties = userProperties; - return this; - } - - public Properties getUserProperties() - { - if ( userProperties == null ) - { - userProperties = new Properties(); - } - - return userProperties; - } - - public Properties getExecutionProperties() - { - return executionProperties; - } - - public ProjectBuilderConfiguration setExecutionProperties( Properties executionProperties ) - { - this.executionProperties = executionProperties; - return this; - } - - public Date getBuildStartTime() - { - return buildStartTime; - } - - public ProjectBuilderConfiguration setBuildStartTime( Date buildStartTime ) - { - this.buildStartTime = buildStartTime; - return this; - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/InvalidProjectModelException.java b/maven-compat/src/main/java/org/apache/maven/project/InvalidProjectModelException.java deleted file mode 100644 index d7241fdc36be..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/InvalidProjectModelException.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.apache.maven.project; - -/* - * 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.validation.ModelValidationResult; - -/** - * InvalidProjectModelException - */ -@Deprecated -public class InvalidProjectModelException - extends ProjectBuildingException -{ - private ModelValidationResult validationResult; - - public InvalidProjectModelException( String projectId, String message, File pomLocation ) - { - super( projectId, message, pomLocation ); - } - - /** - * @param projectId - * @param pomLocation absolute path of the pom file - * @param message - * @param validationResult - * @deprecated use {@link File} constructor for pomLocation - */ - public InvalidProjectModelException( String projectId, String pomLocation, String message, - ModelValidationResult validationResult ) - { - this( projectId, message, new File( pomLocation ), validationResult ); - } - - public InvalidProjectModelException( String projectId, String message, File pomFile, - ModelValidationResult validationResult ) - { - super( projectId, message, pomFile ); - - this.validationResult = validationResult; - } - - /** - * @param projectId - * @param pomLocation absolute path of the pom file - * @param message - * @deprecated use {@link File} constructor for pomLocation - */ - public InvalidProjectModelException( String projectId, String pomLocation, String message ) - { - this( projectId, message, new File( pomLocation ) ); - } - - public final ModelValidationResult getValidationResult() - { - return validationResult; - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/MavenProjectBuilder.java b/maven-compat/src/main/java/org/apache/maven/project/MavenProjectBuilder.java deleted file mode 100644 index df97948149df..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/MavenProjectBuilder.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.apache.maven.project; - -/* - * 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.List; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.apache.maven.profiles.ProfileManager; -import org.apache.maven.wagon.events.TransferListener; - -/** - * @deprecated use {@link ProjectBuilder} instead - */ -@Deprecated -public interface MavenProjectBuilder -{ - - MavenProject build( File pom, ProjectBuilderConfiguration configuration ) - throws ProjectBuildingException; - - //TODO maven-site-plugin -- not used by the plugin directly, but used by Doxia Integration Tool & MPIR - // see DOXIASITETOOLS-167 & MPIR-349 - MavenProject build( File pom, ArtifactRepository localRepository, ProfileManager profileManager ) - throws ProjectBuildingException; - - //TODO remote-resources-plugin - MavenProject buildFromRepository( Artifact artifact, List remoteRepositories, - ArtifactRepository localRepository ) - throws ProjectBuildingException; - - //TODO remote-resources-plugin - MavenProject buildFromRepository( Artifact artifact, List remoteRepositories, - ArtifactRepository localRepository, boolean allowStubModel ) - throws ProjectBuildingException; - - // TODO this is only to provide a project for plugins that don't need a project to execute but need some - // of the values from a MavenProject. Ideally this should be something internal and nothing outside Maven - // would ever need this so it should not be exposed in a public API - MavenProject buildStandaloneSuperProject( ProjectBuilderConfiguration configuration ) - throws ProjectBuildingException; - - MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository ) - throws ProjectBuildingException; - - MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository, ProfileManager profileManager ) - throws ProjectBuildingException; - - MavenProject buildWithDependencies( File pom, ArtifactRepository localRepository, - ProfileManager globalProfileManager, TransferListener transferListener ) - throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException; - - MavenProject buildWithDependencies( File pom, ArtifactRepository localRepository, - ProfileManager globalProfileManager ) - throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException; - -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/MissingRepositoryElementException.java b/maven-compat/src/main/java/org/apache/maven/project/MissingRepositoryElementException.java deleted file mode 100644 index 75384e1515a9..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/MissingRepositoryElementException.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.maven.project; - -/* - * 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.artifact.InvalidRepositoryException; -/** - * Error constructing an artifact repository. - */ -public class MissingRepositoryElementException - extends InvalidRepositoryException -{ - - public MissingRepositoryElementException( String message, String repositoryId ) - { - super( message, repositoryId ); - } - - public MissingRepositoryElementException( String message ) - { - super( message, "-unknown-" ); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/ModelUtils.java b/maven-compat/src/main/java/org/apache/maven/project/ModelUtils.java deleted file mode 100644 index a428da03f9bc..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/ModelUtils.java +++ /dev/null @@ -1,364 +0,0 @@ -package org.apache.maven.project; - -/* - * 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.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import org.apache.maven.model.Dependency; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginContainer; -import org.apache.maven.model.PluginExecution; -import org.apache.maven.model.Repository; -import org.codehaus.plexus.util.xml.Xpp3Dom; - -/** @deprecated */ -@Deprecated -public final class ModelUtils -{ - - /** - * This should be the resulting ordering of plugins after merging: - *

- * Given: - *

-     * parent: X -> A -> B -> D -> E
-     * child: Y -> A -> C -> D -> F
-     * 
- * Result: - *
-     * X -> Y -> A -> B -> C -> D -> E -> F
-     * 
- */ - public static void mergePluginLists( PluginContainer childContainer, PluginContainer parentContainer, - boolean handleAsInheritance ) - { - if ( ( childContainer == null ) || ( parentContainer == null ) ) - { - // nothing to do. - return; - } - - List parentPlugins = parentContainer.getPlugins(); - - if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() ) - { - parentPlugins = new ArrayList<>( parentPlugins ); - - // If we're processing this merge as an inheritance, we have to build up a list of - // plugins that were considered for inheritance. - if ( handleAsInheritance ) - { - for ( Iterator it = parentPlugins.iterator(); it.hasNext(); ) - { - Plugin plugin = it.next(); - - String inherited = plugin.getInherited(); - - if ( ( inherited != null ) && !Boolean.parseBoolean( inherited ) ) - { - it.remove(); - } - } - } - - List assembledPlugins = new ArrayList<>(); - - Map childPlugins = childContainer.getPluginsAsMap(); - - for ( Plugin parentPlugin : parentPlugins ) - { - String parentInherited = parentPlugin.getInherited(); - - // only merge plugin definition from the parent if at least one - // of these is true: - // 1. we're not processing the plugins in an inheritance-based merge - // 2. the parent's flag is not set - // 3. the parent's flag is set to true - if ( !handleAsInheritance || ( parentInherited == null ) - || Boolean.parseBoolean( parentInherited ) ) - { - Plugin childPlugin = childPlugins.get( parentPlugin.getKey() ); - - if ( ( childPlugin != null ) && !assembledPlugins.contains( childPlugin ) ) - { - Plugin assembledPlugin = childPlugin; - - mergePluginDefinitions( childPlugin, parentPlugin, handleAsInheritance ); - - // fix for MNG-2221 (assembly cache was not being populated for later reference): - assembledPlugins.add( assembledPlugin ); - } - - // if we're processing this as an inheritance-based merge, and - // the parent's flag is not set, then we need to - // clear the inherited flag in the merge result. - if ( handleAsInheritance && ( parentInherited == null ) ) - { - parentPlugin.unsetInheritanceApplied(); - } - } - - // very important to use the parentPlugins List, rather than parentContainer.getPlugins() - // since this list is a local one, and may have been modified during processing. - List results = - ModelUtils.orderAfterMerge( assembledPlugins, parentPlugins, childContainer.getPlugins() ); - - childContainer.setPlugins( results ); - - childContainer.flushPluginMap(); - } - } - } - - public static List orderAfterMerge( List merged, List highPrioritySource, - List lowPrioritySource ) - { - List results = new ArrayList<>(); - - if ( !merged.isEmpty() ) - { - results.addAll( merged ); - } - - List missingFromResults = new ArrayList<>(); - - List> sources = new ArrayList<>(); - - sources.add( highPrioritySource ); - sources.add( lowPrioritySource ); - - for ( List source : sources ) - { - for ( Plugin item : source ) - { - if ( results.contains( item ) ) - { - if ( !missingFromResults.isEmpty() ) - { - int idx = results.indexOf( item ); - - if ( idx < 0 ) - { - idx = 0; - } - - results.addAll( idx, missingFromResults ); - - missingFromResults.clear(); - } - } - else - { - missingFromResults.add( item ); - } - } - - if ( !missingFromResults.isEmpty() ) - { - results.addAll( missingFromResults ); - - missingFromResults.clear(); - } - } - - return results; - } - - - public static void mergePluginDefinitions( Plugin child, Plugin parent, boolean handleAsInheritance ) - { - if ( ( child == null ) || ( parent == null ) ) - { - // nothing to do. - return; - } - - if ( parent.isExtensions() ) - { - child.setExtensions( true ); - } - - if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) ) - { - child.setVersion( parent.getVersion() ); - } - - Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration(); - Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration(); - - childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration ); - - child.setConfiguration( childConfiguration ); - - child.setDependencies( mergeDependencyList( child.getDependencies(), parent.getDependencies() ) ); - - // from here to the end of the method is dealing with merging of the section. - String parentInherited = parent.getInherited(); - - boolean parentIsInherited = ( parentInherited == null ) || Boolean.parseBoolean( parentInherited ); - - List parentExecutions = parent.getExecutions(); - - if ( ( parentExecutions != null ) && !parentExecutions.isEmpty() ) - { - List mergedExecutions = new ArrayList<>(); - - Map assembledExecutions = new TreeMap<>(); - - Map childExecutions = child.getExecutionsAsMap(); - - for ( PluginExecution parentExecution : parentExecutions ) - { - String inherited = parentExecution.getInherited(); - - boolean parentExecInherited = - parentIsInherited && ( ( inherited == null ) || Boolean.parseBoolean( inherited ) ); - - if ( !handleAsInheritance || parentExecInherited ) - { - PluginExecution assembled = parentExecution; - - PluginExecution childExecution = childExecutions.get( parentExecution.getId() ); - - if ( childExecution != null ) - { - mergePluginExecutionDefinitions( childExecution, parentExecution ); - - assembled = childExecution; - } - else if ( handleAsInheritance && ( parentInherited == null ) ) - { - parentExecution.unsetInheritanceApplied(); - } - - assembledExecutions.put( assembled.getId(), assembled ); - mergedExecutions.add( assembled ); - } - } - - for ( PluginExecution childExecution : child.getExecutions() ) - { - if ( !assembledExecutions.containsKey( childExecution.getId() ) ) - { - mergedExecutions.add( childExecution ); - } - } - - child.setExecutions( mergedExecutions ); - - child.flushExecutionMap(); - } - - } - - private static void mergePluginExecutionDefinitions( PluginExecution child, PluginExecution parent ) - { - if ( child.getPhase() == null ) - { - child.setPhase( parent.getPhase() ); - } - - List parentGoals = parent.getGoals(); - List childGoals = child.getGoals(); - - List goals = new ArrayList<>(); - - if ( ( childGoals != null ) && !childGoals.isEmpty() ) - { - goals.addAll( childGoals ); - } - - if ( parentGoals != null ) - { - for ( String goal : parentGoals ) - { - if ( !goals.contains( goal ) ) - { - goals.add( goal ); - } - } - } - - child.setGoals( goals ); - - Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration(); - Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration(); - - childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration ); - - child.setConfiguration( childConfiguration ); - } - - public static List mergeRepositoryLists( List dominant, List recessive ) - { - - List repositories = new ArrayList<>( dominant ); - - for ( Repository repository : recessive ) - { - if ( !repositories.contains( repository ) ) - { - repositories.add( repository ); - } - } - - return repositories; - } - - public static void mergeFilterLists( List childFilters, List parentFilters ) - { - for ( String f : parentFilters ) - { - if ( !childFilters.contains( f ) ) - { - childFilters.add( f ); - } - } - } - - private static List mergeDependencyList( List child, List parent ) - { - Map depsMap = new LinkedHashMap<>(); - - if ( parent != null ) - { - for ( Dependency dependency : parent ) - { - depsMap.put( dependency.getManagementKey(), dependency ); - } - } - - if ( child != null ) - { - for ( Dependency dependency : child ) - { - depsMap.put( dependency.getManagementKey(), dependency ); - } - } - - return new ArrayList<>( depsMap.values() ); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java b/maven-compat/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java deleted file mode 100644 index ddfad3cb0b4b..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.apache.maven.project; - -/* - * 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.Date; -import java.util.Properties; - -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.profiles.ProfileManager; - -/** - * @deprecated use {@link ProjectBuildingRequest} instead - */ -@Deprecated -public interface ProjectBuilderConfiguration -{ - - ArtifactRepository getLocalRepository(); - - ProfileManager getGlobalProfileManager(); - - Properties getUserProperties(); - - Properties getExecutionProperties(); - - ProjectBuilderConfiguration setGlobalProfileManager( ProfileManager globalProfileManager ); - - ProjectBuilderConfiguration setLocalRepository( ArtifactRepository localRepository ); - - ProjectBuilderConfiguration setUserProperties( Properties userProperties ); - - ProjectBuilderConfiguration setExecutionProperties( Properties executionProperties ); - - Date getBuildStartTime(); - - ProjectBuilderConfiguration setBuildStartTime( Date buildStartTime ); - -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/ProjectUtils.java b/maven-compat/src/main/java/org/apache/maven/project/ProjectUtils.java deleted file mode 100644 index 21a4ac745a47..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/ProjectUtils.java +++ /dev/null @@ -1,118 +0,0 @@ -package org.apache.maven.project; - -/* - * 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.Arrays; -import java.util.List; - -import org.apache.maven.artifact.InvalidRepositoryException; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; -import org.apache.maven.model.DeploymentRepository; -import org.apache.maven.model.Repository; -import org.apache.maven.plugin.LegacySupport; -import org.apache.maven.repository.RepositorySystem; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.eclipse.aether.RepositorySystemSession; - -// This class needs to stick around because it was exposed the the remote resources plugin started using it instead of -// getting the repositories from the project. - -/** - * ProjectUtils - */ -@Deprecated -public final class ProjectUtils -{ - - private ProjectUtils() - { - } - - public static List buildArtifactRepositories( - List repositories, ArtifactRepositoryFactory artifactRepositoryFactory, PlexusContainer c ) - throws InvalidRepositoryException - { - - List remoteRepositories = new ArrayList<>(); - - for ( Repository r : repositories ) - { - remoteRepositories.add( buildArtifactRepository( r, artifactRepositoryFactory, c ) ); - } - - return remoteRepositories; - } - - public static ArtifactRepository buildDeploymentArtifactRepository( - DeploymentRepository repo, ArtifactRepositoryFactory artifactRepositoryFactory, PlexusContainer c ) - throws InvalidRepositoryException - { - return buildArtifactRepository( repo, artifactRepositoryFactory, c ); - } - - public static ArtifactRepository buildArtifactRepository( - Repository repo, ArtifactRepositoryFactory artifactRepositoryFactory, PlexusContainer c ) - throws InvalidRepositoryException - { - RepositorySystem repositorySystem = rs( c ); - RepositorySystemSession session = rss( c ); - - ArtifactRepository repository = repositorySystem.buildArtifactRepository( repo ); - - if ( session != null ) - { - repositorySystem.injectMirror( session, Arrays.asList( repository ) ); - repositorySystem.injectProxy( session, Arrays.asList( repository ) ); - repositorySystem.injectAuthentication( session, Arrays.asList( repository ) ); - } - - return repository; - } - - private static RepositorySystem rs( PlexusContainer c ) - { - try - { - return c.lookup( RepositorySystem.class ); - } - catch ( ComponentLookupException e ) - { - throw new IllegalStateException( e ); - } - } - - private static RepositorySystemSession rss( PlexusContainer c ) - { - try - { - LegacySupport legacySupport = c.lookup( LegacySupport.class ); - - return legacySupport.getRepositorySession(); - } - catch ( ComponentLookupException e ) - { - throw new IllegalStateException( e ); - } - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java b/maven-compat/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java deleted file mode 100644 index 0113562cff29..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java +++ /dev/null @@ -1,747 +0,0 @@ -package org.apache.maven.project.inheritance; - -/* - * 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.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.StringTokenizer; -import java.util.TreeMap; - -import org.apache.maven.model.Build; -import org.apache.maven.model.Dependency; -import org.apache.maven.model.DependencyManagement; -import org.apache.maven.model.DeploymentRepository; -import org.apache.maven.model.DistributionManagement; -import org.apache.maven.model.Extension; -import org.apache.maven.model.Model; -import org.apache.maven.model.PluginManagement; -import org.apache.maven.model.ReportPlugin; -import org.apache.maven.model.ReportSet; -import org.apache.maven.model.Reporting; -import org.apache.maven.model.Resource; -import org.apache.maven.model.Scm; -import org.apache.maven.model.Site; -import org.apache.maven.project.ModelUtils; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.util.StringUtils; -import org.codehaus.plexus.util.xml.Xpp3Dom; - -/** - * DefaultModelInheritanceAssembler - */ -@Component( role = ModelInheritanceAssembler.class ) -public class DefaultModelInheritanceAssembler - implements ModelInheritanceAssembler -{ - public void assembleBuildInheritance( Build childBuild, Build parentBuild, boolean handleAsInheritance ) - { - // The build has been set but we want to step in here and fill in - // values that have not been set by the child. - - if ( childBuild.getSourceDirectory() == null ) - { - childBuild.setSourceDirectory( parentBuild.getSourceDirectory() ); - } - - if ( childBuild.getScriptSourceDirectory() == null ) - { - childBuild.setScriptSourceDirectory( parentBuild.getScriptSourceDirectory() ); - } - - if ( childBuild.getTestSourceDirectory() == null ) - { - childBuild.setTestSourceDirectory( parentBuild.getTestSourceDirectory() ); - } - - if ( childBuild.getOutputDirectory() == null ) - { - childBuild.setOutputDirectory( parentBuild.getOutputDirectory() ); - } - - if ( childBuild.getTestOutputDirectory() == null ) - { - childBuild.setTestOutputDirectory( parentBuild.getTestOutputDirectory() ); - } - - // Extensions are accumulated - mergeExtensionLists( childBuild, parentBuild ); - - if ( childBuild.getDirectory() == null ) - { - childBuild.setDirectory( parentBuild.getDirectory() ); - } - - if ( childBuild.getDefaultGoal() == null ) - { - childBuild.setDefaultGoal( parentBuild.getDefaultGoal() ); - } - - if ( childBuild.getFinalName() == null ) - { - childBuild.setFinalName( parentBuild.getFinalName() ); - } - - ModelUtils.mergeFilterLists( childBuild.getFilters(), parentBuild.getFilters() ); - - List resources = childBuild.getResources(); - if ( ( resources == null ) || resources.isEmpty() ) - { - childBuild.setResources( parentBuild.getResources() ); - } - - resources = childBuild.getTestResources(); - if ( ( resources == null ) || resources.isEmpty() ) - { - childBuild.setTestResources( parentBuild.getTestResources() ); - } - - // Plugins are aggregated if Plugin.inherit != false - ModelUtils.mergePluginLists( childBuild, parentBuild, handleAsInheritance ); - - // Plugin management :: aggregate - PluginManagement dominantPM = childBuild.getPluginManagement(); - PluginManagement recessivePM = parentBuild.getPluginManagement(); - - if ( ( dominantPM == null ) && ( recessivePM != null ) ) - { - // FIXME: Filter out the inherited == false stuff! - childBuild.setPluginManagement( recessivePM ); - } - else - { - ModelUtils.mergePluginLists( childBuild.getPluginManagement(), parentBuild.getPluginManagement(), false ); - } - } - - private void assembleScmInheritance( Model child, Model parent, String childPathAdjustment, boolean appendPaths ) - { - if ( parent.getScm() != null ) - { - Scm parentScm = parent.getScm(); - - Scm childScm = child.getScm(); - - if ( childScm == null ) - { - childScm = new Scm(); - - child.setScm( childScm ); - } - - if ( StringUtils.isEmpty( childScm.getConnection() ) && !StringUtils.isEmpty( parentScm.getConnection() ) ) - { - childScm.setConnection( - appendPath( parentScm.getConnection(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); - } - - if ( StringUtils.isEmpty( childScm.getDeveloperConnection() ) - && !StringUtils.isEmpty( parentScm.getDeveloperConnection() ) ) - { - childScm - .setDeveloperConnection( appendPath( parentScm.getDeveloperConnection(), child.getArtifactId(), - childPathAdjustment, appendPaths ) ); - } - - if ( StringUtils.isEmpty( childScm.getUrl() ) && !StringUtils.isEmpty( parentScm.getUrl() ) ) - { - childScm.setUrl( - appendPath( parentScm.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); - } - } - } - - public void copyModel( Model dest, Model source ) - { - assembleModelInheritance( dest, source, null, false ); - } - - public void assembleModelInheritance( Model child, Model parent, String childPathAdjustment ) - { - assembleModelInheritance( child, parent, childPathAdjustment, true ); - } - - public void assembleModelInheritance( Model child, Model parent ) - { - assembleModelInheritance( child, parent, null, true ); - } - - private void assembleModelInheritance( Model child, Model parent, String childPathAdjustment, boolean appendPaths ) - { - // cannot inherit from null parent. - if ( parent == null ) - { - return; - } - - // Group id - if ( child.getGroupId() == null ) - { - child.setGroupId( parent.getGroupId() ); - } - - // version - if ( child.getVersion() == null ) - { - // The parent version may have resolved to something different, so we take what we asked for... - // instead of - child.setVersion( parent.getVersion() ); - - if ( child.getParent() != null ) - { - child.setVersion( child.getParent().getVersion() ); - } - } - - // inceptionYear - if ( child.getInceptionYear() == null ) - { - child.setInceptionYear( parent.getInceptionYear() ); - } - - // url - if ( child.getUrl() == null ) - { - if ( parent.getUrl() != null ) - { - child.setUrl( appendPath( parent.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); - } - else - { - child.setUrl( parent.getUrl() ); - } - } - - assembleDistributionInheritance( child, parent, childPathAdjustment, appendPaths ); - - // issueManagement - if ( child.getIssueManagement() == null ) - { - child.setIssueManagement( parent.getIssueManagement() ); - } - - // description - if ( child.getDescription() == null ) - { - child.setDescription( parent.getDescription() ); - } - - // Organization - if ( child.getOrganization() == null ) - { - child.setOrganization( parent.getOrganization() ); - } - - // Scm - assembleScmInheritance( child, parent, childPathAdjustment, appendPaths ); - - // ciManagement - if ( child.getCiManagement() == null ) - { - child.setCiManagement( parent.getCiManagement() ); - } - - // developers - if ( child.getDevelopers().size() == 0 ) - { - child.setDevelopers( parent.getDevelopers() ); - } - - // licenses - if ( child.getLicenses().size() == 0 ) - { - child.setLicenses( parent.getLicenses() ); - } - - // developers - if ( child.getContributors().size() == 0 ) - { - child.setContributors( parent.getContributors() ); - } - - // mailingLists - if ( child.getMailingLists().size() == 0 ) - { - child.setMailingLists( parent.getMailingLists() ); - } - - // Build - assembleBuildInheritance( child, parent ); - - assembleDependencyInheritance( child, parent ); - - child.setRepositories( ModelUtils.mergeRepositoryLists( child.getRepositories(), parent.getRepositories() ) ); -// child.setPluginRepositories( -// ModelUtils.mergeRepositoryLists( child.getPluginRepositories(), parent.getPluginRepositories() ) ); - - assembleReportingInheritance( child, parent ); - - assembleDependencyManagementInheritance( child, parent ); - - Properties props = new Properties(); - props.putAll( parent.getProperties() ); - props.putAll( child.getProperties() ); - - child.setProperties( props ); - } - - private void assembleDependencyManagementInheritance( Model child, Model parent ) - { - DependencyManagement parentDepMgmt = parent.getDependencyManagement(); - - DependencyManagement childDepMgmt = child.getDependencyManagement(); - - if ( parentDepMgmt != null ) - { - if ( childDepMgmt == null ) - { - child.setDependencyManagement( parentDepMgmt ); - } - else - { - List childDeps = childDepMgmt.getDependencies(); - - Map mappedChildDeps = new TreeMap<>(); - for ( Dependency dep : childDeps ) - { - mappedChildDeps.put( dep.getManagementKey(), dep ); - } - - for ( Dependency dep : parentDepMgmt.getDependencies() ) - { - if ( !mappedChildDeps.containsKey( dep.getManagementKey() ) ) - { - childDepMgmt.addDependency( dep ); - } - } - } - } - } - - private void assembleReportingInheritance( Model child, Model parent ) - { - // Reports :: aggregate - Reporting childReporting = child.getReporting(); - Reporting parentReporting = parent.getReporting(); - - if ( parentReporting != null ) - { - if ( childReporting == null ) - { - childReporting = new Reporting(); - child.setReporting( childReporting ); - } - - childReporting.setExcludeDefaults( parentReporting.isExcludeDefaults() ); - - if ( StringUtils.isEmpty( childReporting.getOutputDirectory() ) ) - { - childReporting.setOutputDirectory( parentReporting.getOutputDirectory() ); - } - - mergeReportPluginLists( childReporting, parentReporting, true ); - } - } - - private static void mergeReportPluginLists( Reporting child, Reporting parent, boolean handleAsInheritance ) - { - if ( ( child == null ) || ( parent == null ) ) - { - // nothing to do. - return; - } - - List parentPlugins = parent.getPlugins(); - - if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() ) - { - Map assembledPlugins = new TreeMap<>(); - - Map childPlugins = child.getReportPluginsAsMap(); - - for ( ReportPlugin parentPlugin : parentPlugins ) - { - String parentInherited = parentPlugin.getInherited(); - - if ( !handleAsInheritance || ( parentInherited == null ) || Boolean.parseBoolean( parentInherited ) ) - { - - ReportPlugin assembledPlugin = parentPlugin; - - ReportPlugin childPlugin = childPlugins.get( parentPlugin.getKey() ); - - if ( childPlugin != null ) - { - assembledPlugin = childPlugin; - - mergeReportPluginDefinitions( childPlugin, parentPlugin, handleAsInheritance ); - } - - if ( handleAsInheritance && ( parentInherited == null ) ) - { - assembledPlugin.unsetInheritanceApplied(); - } - - assembledPlugins.put( assembledPlugin.getKey(), assembledPlugin ); - } - } - - for ( ReportPlugin childPlugin : childPlugins.values() ) - { - if ( !assembledPlugins.containsKey( childPlugin.getKey() ) ) - { - assembledPlugins.put( childPlugin.getKey(), childPlugin ); - } - } - - child.setPlugins( new ArrayList<>( assembledPlugins.values() ) ); - - child.flushReportPluginMap(); - } - } - - private static void mergeReportSetDefinitions( ReportSet child, ReportSet parent ) - { - List parentReports = parent.getReports(); - List childReports = child.getReports(); - - List reports = new ArrayList<>(); - - if ( ( childReports != null ) && !childReports.isEmpty() ) - { - reports.addAll( childReports ); - } - - if ( parentReports != null ) - { - for ( String report : parentReports ) - { - if ( !reports.contains( report ) ) - { - reports.add( report ); - } - } - } - - child.setReports( reports ); - - Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration(); - Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration(); - - childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration ); - - child.setConfiguration( childConfiguration ); - } - - - public static void mergeReportPluginDefinitions( ReportPlugin child, ReportPlugin parent, - boolean handleAsInheritance ) - { - if ( ( child == null ) || ( parent == null ) ) - { - // nothing to do. - return; - } - - if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) ) - { - child.setVersion( parent.getVersion() ); - } - - // from here to the end of the method is dealing with merging of the section. - String parentInherited = parent.getInherited(); - - boolean parentIsInherited = ( parentInherited == null ) || Boolean.parseBoolean( parentInherited ); - - List parentReportSets = parent.getReportSets(); - - if ( ( parentReportSets != null ) && !parentReportSets.isEmpty() ) - { - Map assembledReportSets = new TreeMap<>(); - - Map childReportSets = child.getReportSetsAsMap(); - - for ( Object parentReportSet1 : parentReportSets ) - { - ReportSet parentReportSet = (ReportSet) parentReportSet1; - - if ( !handleAsInheritance || parentIsInherited ) - { - ReportSet assembledReportSet = parentReportSet; - - ReportSet childReportSet = childReportSets.get( parentReportSet.getId() ); - - if ( childReportSet != null ) - { - mergeReportSetDefinitions( childReportSet, parentReportSet ); - - assembledReportSet = childReportSet; - } - else if ( handleAsInheritance && ( parentInherited == null ) ) - { - parentReportSet.unsetInheritanceApplied(); - } - - assembledReportSets.put( assembledReportSet.getId(), assembledReportSet ); - } - } - - for ( Map.Entry entry : childReportSets.entrySet() ) - { - String id = entry.getKey(); - - if ( !assembledReportSets.containsKey( id ) ) - { - assembledReportSets.put( id, entry.getValue() ); - } - } - - child.setReportSets( new ArrayList<>( assembledReportSets.values() ) ); - - child.flushReportSetMap(); - } - - } - - private void assembleDependencyInheritance( Model child, Model parent ) - { - Map depsMap = new LinkedHashMap<>(); - - List deps = parent.getDependencies(); - - if ( deps != null ) - { - for ( Dependency dependency : deps ) - { - depsMap.put( dependency.getManagementKey(), dependency ); - } - } - - deps = child.getDependencies(); - - if ( deps != null ) - { - for ( Dependency dependency : deps ) - { - depsMap.put( dependency.getManagementKey(), dependency ); - } - } - - child.setDependencies( new ArrayList<>( depsMap.values() ) ); - } - - private void assembleBuildInheritance( Model child, Model parent ) - { - Build childBuild = child.getBuild(); - Build parentBuild = parent.getBuild(); - - if ( parentBuild != null ) - { - if ( childBuild == null ) - { - childBuild = new Build(); - child.setBuild( childBuild ); - } - - assembleBuildInheritance( childBuild, parentBuild, true ); - } - } - - private void assembleDistributionInheritance( Model child, Model parent, String childPathAdjustment, - boolean appendPaths ) - { - if ( parent.getDistributionManagement() != null ) - { - DistributionManagement parentDistMgmt = parent.getDistributionManagement(); - - DistributionManagement childDistMgmt = child.getDistributionManagement(); - - if ( childDistMgmt == null ) - { - childDistMgmt = new DistributionManagement(); - - child.setDistributionManagement( childDistMgmt ); - } - - if ( childDistMgmt.getSite() == null ) - { - if ( parentDistMgmt.getSite() != null ) - { - Site site = new Site(); - - childDistMgmt.setSite( site ); - - site.setId( parentDistMgmt.getSite().getId() ); - - site.setName( parentDistMgmt.getSite().getName() ); - - site.setUrl( parentDistMgmt.getSite().getUrl() ); - - if ( site.getUrl() != null ) - { - site.setUrl( - appendPath( site.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); - } - } - } - - if ( childDistMgmt.getRepository() == null ) - { - if ( parentDistMgmt.getRepository() != null ) - { - DeploymentRepository repository = copyDistributionRepository( parentDistMgmt.getRepository() ); - childDistMgmt.setRepository( repository ); - } - } - - if ( childDistMgmt.getSnapshotRepository() == null ) - { - if ( parentDistMgmt.getSnapshotRepository() != null ) - { - DeploymentRepository repository = - copyDistributionRepository( parentDistMgmt.getSnapshotRepository() ); - childDistMgmt.setSnapshotRepository( repository ); - } - } - - if ( StringUtils.isEmpty( childDistMgmt.getDownloadUrl() ) ) - { - childDistMgmt.setDownloadUrl( parentDistMgmt.getDownloadUrl() ); - } - - // NOTE: We SHOULD NOT be inheriting status, since this is an assessment of the POM quality. - // NOTE: We SHOULD NOT be inheriting relocation, since this relates to a single POM - } - } - - private static DeploymentRepository copyDistributionRepository( DeploymentRepository parentRepository ) - { - DeploymentRepository repository = new DeploymentRepository(); - - repository.setId( parentRepository.getId() ); - - repository.setName( parentRepository.getName() ); - - repository.setUrl( parentRepository.getUrl() ); - - repository.setLayout( parentRepository.getLayout() ); - - repository.setUniqueVersion( parentRepository.isUniqueVersion() ); - - return repository; - } - - // TODO This should eventually be migrated to DefaultPathTranslator. - protected String appendPath( String parentPath, String childPath, String pathAdjustment, boolean appendPaths ) - { - String uncleanPath = parentPath; - - if ( appendPaths ) - { - if ( pathAdjustment != null ) - { - uncleanPath += "/" + pathAdjustment; - } - - if ( childPath != null ) - { - uncleanPath += "/" + childPath; - } - } - - String cleanedPath = ""; - - int protocolIdx = uncleanPath.indexOf( "://" ); - - if ( protocolIdx > -1 ) - { - cleanedPath = uncleanPath.substring( 0, protocolIdx + 3 ); - uncleanPath = uncleanPath.substring( protocolIdx + 3 ); - } - - if ( uncleanPath.startsWith( "/" ) ) - { - cleanedPath += "/"; - } - - return cleanedPath + resolvePath( uncleanPath ); - } - - // TODO Move this to plexus-utils' PathTool. - private static String resolvePath( String uncleanPath ) - { - LinkedList pathElements = new LinkedList<>(); - - StringTokenizer tokenizer = new StringTokenizer( uncleanPath, "/" ); - - while ( tokenizer.hasMoreTokens() ) - { - String token = tokenizer.nextToken(); - - switch ( token ) - { - case "": - // Empty path entry ("...//.."), remove. - break; - case "..": - if ( pathElements.isEmpty() ) - { - // FIXME: somehow report to the user - // that there are too many '..' elements. - // For now, ignore the extra '..'. - } - else - { - pathElements.removeLast(); - } - break; - default: - pathElements.addLast( token ); - break; - } - } - - StringBuilder cleanedPath = new StringBuilder(); - - while ( !pathElements.isEmpty() ) - { - cleanedPath.append( pathElements.removeFirst() ); - if ( !pathElements.isEmpty() ) - { - cleanedPath.append( '/' ); - } - } - - return cleanedPath.toString(); - } - - private static void mergeExtensionLists( Build childBuild, Build parentBuild ) - { - for ( Extension e : parentBuild.getExtensions() ) - { - if ( !childBuild.getExtensions().contains( e ) ) - { - childBuild.addExtension( e ); - } - } - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceAssembler.java b/maven-compat/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceAssembler.java deleted file mode 100644 index bf8a63b4e430..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceAssembler.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.apache.maven.project.inheritance; - -/* - * 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.Build; -import org.apache.maven.model.Model; - -/** - * @author Jason van Zyl - * @deprecated - */ -@Deprecated -public interface ModelInheritanceAssembler -{ - String ROLE = ModelInheritanceAssembler.class.getName(); - - void assembleModelInheritance( Model child, Model parent, String childPathAdjustment ); - - void assembleModelInheritance( Model child, Model parent ); - - void assembleBuildInheritance( Build childBuild, Build parentBuild, boolean handleAsInheritance ); - - void copyModel( Model dest, Model source ); -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/interpolation/AbstractStringBasedModelInterpolator.java b/maven-compat/src/main/java/org/apache/maven/project/interpolation/AbstractStringBasedModelInterpolator.java deleted file mode 100644 index 996baef590ab..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/interpolation/AbstractStringBasedModelInterpolator.java +++ /dev/null @@ -1,406 +0,0 @@ -package org.apache.maven.project.interpolation; - -/* - * 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.apache.maven.model.io.xpp3.MavenXpp3Reader; -import org.apache.maven.model.io.xpp3.MavenXpp3Writer; -import org.apache.maven.project.DefaultProjectBuilderConfiguration; -import org.apache.maven.project.ProjectBuilderConfiguration; -import org.apache.maven.project.path.PathTranslator; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.interpolation.AbstractValueSource; -import org.codehaus.plexus.interpolation.InterpolationException; -import org.codehaus.plexus.interpolation.InterpolationPostProcessor; -import org.codehaus.plexus.interpolation.Interpolator; -import org.codehaus.plexus.interpolation.MapBasedValueSource; -import org.codehaus.plexus.interpolation.ObjectBasedValueSource; -import org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor; -import org.codehaus.plexus.interpolation.PrefixedObjectValueSource; -import org.codehaus.plexus.interpolation.PrefixedValueSourceWrapper; -import org.codehaus.plexus.interpolation.RecursionInterceptor; -import org.codehaus.plexus.interpolation.ValueSource; -import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - -import java.io.File; -import java.io.IOException; -import java.io.StringReader; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -/** - * Use a regular expression search to find and resolve expressions within the POM. - * - * @author jdcasey Created on Feb 3, 2005 - * TODO Consolidate this logic with the PluginParameterExpressionEvaluator, minus deprecations/bans. - */ -@Deprecated -public abstract class AbstractStringBasedModelInterpolator - extends AbstractLogEnabled - implements ModelInterpolator, Initializable -{ - - private static final List PROJECT_PREFIXES = Arrays.asList( "pom.", "project." ); - - private static final List TRANSLATED_PATH_EXPRESSIONS; - - static - { - List translatedPrefixes = new ArrayList<>(); - - // MNG-1927, MNG-2124, MNG-3355: - // If the build section is present and the project directory is non-null, we should make - // sure interpolation of the directories below uses translated paths. - // Afterward, we'll double back and translate any paths that weren't covered during interpolation via the - // code below... - translatedPrefixes.add( "build.directory" ); - translatedPrefixes.add( "build.outputDirectory" ); - translatedPrefixes.add( "build.testOutputDirectory" ); - translatedPrefixes.add( "build.sourceDirectory" ); - translatedPrefixes.add( "build.testSourceDirectory" ); - translatedPrefixes.add( "build.scriptSourceDirectory" ); - translatedPrefixes.add( "reporting.outputDirectory" ); - - TRANSLATED_PATH_EXPRESSIONS = translatedPrefixes; - } - - @Requirement - private PathTranslator pathTranslator; - - private Interpolator interpolator; - - private RecursionInterceptor recursionInterceptor; - - // for testing. - protected AbstractStringBasedModelInterpolator( PathTranslator pathTranslator ) - { - this.pathTranslator = pathTranslator; - } - - protected AbstractStringBasedModelInterpolator() - { - } - - public Model interpolate( Model model, Map context ) - throws ModelInterpolationException - { - return interpolate( model, context, true ); - } - - /** - * Serialize the inbound Model instance to a StringWriter, perform the regex replacement to resolve - * POM expressions, then re-parse into the resolved Model instance. - *

- * NOTE: This will result in a different instance of Model being returned!!! - * - * @param model The inbound Model instance, to serialize and reference for expression resolution - * @param context The other context map to be used during resolution - * - * @return The resolved instance of the inbound Model. This is a different instance! - * - * @deprecated Use {@link ModelInterpolator#interpolate(Model, File, ProjectBuilderConfiguration, boolean)} instead. - */ - public Model interpolate( Model model, Map context, boolean strict ) - throws ModelInterpolationException - { - Properties props = new Properties(); - props.putAll( context ); - - return interpolate( model, - null, - new DefaultProjectBuilderConfiguration().setExecutionProperties( props ), - true ); - } - - public Model interpolate( Model model, - File projectDir, - ProjectBuilderConfiguration config, - boolean debugEnabled ) - throws ModelInterpolationException - { - StringWriter sWriter = new StringWriter( 1024 ); - - MavenXpp3Writer writer = new MavenXpp3Writer(); - try - { - writer.write( sWriter, model ); - } - catch ( IOException e ) - { - throw new ModelInterpolationException( "Cannot serialize project model for interpolation.", e ); - } - - String serializedModel = sWriter.toString(); - serializedModel = interpolate( serializedModel, model, projectDir, config, debugEnabled ); - - StringReader sReader = new StringReader( serializedModel ); - - MavenXpp3Reader modelReader = new MavenXpp3Reader(); - try - { - model = modelReader.read( sReader ); - } - catch ( IOException | XmlPullParserException e ) - { - throw new ModelInterpolationException( - "Cannot read project model from interpolating filter of serialized version.", e ); - } - - return model; - } - - /** - * Interpolates all expressions in the src parameter. - *

- * The algorithm used for each expression is: - *

    - *
  • If it starts with either "pom." or "project.", the expression is evaluated against the model.
  • - *
  • If the value is null, get the value from the context.
  • - *
  • If the value is null, but the context contains the expression, don't replace the expression string - * with the value, and continue to find other expressions.
  • - *
  • If the value is null, get it from the model properties.
  • - *
- */ - public String interpolate( String src, - Model model, - final File projectDir, - ProjectBuilderConfiguration config, - boolean debug ) - throws ModelInterpolationException - { - try - { - List valueSources = createValueSources( model, projectDir, config ); - List postProcessors = createPostProcessors( model, projectDir, config ); - - return interpolateInternal( src, valueSources, postProcessors, debug ); - } - finally - { - interpolator.clearAnswers(); - } - } - - protected List createValueSources( final Model model, final File projectDir, - final ProjectBuilderConfiguration config ) - { - String timestampFormat = DEFAULT_BUILD_TIMESTAMP_FORMAT; - - Properties modelProperties = model.getProperties(); - if ( modelProperties != null ) - { - timestampFormat = modelProperties.getProperty( BUILD_TIMESTAMP_FORMAT_PROPERTY, timestampFormat ); - } - - ValueSource modelValueSource1 = new PrefixedObjectValueSource( PROJECT_PREFIXES, model, false ); - ValueSource modelValueSource2 = new ObjectBasedValueSource( model ); - - ValueSource basedirValueSource = new PrefixedValueSourceWrapper( new AbstractValueSource( false ) - { - - public Object getValue( String expression ) - { - if ( projectDir != null && "basedir".equals( expression ) ) - { - return projectDir.getAbsolutePath(); - } - return null; - } - - }, PROJECT_PREFIXES, true ); - ValueSource baseUriValueSource = new PrefixedValueSourceWrapper( new AbstractValueSource( false ) - { - - public Object getValue( String expression ) - { - if ( projectDir != null && "baseUri".equals( expression ) ) - { - return projectDir.getAbsoluteFile().toPath().toUri().toASCIIString(); - } - return null; - } - - }, PROJECT_PREFIXES, false ); - - List valueSources = new ArrayList<>( 9 ); - - // NOTE: Order counts here! - valueSources.add( basedirValueSource ); - valueSources.add( baseUriValueSource ); - valueSources.add( new BuildTimestampValueSource( config.getBuildStartTime(), timestampFormat ) ); - valueSources.add( modelValueSource1 ); - valueSources.add( new MapBasedValueSource( config.getUserProperties() ) ); - valueSources.add( new MapBasedValueSource( modelProperties ) ); - valueSources.add( new MapBasedValueSource( config.getExecutionProperties() ) ); - valueSources.add( new AbstractValueSource( false ) - { - - public Object getValue( String expression ) - { - return config.getExecutionProperties().getProperty( "env." + expression ); - } - - } ); - valueSources.add( modelValueSource2 ); - - return valueSources; - } - - protected List createPostProcessors( final Model model, final File projectDir, - final ProjectBuilderConfiguration config ) - { - return Collections.singletonList( - (InterpolationPostProcessor) new PathTranslatingPostProcessor( - PROJECT_PREFIXES, - TRANSLATED_PATH_EXPRESSIONS, - projectDir, - pathTranslator ) ); - - } - - @SuppressWarnings( "unchecked" ) - protected String interpolateInternal( String src, List valueSources, - List postProcessors, boolean debug ) - throws ModelInterpolationException - { - if ( !src.contains( "${" ) ) - { - return src; - } - - Logger logger = getLogger(); - - String result = src; - synchronized ( this ) - { - - for ( ValueSource vs : valueSources ) - { - interpolator.addValueSource( vs ); - } - - for ( InterpolationPostProcessor postProcessor : postProcessors ) - { - interpolator.addPostProcessor( postProcessor ); - } - - try - { - try - { - result = interpolator.interpolate( result, recursionInterceptor ); - } - catch ( InterpolationException e ) - { - throw new ModelInterpolationException( e.getMessage(), e ); - } - - if ( debug ) - { - List feedback = interpolator.getFeedback(); - if ( feedback != null && !feedback.isEmpty() ) - { - logger.debug( "Maven encountered the following problems during initial POM interpolation:" ); - - Object last = null; - for ( Object next : feedback ) - { - if ( next instanceof Throwable ) - { - if ( last == null ) - { - logger.debug( "", ( (Throwable) next ) ); - } - else - { - logger.debug( String.valueOf( last ), ( (Throwable) next ) ); - } - } - else - { - if ( last != null ) - { - logger.debug( String.valueOf( last ) ); - } - - last = next; - } - } - - if ( last != null ) - { - logger.debug( String.valueOf( last ) ); - } - } - } - - interpolator.clearFeedback(); - } - finally - { - for ( ValueSource vs : valueSources ) - { - interpolator.removeValuesSource( vs ); - } - - for ( InterpolationPostProcessor postProcessor : postProcessors ) - { - interpolator.removePostProcessor( postProcessor ); - } - } - } - - return result; - } - - protected RecursionInterceptor getRecursionInterceptor() - { - return recursionInterceptor; - } - - protected void setRecursionInterceptor( RecursionInterceptor recursionInterceptor ) - { - this.recursionInterceptor = recursionInterceptor; - } - - protected abstract Interpolator createInterpolator(); - - public void initialize() - throws InitializationException - { - interpolator = createInterpolator(); - recursionInterceptor = new PrefixAwareRecursionInterceptor( PROJECT_PREFIXES ); - } - - protected final Interpolator getInterpolator() - { - return interpolator; - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/interpolation/BuildTimestampValueSource.java b/maven-compat/src/main/java/org/apache/maven/project/interpolation/BuildTimestampValueSource.java deleted file mode 100644 index f6319fa66418..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/interpolation/BuildTimestampValueSource.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.apache.maven.project.interpolation; - -/* - * 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.text.SimpleDateFormat; -import java.util.Date; - -import org.codehaus.plexus.interpolation.AbstractValueSource; - -/** - * - */ -@Deprecated -public class BuildTimestampValueSource - extends AbstractValueSource -{ - - private final Date startTime; - - private final String format; - - private String formattedDate; - - public BuildTimestampValueSource( Date startTime, String format ) - { - super( false ); - this.startTime = startTime; - this.format = format; - } - - public Object getValue( String expression ) - { - if ( "build.timestamp".equals( expression ) || "maven.build.timestamp".equals( expression ) ) - { - if ( formattedDate == null && startTime != null ) - { - formattedDate = new SimpleDateFormat( format ).format( startTime ); - } - - return formattedDate; - } - - return null; - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/interpolation/ModelInterpolationException.java b/maven-compat/src/main/java/org/apache/maven/project/interpolation/ModelInterpolationException.java deleted file mode 100644 index ea60f1629961..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/interpolation/ModelInterpolationException.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.apache.maven.project.interpolation; - -/* - * 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. - */ - -/** - * @author jdcasey - */ -@SuppressWarnings( "serial" ) -@Deprecated -public class ModelInterpolationException - extends Exception -{ - private String expression; - - private String originalMessage; - - public ModelInterpolationException( String message ) - { - super( message ); - } - - public ModelInterpolationException( String message, Throwable cause ) - { - super( message, cause ); - } - - public ModelInterpolationException( String expression, String message, Throwable cause ) - { - super( "The POM expression: " + expression + " could not be evaluated. Reason: " + message, cause ); - - this.expression = expression; - this.originalMessage = message; - } - - public ModelInterpolationException( String expression, String message ) - { - super( "The POM expression: " + expression + " could not be evaluated. Reason: " + message ); - - this.expression = expression; - this.originalMessage = message; - } - - public String getExpression() - { - return expression; - } - - public String getOriginalMessage() - { - return originalMessage; - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/interpolation/ModelInterpolator.java b/maven-compat/src/main/java/org/apache/maven/project/interpolation/ModelInterpolator.java deleted file mode 100644 index 036e7f04811b..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/interpolation/ModelInterpolator.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.apache.maven.project.interpolation; - -/* - * 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.apache.maven.project.ProjectBuilderConfiguration; - -import java.io.File; -import java.util.Map; - -/** - * @author jdcasey - */ -@Deprecated -public interface ModelInterpolator -{ - String DEFAULT_BUILD_TIMESTAMP_FORMAT = "yyyyMMdd-HHmm"; - - String BUILD_TIMESTAMP_FORMAT_PROPERTY = "maven.build.timestamp.format"; - - String ROLE = ModelInterpolator.class.getName(); - - /** - * @deprecated Use {@link ModelInterpolator#interpolate(Model, File, ProjectBuilderConfiguration, boolean)} instead. - */ - Model interpolate( Model project, Map context ) - throws ModelInterpolationException; - - /** - * @deprecated Use {@link ModelInterpolator#interpolate(Model, File, ProjectBuilderConfiguration, boolean)} instead. - */ - Model interpolate( Model model, Map context, boolean strict ) - throws ModelInterpolationException; - - Model interpolate( Model model, - File projectDir, - ProjectBuilderConfiguration config, - boolean debugEnabled ) - throws ModelInterpolationException; - - String interpolate( String src, - Model model, - File projectDir, - ProjectBuilderConfiguration config, - boolean debugEnabled ) - throws ModelInterpolationException; -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/interpolation/PathTranslatingPostProcessor.java b/maven-compat/src/main/java/org/apache/maven/project/interpolation/PathTranslatingPostProcessor.java deleted file mode 100644 index da2ba0563274..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/interpolation/PathTranslatingPostProcessor.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.apache.maven.project.interpolation; - -/* - * 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.project.path.PathTranslator; -import org.codehaus.plexus.interpolation.InterpolationPostProcessor; -import org.codehaus.plexus.interpolation.util.ValueSourceUtils; - -import java.io.File; -import java.util.List; - -/** - * - */ -@Deprecated -public class PathTranslatingPostProcessor - implements InterpolationPostProcessor -{ - - private final List unprefixedPathKeys; - private final File projectDir; - private final PathTranslator pathTranslator; - private final List expressionPrefixes; - - public PathTranslatingPostProcessor( List expressionPrefixes, List unprefixedPathKeys, - File projectDir, PathTranslator pathTranslator ) - { - this.expressionPrefixes = expressionPrefixes; - this.unprefixedPathKeys = unprefixedPathKeys; - this.projectDir = projectDir; - this.pathTranslator = pathTranslator; - } - - public Object execute( String expression, - Object value ) - { - expression = ValueSourceUtils.trimPrefix( expression, expressionPrefixes, true ); - - if ( projectDir != null && value != null && unprefixedPathKeys.contains( expression ) ) - { - return pathTranslator.alignToBaseDirectory( String.valueOf( value ), projectDir ); - } - - return value; - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java b/maven-compat/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java deleted file mode 100644 index 78990ea76ed8..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.apache.maven.project.interpolation; - -/* - * 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.IOException; -import java.util.Properties; - -import org.apache.maven.project.path.PathTranslator; -import org.codehaus.plexus.interpolation.Interpolator; -import org.codehaus.plexus.interpolation.RegexBasedInterpolator; - -/** - * Use a regular expression search to find and resolve expressions within the POM. - * - * @author jdcasey Created on Feb 3, 2005 - * TODO Consolidate this logic with the PluginParameterExpressionEvaluator, minus deprecations/bans. - */ -@Deprecated -public class RegexBasedModelInterpolator - extends AbstractStringBasedModelInterpolator -{ - - public RegexBasedModelInterpolator() - throws IOException - { - } - - public RegexBasedModelInterpolator( PathTranslator pathTranslator ) - { - super( pathTranslator ); - } - - public RegexBasedModelInterpolator( Properties envars ) - { - } - - protected Interpolator createInterpolator() - { - return new RegexBasedInterpolator( true ); - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/interpolation/StringSearchModelInterpolator.java b/maven-compat/src/main/java/org/apache/maven/project/interpolation/StringSearchModelInterpolator.java deleted file mode 100644 index f137c6ef2ecf..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/interpolation/StringSearchModelInterpolator.java +++ /dev/null @@ -1,408 +0,0 @@ -package org.apache.maven.project.interpolation; - -/* - * 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.apache.maven.project.ProjectBuilderConfiguration; -import org.apache.maven.project.path.PathTranslator; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.interpolation.InterpolationPostProcessor; -import org.codehaus.plexus.interpolation.Interpolator; -import org.codehaus.plexus.interpolation.StringSearchInterpolator; -import org.codehaus.plexus.interpolation.ValueSource; -import org.codehaus.plexus.logging.Logger; - -import java.io.File; -import java.lang.reflect.Array; -import java.lang.reflect.Field; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.WeakHashMap; - -/** - * StringSearchModelInterpolator - */ -@Deprecated -@Component( role = ModelInterpolator.class ) -public class StringSearchModelInterpolator - extends AbstractStringBasedModelInterpolator -{ - - private static final Map, Field[]> FIELDS_BY_CLASS = new WeakHashMap<>(); - private static final Map, Boolean> PRIMITIVE_BY_CLASS = new WeakHashMap<>(); - - public StringSearchModelInterpolator() - { - } - - public StringSearchModelInterpolator( PathTranslator pathTranslator ) - { - super( pathTranslator ); - } - - public Model interpolate( Model model, File projectDir, ProjectBuilderConfiguration config, boolean debugEnabled ) - throws ModelInterpolationException - { - interpolateObject( model, model, projectDir, config, debugEnabled ); - - return model; - } - - protected void interpolateObject( Object obj, Model model, File projectDir, ProjectBuilderConfiguration config, - boolean debugEnabled ) - throws ModelInterpolationException - { - try - { - List valueSources = createValueSources( model, projectDir, config ); - List postProcessors = createPostProcessors( model, projectDir, config ); - - InterpolateObjectAction action = - new InterpolateObjectAction( obj, valueSources, postProcessors, debugEnabled, - this, getLogger() ); - - ModelInterpolationException error = AccessController.doPrivileged( action ); - - if ( error != null ) - { - throw error; - } - } - finally - { - getInterpolator().clearAnswers(); - } - } - - protected Interpolator createInterpolator() - { - StringSearchInterpolator interpolator = new StringSearchInterpolator(); - interpolator.setCacheAnswers( true ); - - return interpolator; - } - - private static final class InterpolateObjectAction implements PrivilegedAction - { - - private final boolean debugEnabled; - private final LinkedList interpolationTargets; - private final StringSearchModelInterpolator modelInterpolator; - private final Logger logger; - private final List valueSources; - private final List postProcessors; - - InterpolateObjectAction( Object target, List valueSources, - List postProcessors, boolean debugEnabled, - StringSearchModelInterpolator modelInterpolator, Logger logger ) - { - this.valueSources = valueSources; - this.postProcessors = postProcessors; - this.debugEnabled = debugEnabled; - - this.interpolationTargets = new LinkedList<>(); - interpolationTargets.add( target ); - - this.modelInterpolator = modelInterpolator; - this.logger = logger; - } - - public ModelInterpolationException run() - { - while ( !interpolationTargets.isEmpty() ) - { - Object obj = interpolationTargets.removeFirst(); - - try - { - traverseObjectWithParents( obj.getClass(), obj ); - } - catch ( ModelInterpolationException e ) - { - return e; - } - } - - return null; - } - - @SuppressWarnings( { "unchecked", "checkstyle:methodlength" } ) - private void traverseObjectWithParents( Class cls, Object target ) - throws ModelInterpolationException - { - if ( cls == null ) - { - return; - } - - - if ( cls.isArray() ) - { - evaluateArray( target ); - } - else if ( isQualifiedForInterpolation( cls ) ) - { - Field[] fields = FIELDS_BY_CLASS.get( cls ); - if ( fields == null ) - { - fields = cls.getDeclaredFields(); - FIELDS_BY_CLASS.put( cls, fields ); - } - - for ( Field field : fields ) - { - Class type = field.getType(); - if ( isQualifiedForInterpolation( field, type ) ) - { - boolean isAccessible = field.isAccessible(); - field.setAccessible( true ); - try - { - try - { - if ( String.class == type ) - { - String value = (String) field.get( target ); - if ( value != null ) - { - String interpolated = - modelInterpolator.interpolateInternal( value, valueSources, postProcessors, - debugEnabled ); - - if ( !interpolated.equals( value ) ) - { - field.set( target, interpolated ); - } - } - } - else if ( Collection.class.isAssignableFrom( type ) ) - { - Collection c = (Collection) field.get( target ); - if ( c != null && !c.isEmpty() ) - { - List originalValues = new ArrayList<>( c ); - try - { - c.clear(); - } - catch ( UnsupportedOperationException e ) - { - if ( debugEnabled && logger != null ) - { - logger.debug( "Skipping interpolation of field: " + field + " in: " - + cls.getName() - + "; it is an unmodifiable collection." ); - } - continue; - } - - for ( Object value : originalValues ) - { - if ( value != null ) - { - if ( String.class == value.getClass() ) - { - String interpolated = - modelInterpolator.interpolateInternal( (String) value, - valueSources, - postProcessors, - debugEnabled ); - - if ( !interpolated.equals( value ) ) - { - c.add( interpolated ); - } - else - { - c.add( value ); - } - } - else - { - c.add( value ); - if ( value.getClass().isArray() ) - { - evaluateArray( value ); - } - else - { - interpolationTargets.add( value ); - } - } - } - else - { - // add the null back in...not sure what else to do... - c.add( value ); - } - } - } - } - else if ( Map.class.isAssignableFrom( type ) ) - { - Map m = (Map) field.get( target ); - if ( m != null && !m.isEmpty() ) - { - for ( Map.Entry entry : m.entrySet() ) - { - Object value = entry.getValue(); - - if ( value != null ) - { - if ( String.class == value.getClass() ) - { - String interpolated = - modelInterpolator.interpolateInternal( (String) value, - valueSources, - postProcessors, - debugEnabled ); - - if ( !interpolated.equals( value ) ) - { - try - { - entry.setValue( interpolated ); - } - catch ( UnsupportedOperationException e ) - { - if ( debugEnabled && logger != null ) - { - logger.debug( - "Skipping interpolation of field: " + field - + " (key: " + entry.getKey() + ") in: " - + cls.getName() - + "; it is an unmodifiable collection." ); - } - } - } - } - else - { - if ( value.getClass().isArray() ) - { - evaluateArray( value ); - } - else - { - interpolationTargets.add( value ); - } - } - } - } - } - } - else - { - Object value = field.get( target ); - if ( value != null ) - { - if ( field.getType().isArray() ) - { - evaluateArray( value ); - } - else - { - interpolationTargets.add( value ); - } - } - } - } - catch ( IllegalArgumentException | IllegalAccessException e ) - { - throw new ModelInterpolationException( - "Failed to interpolate field: " + field + " on class: " + cls.getName(), e ); - } - } - finally - { - field.setAccessible( isAccessible ); - } - } - } - - traverseObjectWithParents( cls.getSuperclass(), target ); - } - } - - private boolean isQualifiedForInterpolation( Class cls ) - { - return !cls.getPackage().getName().startsWith( "java" ); - } - - private boolean isQualifiedForInterpolation( Field field, Class fieldType ) - { - if ( !PRIMITIVE_BY_CLASS.containsKey( fieldType ) ) - { - PRIMITIVE_BY_CLASS.put( fieldType, fieldType.isPrimitive() ); - } - - if ( PRIMITIVE_BY_CLASS.get( fieldType ) ) - { - return false; - } - -// if ( fieldType.isPrimitive() ) -// { -// return false; -// } - - if ( "parent".equals( field.getName() ) ) - { - return false; - } - - return true; - } - - private void evaluateArray( Object target ) - throws ModelInterpolationException - { - int len = Array.getLength( target ); - for ( int i = 0; i < len; i++ ) - { - Object value = Array.get( target, i ); - if ( value != null ) - { - if ( String.class == value.getClass() ) - { - String interpolated = - modelInterpolator.interpolateInternal( (String) value, valueSources, postProcessors, - debugEnabled ); - - if ( !interpolated.equals( value ) ) - { - Array.set( target, i, interpolated ); - } - } - else - { - interpolationTargets.add( value ); - } - } - } - } - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java b/maven-compat/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java deleted file mode 100644 index 79e1f410e1bb..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java +++ /dev/null @@ -1,260 +0,0 @@ -package org.apache.maven.project.path; - -/* - * 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.List; - -import org.apache.maven.model.Build; -import org.apache.maven.model.Model; -import org.apache.maven.model.Reporting; -import org.apache.maven.model.Resource; -import org.codehaus.plexus.component.annotations.Component; - -/** - * DefaultPathTranslator - */ -@Deprecated -@Component( role = PathTranslator.class ) -public class DefaultPathTranslator - implements PathTranslator -{ - private static final String[] BASEDIR_EXPRESSIONS = {"${basedir}", "${pom.basedir}", "${project.basedir}"}; - - public void alignToBaseDirectory( Model model, File basedir ) - { - if ( basedir == null ) - { - return; - } - - Build build = model.getBuild(); - - if ( build != null ) - { - build.setDirectory( alignToBaseDirectory( build.getDirectory(), basedir ) ); - - build.setSourceDirectory( alignToBaseDirectory( build.getSourceDirectory(), basedir ) ); - - build.setTestSourceDirectory( alignToBaseDirectory( build.getTestSourceDirectory(), basedir ) ); - - for ( Resource resource : build.getResources() ) - { - resource.setDirectory( alignToBaseDirectory( resource.getDirectory(), basedir ) ); - } - - for ( Resource resource : build.getTestResources() ) - { - resource.setDirectory( alignToBaseDirectory( resource.getDirectory(), basedir ) ); - } - - if ( build.getFilters() != null ) - { - List filters = new ArrayList<>(); - for ( String filter : build.getFilters() ) - { - filters.add( alignToBaseDirectory( filter, basedir ) ); - } - build.setFilters( filters ); - } - - build.setOutputDirectory( alignToBaseDirectory( build.getOutputDirectory(), basedir ) ); - - build.setTestOutputDirectory( alignToBaseDirectory( build.getTestOutputDirectory(), basedir ) ); - } - - Reporting reporting = model.getReporting(); - - if ( reporting != null ) - { - reporting.setOutputDirectory( alignToBaseDirectory( reporting.getOutputDirectory(), basedir ) ); - } - } - - public String alignToBaseDirectory( String path, File basedir ) - { - if ( basedir == null ) - { - return path; - } - - if ( path == null ) - { - return null; - } - - String s = stripBasedirToken( path ); - - File file = new File( s ); - if ( file.isAbsolute() ) - { - // path was already absolute, just normalize file separator and we're done - s = file.getPath(); - } - else if ( file.getPath().startsWith( File.separator ) ) - { - // drive-relative Windows path, don't align with project directory but with drive root - s = file.getAbsolutePath(); - } - else - { - // an ordinary relative path, align with project directory - s = new File( new File( basedir, s ).toURI().normalize() ).getAbsolutePath(); - } - - return s; - } - - private String stripBasedirToken( String s ) - { - if ( s != null ) - { - String basedirExpr = null; - for ( String expression : BASEDIR_EXPRESSIONS ) - { - if ( s.startsWith( expression ) ) - { - basedirExpr = expression; - break; - } - } - - if ( basedirExpr != null ) - { - if ( s.length() > basedirExpr.length() ) - { - // Take out basedir expression and the leading slash - s = chopLeadingFileSeparator( s.substring( basedirExpr.length() ) ); - } - else - { - s = "."; - } - } - } - - return s; - } - - /** - * Removes the leading directory separator from the specified filesystem path (if any). For platform-independent - * behavior, this method accepts both the forward slash and the backward slash as separator. - * - * @param path The filesystem path, may be null. - * @return The altered filesystem path or null if the input path was null. - */ - private String chopLeadingFileSeparator( String path ) - { - if ( path != null ) - { - if ( path.startsWith( "/" ) || path.startsWith( "\\" ) ) - { - path = path.substring( 1 ); - } - } - return path; - } - - public void unalignFromBaseDirectory( Model model, File basedir ) - { - if ( basedir == null ) - { - return; - } - - Build build = model.getBuild(); - - if ( build != null ) - { - build.setDirectory( unalignFromBaseDirectory( build.getDirectory(), basedir ) ); - - build.setSourceDirectory( unalignFromBaseDirectory( build.getSourceDirectory(), basedir ) ); - - build.setTestSourceDirectory( unalignFromBaseDirectory( build.getTestSourceDirectory(), basedir ) ); - - for ( Resource resource : build.getResources() ) - { - resource.setDirectory( unalignFromBaseDirectory( resource.getDirectory(), basedir ) ); - } - - for ( Resource resource : build.getTestResources() ) - { - resource.setDirectory( unalignFromBaseDirectory( resource.getDirectory(), basedir ) ); - } - - if ( build.getFilters() != null ) - { - List filters = new ArrayList<>(); - for ( String filter : build.getFilters() ) - { - filters.add( unalignFromBaseDirectory( filter, basedir ) ); - } - build.setFilters( filters ); - } - - build.setOutputDirectory( unalignFromBaseDirectory( build.getOutputDirectory(), basedir ) ); - - build.setTestOutputDirectory( unalignFromBaseDirectory( build.getTestOutputDirectory(), basedir ) ); - } - - Reporting reporting = model.getReporting(); - - if ( reporting != null ) - { - reporting.setOutputDirectory( unalignFromBaseDirectory( reporting.getOutputDirectory(), basedir ) ); - } - } - - public String unalignFromBaseDirectory( String path, File basedir ) - { - if ( basedir == null ) - { - return path; - } - - if ( path == null ) - { - return null; - } - - path = path.trim(); - - String base = basedir.getAbsolutePath(); - if ( path.startsWith( base ) ) - { - path = chopLeadingFileSeparator( path.substring( base.length() ) ); - } - - if ( path.length() <= 0 ) - { - path = "."; - } - - if ( !new File( path ).isAbsolute() ) - { - path = path.replace( '\\', '/' ); - } - - return path; - } - -} - diff --git a/maven-compat/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java b/maven-compat/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java deleted file mode 100644 index 6406b5844dbd..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.apache.maven.project.validation; - -/* - * 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.apache.maven.model.building.DefaultModelBuildingRequest; -import org.apache.maven.model.building.ModelBuildingRequest; -import org.apache.maven.model.building.ModelProblem; -import org.apache.maven.model.building.ModelProblemCollector; -import org.apache.maven.model.building.ModelProblemCollectorRequest; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; - -/** - * @author Trygve Laugstøl - */ -@Component( role = ModelValidator.class ) -@Deprecated -public class DefaultModelValidator - implements ModelValidator -{ - - @Requirement - private org.apache.maven.model.validation.ModelValidator modelValidator; - - public ModelValidationResult validate( Model model ) - { - ModelValidationResult result = new ModelValidationResult(); - - ModelBuildingRequest request = - new DefaultModelBuildingRequest().setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 ); - - SimpleModelProblemCollector problems = new SimpleModelProblemCollector( result ); - - modelValidator.validateEffectiveModel( model, request, problems ); - - return result; - } - - private static class SimpleModelProblemCollector - implements ModelProblemCollector - { - - ModelValidationResult result; - - SimpleModelProblemCollector( ModelValidationResult result ) - { - this.result = result; - } - - public void add( ModelProblemCollectorRequest req ) - { - if ( !ModelProblem.Severity.WARNING.equals( req.getSeverity() ) ) - { - result.addMessage( req.getMessage() ); - } - } - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/validation/ModelValidationResult.java b/maven-compat/src/main/java/org/apache/maven/project/validation/ModelValidationResult.java deleted file mode 100644 index 9e2966e92d94..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/validation/ModelValidationResult.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.apache.maven.project.validation; - -/* - * 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.Collections; -import java.util.List; - -/** - * @author Trygve Laugstøl - */ -public class ModelValidationResult -{ - - /** */ - private static final String LS = System.lineSeparator(); - - /** */ - private List messages; - - public ModelValidationResult() - { - messages = new ArrayList<>(); - } - - public int getMessageCount() - { - return messages.size(); - } - - public String getMessage( int i ) - { - return messages.get( i ); - } - - public List getMessages() - { - return Collections.unmodifiableList( messages ); - } - - public void addMessage( String message ) - { - messages.add( message ); - } - - public String toString() - { - return render( "" ); - } - - public String render( String indentation ) - { - if ( messages.size() == 0 ) - { - return indentation + "There were no validation errors."; - } - - StringBuilder message = new StringBuilder(); - -// if ( messages.size() == 1 ) -// { -// message.append( "There was 1 validation error: " ); -// } -// else -// { -// message.append( "There was " + messages.size() + " validation errors: " + LS ); -// } -// - for ( int i = 0; i < messages.size(); i++ ) - { - message.append( indentation ).append( '[' ).append( i ).append( "] " ).append( messages.get( i ) ).append( - LS ); - } - - return message.toString(); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/project/validation/ModelValidator.java b/maven-compat/src/main/java/org/apache/maven/project/validation/ModelValidator.java deleted file mode 100644 index 54fd04cad8bc..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/project/validation/ModelValidator.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.apache.maven.project.validation; - -/* - * 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; - -/** - * Checks the model for missing or invalid values. - * - * @author Trygve Laugstøl - */ -@Deprecated -public interface ModelValidator -{ - - String ROLE = ModelValidator.class.getName(); - - ModelValidationResult validate( Model model ); - -} diff --git a/maven-compat/src/main/java/org/apache/maven/reporting/MavenReportException.java b/maven-compat/src/main/java/org/apache/maven/reporting/MavenReportException.java deleted file mode 100644 index af27a84056b5..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/reporting/MavenReportException.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.apache.maven.reporting; - -/* - * 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. - */ - -/** - * An exception occurring during the execution of a Maven report. - * - * @author Brett Porter - * @author Emmanuel Venisse - */ -public class MavenReportException extends Exception -{ - public MavenReportException( String msg ) - { - super( msg ); - } - - public MavenReportException( String msg, Exception e ) - { - super( msg, e ); - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java b/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java deleted file mode 100644 index 5c176e69b3a2..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java +++ /dev/null @@ -1,247 +0,0 @@ -package org.apache.maven.repository; - -/* - * 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 java.net.URL; -import java.util.List; - -import org.apache.maven.RepositoryUtils; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.settings.Mirror; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.util.StringUtils; - -/** - * DefaultMirrorSelector - */ -@Component( role = MirrorSelector.class ) -public class DefaultMirrorSelector - implements MirrorSelector -{ - - private static final String WILDCARD = "*"; - - private static final String EXTERNAL_WILDCARD = "external:*"; - - private static final String EXTERNAL_HTTP_WILDCARD = "external:http:*"; - - public Mirror getMirror( ArtifactRepository repository, List mirrors ) - { - String repoId = repository.getId(); - - if ( repoId != null && mirrors != null ) - { - for ( Mirror mirror : mirrors ) - { - if ( repoId.equals( mirror.getMirrorOf() ) && matchesLayout( repository, mirror ) ) - { - return mirror; - } - } - - for ( Mirror mirror : mirrors ) - { - if ( matchPattern( repository, mirror.getMirrorOf() ) && matchesLayout( repository, mirror ) ) - { - return mirror; - } - } - } - - return null; - } - - /** - * This method checks if the pattern matches the originalRepository. Valid patterns: - *
    - *
  • {@code *} = everything,
  • - *
  • {@code external:*} = everything not on the localhost and not file based,
  • - *
  • {@code external:http:*} = any repository not on the localhost using HTTP,
  • - *
  • {@code repo,repo1} = {@code repo} or {@code repo1},
  • - *
  • {@code *,!repo1} = everything except {@code repo1}.
  • - *
- * - * @param originalRepository to compare for a match. - * @param pattern used for match. - * @return true if the repository is a match to this pattern. - */ - static boolean matchPattern( ArtifactRepository originalRepository, String pattern ) - { - boolean result = false; - String originalId = originalRepository.getId(); - - // simple checks first to short circuit processing below. - if ( WILDCARD.equals( pattern ) || pattern.equals( originalId ) ) - { - result = true; - } - else - { - // process the list - String[] repos = pattern.split( "," ); - for ( String repo : repos ) - { - repo = repo.trim(); - // see if this is a negative match - if ( repo.length() > 1 && repo.startsWith( "!" ) ) - { - if ( repo.substring( 1 ).equals( originalId ) ) - { - // explicitly exclude. Set result and stop processing. - result = false; - break; - } - } - // check for exact match - else if ( repo.equals( originalId ) ) - { - result = true; - break; - } - // check for external:* - else if ( EXTERNAL_WILDCARD.equals( repo ) && isExternalRepo( originalRepository ) ) - { - result = true; - // don't stop processing in case a future segment explicitly excludes this repo - } - // check for external:http:* - else if ( EXTERNAL_HTTP_WILDCARD.equals( repo ) && isExternalHttpRepo( originalRepository ) ) - { - result = true; - // don't stop processing in case a future segment explicitly excludes this repo - } - else if ( WILDCARD.equals( repo ) ) - { - result = true; - // don't stop processing in case a future segment explicitly excludes this repo - } - } - } - return result; - } - - /** - * Checks the URL to see if this repository refers to an external repository - * - * @param originalRepository - * @return true if external. - */ - static boolean isExternalRepo( ArtifactRepository originalRepository ) - { - try - { - URL url = new URL( originalRepository.getUrl() ); - return !( isLocal( url.getHost() ) || url.getProtocol().equals( "file" ) ); - } - catch ( MalformedURLException e ) - { - // bad url just skip it here. It should have been validated already, but the wagon lookup will deal with it - return false; - } - } - - private static boolean isLocal( String host ) - { - return "localhost".equals( host ) || "127.0.0.1".equals( host ); - } - - /** - * Checks the URL to see if this repository refers to a non-localhost repository using HTTP. - * - * @param originalRepository - * @return true if external. - */ - static boolean isExternalHttpRepo( ArtifactRepository originalRepository ) - { - try - { - URL url = new URL( originalRepository.getUrl() ); - return ( "http".equalsIgnoreCase( url.getProtocol() ) || "dav".equalsIgnoreCase( url.getProtocol() ) - || "dav:http".equalsIgnoreCase( url.getProtocol() ) - || "dav+http".equalsIgnoreCase( url.getProtocol() ) ) && !isLocal( url.getHost() ); - } - catch ( MalformedURLException e ) - { - // bad url just skip it here. It should have been validated already, but the wagon lookup will deal with it - return false; - } - } - - static boolean matchesLayout( ArtifactRepository repository, Mirror mirror ) - { - return matchesLayout( RepositoryUtils.getLayout( repository ), mirror.getMirrorOfLayouts() ); - } - - /** - * Checks whether the layouts configured for a mirror match with the layout of the repository. - * - * @param repoLayout The layout of the repository, may be {@code null}. - * @param mirrorLayout The layouts supported by the mirror, may be {@code null}. - * @return {@code true} if the layouts associated with the mirror match the layout of the original repository, - * {@code false} otherwise. - */ - static boolean matchesLayout( String repoLayout, String mirrorLayout ) - { - boolean result = false; - - // simple checks first to short circuit processing below. - if ( StringUtils.isEmpty( mirrorLayout ) || WILDCARD.equals( mirrorLayout ) ) - { - result = true; - } - else if ( mirrorLayout.equals( repoLayout ) ) - { - result = true; - } - else - { - // process the list - String[] layouts = mirrorLayout.split( "," ); - for ( String layout : layouts ) - { - // see if this is a negative match - if ( layout.length() > 1 && layout.startsWith( "!" ) ) - { - if ( layout.substring( 1 ).equals( repoLayout ) ) - { - // explicitly exclude. Set result and stop processing. - result = false; - break; - } - } - // check for exact match - else if ( layout.equals( repoLayout ) ) - { - result = true; - break; - } - else if ( WILDCARD.equals( layout ) ) - { - result = true; - // don't stop processing in case a future segment explicitly excludes this repo - } - } - } - - return result; - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/MavenArtifactMetadata.java b/maven-compat/src/main/java/org/apache/maven/repository/MavenArtifactMetadata.java deleted file mode 100644 index c507bf7027ba..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/MavenArtifactMetadata.java +++ /dev/null @@ -1,119 +0,0 @@ -package org.apache.maven.repository; - -/* - * 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. - */ - -/** - * - * - * @author Oleg Gusakov - * - */ -public class MavenArtifactMetadata -{ - public static final String DEFAULT_TYPE = "jar"; - - String groupId; - String artifactId; - String version; - String classifier; - String type; - String scope; - - transient Object datum; - - public String getGroupId() - { - return groupId; - } - - public void setGroupId( String groupId ) - { - this.groupId = groupId; - } - - public String getArtifactId() - { - return artifactId; - } - - public void setArtifactId( String artifactId ) - { - this.artifactId = artifactId; - } - - public String getVersion() - { - return version; - } - - public void setVersion( String version ) - { - this.version = version; - } - - public String getClassifier() - { - return classifier; - } - - public void setClassifier( String classifier ) - { - this.classifier = classifier; - } - - public String getType() - { - return type; - } - - public void setType( String type ) - { - this.type = type; - } - - public Object getDatum() - { - return datum; - } - - public void setDatum( Object datum ) - { - this.datum = datum; - } - - public String getScope() - { - return scope; - } - - public void setScope( String scope ) - { - this.scope = scope; - } - - @Override - public String toString() - { - return getGroupId() + ":" + getArtifactId() + ":" + getVersion() + ":" - + ( getClassifier() == null ? "" : getClassifier() ) + ":" - + ( getType() == null ? DEFAULT_TYPE : getType() ); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/MetadataGraph.java b/maven-compat/src/main/java/org/apache/maven/repository/MetadataGraph.java deleted file mode 100644 index 3568ff026051..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/MetadataGraph.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.apache.maven.repository; - -/* - * 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; - -/** - * This is the main graph data structure used by the RepositorySystem to present tree and graph objects. - * - * @author Oleg Gusakov - * - */ -public class MetadataGraph -{ - /** all graph nodes */ - Collection nodes; - - /** entry point for tree-like structures */ - MetadataGraphNode entry; - - public MetadataGraph( MetadataGraphNode entry ) - { - this(); - - this.entry = entry; - } - - public MetadataGraph() - { - nodes = new ArrayList<>( 64 ); - } - - public void addNode( MetadataGraphNode node ) - { - nodes.add( node ); - } - - /** - * find a node by the GAV (metadata) - * - * @param md - */ - public MetadataGraphNode findNode( MavenArtifactMetadata md ) - { - for ( MetadataGraphNode mgn : nodes ) - { - if ( mgn.metadata.equals( md ) ) - { - return mgn; - } - } - - MetadataGraphNode node = new MetadataGraphNode( md ); - addNode( node ); - return node; - } - - /** - * getter - */ - public MetadataGraphNode getEntry() - { - return entry; - } - - /** - * getter - */ - public Collection getNodes() - { - return nodes; - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/MetadataGraphNode.java b/maven-compat/src/main/java/org/apache/maven/repository/MetadataGraphNode.java deleted file mode 100644 index c258f05a6e26..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/MetadataGraphNode.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.apache.maven.repository; - -/* - * 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.List; - -/** - * MetadataGraph node - as it's a directed graph - holds adjacency lists for incident and exident nodes - * - * @author Oleg Gusakov - * - */ -public class MetadataGraphNode -{ - /** node payload */ - MavenArtifactMetadata metadata; - - /** nodes, incident to this (depend on me) */ - List inNodes; - - /** nodes, exident to this (I depend on) */ - List exNodes; - - public MetadataGraphNode() - { - inNodes = new ArrayList<>( 4 ); - exNodes = new ArrayList<>( 8 ); - } - - public MetadataGraphNode( MavenArtifactMetadata metadata ) - { - this(); - this.metadata = metadata; - } - - public MetadataGraphNode addIncident( MetadataGraphNode node ) - { - inNodes.add( node ); - return this; - } - - public MetadataGraphNode addExident( MetadataGraphNode node ) - { - exNodes.add( node ); - return this; - } - - @Override - public boolean equals( Object obj ) - { - if ( obj == null ) - { - return false; - } - - if ( MetadataGraphNode.class.isAssignableFrom( obj.getClass() ) ) - { - MetadataGraphNode node2 = (MetadataGraphNode) obj; - - if ( node2.metadata == null ) - { - return metadata == null; - } - - return metadata != null && metadata.toString().equals( node2.metadata.toString() ); - } - else - { - return super.equals( obj ); - } - } - - @Override - public int hashCode() - { - if ( metadata == null ) - { - return super.hashCode(); - } - - return metadata.toString().hashCode(); - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/MetadataResolutionRequest.java b/maven-compat/src/main/java/org/apache/maven/repository/MetadataResolutionRequest.java deleted file mode 100644 index 75d9ddc264eb..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/MetadataResolutionRequest.java +++ /dev/null @@ -1,220 +0,0 @@ -package org.apache.maven.repository; - -/* - * 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.List; -import java.util.Map; -import java.util.Set; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; - -/** - * - * - * @author Oleg Gusakov - * - */ -public class MetadataResolutionRequest -{ - private MavenArtifactMetadata mad; - - private String scope; - - // Needs to go away - private Set artifactDependencies; - - private ArtifactRepository localRepository; - - private List remoteRepositories; - - // This is like a filter but overrides all transitive versions - private Map managedVersionMap; - - /** result type - flat list; the default */ - private boolean asList = true; - - /** result type - dirty tree */ - private boolean asDirtyTree = false; - - /** result type - resolved tree */ - private boolean asResolvedTree = false; - - /** result type - graph */ - private boolean asGraph = false; - - public MetadataResolutionRequest() - { - } - - public MetadataResolutionRequest( MavenArtifactMetadata md, ArtifactRepository localRepository, - List remoteRepositories ) - { - this.mad = md; - this.localRepository = localRepository; - this.remoteRepositories = remoteRepositories; - } - - public MavenArtifactMetadata getArtifactMetadata() - { - return mad; - } - - public MetadataResolutionRequest setArtifactMetadata( MavenArtifactMetadata md ) - { - this.mad = md; - - return this; - } - - public MetadataResolutionRequest setArtifactDependencies( Set artifactDependencies ) - { - this.artifactDependencies = artifactDependencies; - - return this; - } - - public Set getArtifactDependencies() - { - return artifactDependencies; - } - - public ArtifactRepository getLocalRepository() - { - return localRepository; - } - - public MetadataResolutionRequest setLocalRepository( ArtifactRepository localRepository ) - { - this.localRepository = localRepository; - - return this; - } - - /** - * @deprecated instead use {@link #getRemoteRepositories()} - */ - @Deprecated - public List getRemoteRepostories() - { - return remoteRepositories; - } - - public List getRemoteRepositories() - { - return getRemoteRepostories(); - } - - /** - * @deprecated instead use {@link #setRemoteRepositories(List)} - */ - @Deprecated - public MetadataResolutionRequest setRemoteRepostories( List remoteRepostories ) - { - this.remoteRepositories = remoteRepostories; - - return this; - } - - public MetadataResolutionRequest setRemoteRepositories( List remoteRepositories ) - { - return setRemoteRepostories( remoteRepositories ); - } - - public Map getManagedVersionMap() - { - return managedVersionMap; - } - - public MetadataResolutionRequest setManagedVersionMap( Map managedVersionMap ) - { - this.managedVersionMap = managedVersionMap; - - return this; - } - - public String toString() - { - StringBuilder sb = new StringBuilder() - .append( "REQUEST: " ).append( "\n" ) - .append( "artifact: " ).append( mad ).append( "\n" ) - .append( artifactDependencies ).append( "\n" ) - .append( "localRepository: " ).append( localRepository ).append( "\n" ) - .append( "remoteRepositories: " ).append( remoteRepositories ).append( "\n" ) - ; - - return sb.toString(); - } - - public boolean isAsList() - { - return asList; - } - - public MetadataResolutionRequest setAsList( boolean asList ) - { - this.asList = asList; - return this; - } - - public boolean isAsDirtyTree() - { - return asDirtyTree; - } - - public MetadataResolutionRequest setAsDirtyTree( boolean asDirtyTree ) - { - this.asDirtyTree = asDirtyTree; - return this; - } - - public boolean isAsResolvedTree() - { - return asResolvedTree; - } - - public MetadataResolutionRequest setAsResolvedTree( boolean asResolvedTree ) - { - this.asResolvedTree = asResolvedTree; - return this; - } - - public boolean isAsGraph() - { - return asGraph; - } - - public MetadataResolutionRequest setAsGraph( boolean asGraph ) - { - this.asGraph = asGraph; - return this; - } - - public MetadataResolutionRequest setScope( String scope ) - { - this.scope = scope; - return this; - } - - public String getScope() - { - return scope; - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/MetadataResolutionResult.java b/maven-compat/src/main/java/org/apache/maven/repository/MetadataResolutionResult.java deleted file mode 100644 index 7be1d96950a3..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/MetadataResolutionResult.java +++ /dev/null @@ -1,363 +0,0 @@ -package org.apache.maven.repository; - -/* - * 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.Collections; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.apache.maven.artifact.resolver.CyclicDependencyException; -import org.apache.maven.artifact.versioning.OverConstrainedVersionException; - -/** - * - * - * @author Oleg Gusakov - * - */ -public class MetadataResolutionResult -{ - private Artifact originatingArtifact; - - private List missingArtifacts; - - // Exceptions - - private List exceptions; - - private List versionRangeViolations; - - private List metadataResolutionExceptions; - - private List circularDependencyExceptions; - - private List errorArtifactExceptions; - - // file system errors - - private List repositories; - - private Set requestedArtifacts; - - private Set artifacts; - - private MetadataGraph dirtyTree; - - private MetadataGraph resolvedTree; - - private MetadataGraph resolvedGraph; - - public Artifact getOriginatingArtifact() - { - return originatingArtifact; - } - - public MetadataResolutionResult listOriginatingArtifact( final Artifact originatingArtifact ) - { - this.originatingArtifact = originatingArtifact; - - return this; - } - - public void addArtifact( Artifact artifact ) - { - if ( artifacts == null ) - { - artifacts = new LinkedHashSet<>(); - } - - artifacts.add( artifact ); - } - - public Set getArtifacts() - { - return artifacts; - } - - public void addRequestedArtifact( Artifact artifact ) - { - if ( requestedArtifacts == null ) - { - requestedArtifacts = new LinkedHashSet<>(); - } - - requestedArtifacts.add( artifact ); - } - - public Set getRequestedArtifacts() - { - return requestedArtifacts; - } - - public boolean hasMissingArtifacts() - { - return missingArtifacts != null && !missingArtifacts.isEmpty(); - } - - public List getMissingArtifacts() - { - return missingArtifacts == null - ? Collections.emptyList() - : Collections.unmodifiableList( missingArtifacts ); - - } - - public MetadataResolutionResult addMissingArtifact( Artifact artifact ) - { - missingArtifacts = initList( missingArtifacts ); - - missingArtifacts.add( artifact ); - - return this; - } - - public MetadataResolutionResult setUnresolvedArtifacts( final List unresolvedArtifacts ) - { - this.missingArtifacts = unresolvedArtifacts; - - return this; - } - - // ------------------------------------------------------------------------ - // Exceptions - // ------------------------------------------------------------------------ - - public boolean hasExceptions() - { - return exceptions != null && !exceptions.isEmpty(); - } - - public List getExceptions() - { - return exceptions == null - ? Collections.emptyList() - : Collections.unmodifiableList( exceptions ); - - } - - // ------------------------------------------------------------------------ - // Version Range Violations - // ------------------------------------------------------------------------ - - public boolean hasVersionRangeViolations() - { - return versionRangeViolations != null; - } - - /** - * TODO this needs to accept a {@link OverConstrainedVersionException} as returned by - * {@link #getVersionRangeViolation(int)} but it's not used like that in - * {@link org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector} - */ - public MetadataResolutionResult addVersionRangeViolation( Exception e ) - { - versionRangeViolations = initList( versionRangeViolations ); - - versionRangeViolations.add( e ); - - exceptions = initList( exceptions ); - - exceptions.add( e ); - - return this; - } - - public OverConstrainedVersionException getVersionRangeViolation( int i ) - { - return (OverConstrainedVersionException) versionRangeViolations.get( i ); - } - - public List getVersionRangeViolations() - { - return versionRangeViolations == null - ? Collections.emptyList() - : Collections.unmodifiableList( versionRangeViolations ); - - } - - // ------------------------------------------------------------------------ - // Metadata Resolution Exceptions: ArtifactResolutionExceptions - // ------------------------------------------------------------------------ - - public boolean hasMetadataResolutionExceptions() - { - return metadataResolutionExceptions != null; - } - - public MetadataResolutionResult addMetadataResolutionException( ArtifactResolutionException e ) - { - metadataResolutionExceptions = initList( metadataResolutionExceptions ); - - metadataResolutionExceptions.add( e ); - - exceptions = initList( exceptions ); - - exceptions.add( e ); - - return this; - } - - public ArtifactResolutionException getMetadataResolutionException( int i ) - { - return metadataResolutionExceptions.get( i ); - } - - public List getMetadataResolutionExceptions() - { - return metadataResolutionExceptions == null - ? Collections.emptyList() - : Collections.unmodifiableList( metadataResolutionExceptions ); - - } - - // ------------------------------------------------------------------------ - // ErrorArtifactExceptions: ArtifactResolutionExceptions - // ------------------------------------------------------------------------ - - public boolean hasErrorArtifactExceptions() - { - return errorArtifactExceptions != null; - } - - public MetadataResolutionResult addError( Exception e ) - { - exceptions = initList( exceptions ); - - exceptions.add( e ); - - return this; - } - - public List getErrorArtifactExceptions() - { - if ( errorArtifactExceptions == null ) - { - return Collections.emptyList(); - } - - return Collections.unmodifiableList( errorArtifactExceptions ); - } - - // ------------------------------------------------------------------------ - // Circular Dependency Exceptions - // ------------------------------------------------------------------------ - - public boolean hasCircularDependencyExceptions() - { - return circularDependencyExceptions != null; - } - - public MetadataResolutionResult addCircularDependencyException( CyclicDependencyException e ) - { - circularDependencyExceptions = initList( circularDependencyExceptions ); - - circularDependencyExceptions.add( e ); - - exceptions = initList( exceptions ); - - exceptions.add( e ); - - return this; - } - - public CyclicDependencyException getCircularDependencyException( int i ) - { - return circularDependencyExceptions.get( i ); - } - - public List getCircularDependencyExceptions() - { - if ( circularDependencyExceptions == null ) - { - return Collections.emptyList(); - } - - return Collections.unmodifiableList( circularDependencyExceptions ); - } - - // ------------------------------------------------------------------------ - // Repositories - // ------------------------------------------------------------------------ - - public List getRepositories() - { - if ( repositories == null ) - { - return Collections.emptyList(); - } - - return Collections.unmodifiableList( repositories ); - } - - public MetadataResolutionResult setRepositories( final List repositories ) - { - this.repositories = repositories; - - return this; - } - - // - // Internal - // - - private List initList( final List l ) - { - if ( l == null ) - { - return new ArrayList<>(); - } - return l; - } - - public String toString() - { - if ( artifacts == null ) - { - return ""; - } - StringBuilder sb = new StringBuilder( 256 ); - int i = 1; - sb.append( "---------\n" ); - sb.append( artifacts.size() ).append( '\n' ); - for ( Artifact a : artifacts ) - { - sb.append( i ).append( ' ' ).append( a ).append( '\n' ); - i++; - } - sb.append( "---------\n" ); - return sb.toString(); - } - - public MetadataGraph getResolvedTree() - { - return resolvedTree; - } - - public void setResolvedTree( MetadataGraph resolvedTree ) - { - this.resolvedTree = resolvedTree; - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/MirrorSelector.java b/maven-compat/src/main/java/org/apache/maven/repository/MirrorSelector.java deleted file mode 100644 index c15899ed44b6..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/MirrorSelector.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.apache.maven.repository; - -/* - * 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.List; - -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.settings.Mirror; - -/** - * Handles the selection of mirrors for repositories. - * - * @author Benjamin Bentmann - */ -public interface MirrorSelector -{ - - /** - * Determines the mirror for the specified repository. - * - * @param repository The repository to determine the mirror for, must not be {@code null}. - * @param mirrors The available mirrors, may be {@code null}. - * @return The mirror specification for the repository or {@code null} if no mirror matched. - */ - Mirror getMirror( ArtifactRepository repository, List mirrors ); - -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/UserLocalArtifactRepository.java b/maven-compat/src/main/java/org/apache/maven/repository/UserLocalArtifactRepository.java deleted file mode 100644 index a88b0096e4d9..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/UserLocalArtifactRepository.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.apache.maven.repository; - -/* - * 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.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadata; -import org.apache.maven.artifact.repository.ArtifactRepository; - -/** - * UserLocalArtifactRepository - */ -public class UserLocalArtifactRepository - extends LocalArtifactRepository -{ - private ArtifactRepository localRepository; - - public UserLocalArtifactRepository( ArtifactRepository localRepository ) - { - this.localRepository = localRepository; - setLayout( localRepository.getLayout() ); - } - - @Override - public Artifact find( Artifact artifact ) - { - File artifactFile = new File( localRepository.getBasedir(), pathOf( artifact ) ); - - // We need to set the file here or the resolver will fail with an NPE, not fully equipped to deal - // with multiple local repository implementations yet. - artifact.setFile( artifactFile ); - - return artifact; - } - - @Override - public String getId() - { - return localRepository.getId(); - } - - @Override - public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) - { - return localRepository.pathOfLocalRepositoryMetadata( metadata, repository ); - } - - @Override - public String pathOf( Artifact artifact ) - { - return localRepository.pathOf( artifact ); - } - - @Override - public boolean hasLocalMetadata() - { - return true; - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/VersionNotFoundException.java b/maven-compat/src/main/java/org/apache/maven/repository/VersionNotFoundException.java deleted file mode 100644 index 77b1af1273f4..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/VersionNotFoundException.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.apache.maven.repository; - -/* - * 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.artifact.ArtifactUtils; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.model.Dependency; - -/** - * Thrown if a dependency has an invalid version. - * - * @author Brett Porter - */ -public class VersionNotFoundException - extends Exception -{ - private Dependency dependency; - - private String projectId; - private File pomFile; - private InvalidVersionSpecificationException cause; - - public VersionNotFoundException( String projectId, Dependency dependency, File pomFile, - InvalidVersionSpecificationException cause ) - { - super( projectId + ", " + formatLocationInPom( dependency ) + " " + dependency.getVersion() + ", pom file " - + pomFile, cause ); - - this.projectId = projectId; - - this.pomFile = pomFile; - - this.cause = cause; - - this.dependency = dependency; - } - - private static String formatLocationInPom( Dependency dependency ) - { - return "Dependency: " + ArtifactUtils.versionlessKey( dependency.getGroupId(), dependency.getArtifactId() ); - } - - public Dependency getDependency() - { - return dependency; - } - - public String getProjectId() - { - return projectId; - } - - public File getPomFile() - { - return pomFile; - } - - public InvalidVersionSpecificationException getCauseException() - { - return cause; - } - - -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java deleted file mode 100644 index cd01ec910f3a..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java +++ /dev/null @@ -1,428 +0,0 @@ -package org.apache.maven.repository.legacy; - -/* - * 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.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; -import org.apache.maven.artifact.repository.Authentication; -import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; -import org.apache.maven.repository.Proxy; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.logging.Logger; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.nio.channels.Channels; -import java.nio.channels.FileChannel; -import java.nio.channels.FileLock; -import java.util.Date; -import java.util.Properties; - -/** - * DefaultUpdateCheckManager - */ -@Component( role = UpdateCheckManager.class ) -public class DefaultUpdateCheckManager - extends AbstractLogEnabled - implements UpdateCheckManager -{ - - private static final String ERROR_KEY_SUFFIX = ".error"; - - public DefaultUpdateCheckManager() - { - - } - - public DefaultUpdateCheckManager( Logger logger ) - { - enableLogging( logger ); - } - - public static final String LAST_UPDATE_TAG = ".lastUpdated"; - - private static final String TOUCHFILE_NAME = "resolver-status.properties"; - - public boolean isUpdateRequired( Artifact artifact, ArtifactRepository repository ) - { - File file = artifact.getFile(); - - ArtifactRepositoryPolicy policy = artifact.isSnapshot() ? repository.getSnapshots() : repository.getReleases(); - - if ( !policy.isEnabled() ) - { - if ( getLogger().isDebugEnabled() ) - { - getLogger().debug( - "Skipping update check for " + artifact + " (" + file + ") from " + repository.getId() + " (" - + repository.getUrl() + ")" ); - } - - return false; - } - - if ( getLogger().isDebugEnabled() ) - { - getLogger().debug( - "Determining update check for " + artifact + " (" + file + ") from " + repository.getId() + " (" - + repository.getUrl() + ")" ); - } - - if ( file == null ) - { - // TODO throw something instead? - return true; - } - - Date lastCheckDate; - - if ( file.exists() ) - { - lastCheckDate = new Date( file.lastModified() ); - } - else - { - File touchfile = getTouchfile( artifact ); - lastCheckDate = readLastUpdated( touchfile, getRepositoryKey( repository ) ); - } - - return ( lastCheckDate == null ) || policy.checkOutOfDate( lastCheckDate ); - } - - public boolean isUpdateRequired( RepositoryMetadata metadata, ArtifactRepository repository, File file ) - { - // Here, we need to determine which policy to use. Release updateInterval will be used when - // the metadata refers to a release artifact or meta-version, and snapshot updateInterval will be used when - // it refers to a snapshot artifact or meta-version. - // NOTE: Release metadata includes version information about artifacts that have been released, to allow - // meta-versions like RELEASE and LATEST to resolve, and also to allow retrieval of the range of valid, released - // artifacts available. - ArtifactRepositoryPolicy policy = metadata.getPolicy( repository ); - - if ( !policy.isEnabled() ) - { - if ( getLogger().isDebugEnabled() ) - { - getLogger().debug( - "Skipping update check for " + metadata.getKey() + " (" + file + ") from " + repository.getId() - + " (" + repository.getUrl() + ")" ); - } - - return false; - } - - if ( getLogger().isDebugEnabled() ) - { - getLogger().debug( - "Determining update check for " + metadata.getKey() + " (" + file + ") from " + repository.getId() - + " (" + repository.getUrl() + ")" ); - } - - if ( file == null ) - { - // TODO throw something instead? - return true; - } - - Date lastCheckDate = readLastUpdated( metadata, repository, file ); - - return ( lastCheckDate == null ) || policy.checkOutOfDate( lastCheckDate ); - } - - private Date readLastUpdated( RepositoryMetadata metadata, ArtifactRepository repository, File file ) - { - File touchfile = getTouchfile( metadata, file ); - - String key = getMetadataKey( repository, file ); - - return readLastUpdated( touchfile, key ); - } - - public String getError( Artifact artifact, ArtifactRepository repository ) - { - File touchFile = getTouchfile( artifact ); - return getError( touchFile, getRepositoryKey( repository ) ); - } - - public void touch( Artifact artifact, ArtifactRepository repository, String error ) - { - File file = artifact.getFile(); - - File touchfile = getTouchfile( artifact ); - - if ( file.exists() ) - { - touchfile.delete(); - } - else - { - writeLastUpdated( touchfile, getRepositoryKey( repository ), error ); - } - } - - public void touch( RepositoryMetadata metadata, ArtifactRepository repository, File file ) - { - File touchfile = getTouchfile( metadata, file ); - - String key = getMetadataKey( repository, file ); - - writeLastUpdated( touchfile, key, null ); - } - - String getMetadataKey( ArtifactRepository repository, File file ) - { - return repository.getId() + '.' + file.getName() + LAST_UPDATE_TAG; - } - - String getRepositoryKey( ArtifactRepository repository ) - { - StringBuilder buffer = new StringBuilder( 256 ); - - Proxy proxy = repository.getProxy(); - if ( proxy != null ) - { - if ( proxy.getUserName() != null ) - { - int hash = ( proxy.getUserName() + proxy.getPassword() ).hashCode(); - buffer.append( hash ).append( '@' ); - } - buffer.append( proxy.getHost() ).append( ':' ).append( proxy.getPort() ).append( '>' ); - } - - // consider the username&password because a repo manager might block artifacts depending on authorization - Authentication auth = repository.getAuthentication(); - if ( auth != null ) - { - int hash = ( auth.getUsername() + auth.getPassword() ).hashCode(); - buffer.append( hash ).append( '@' ); - } - - // consider the URL (instead of the id) as this most closely relates to the contents in the repo - buffer.append( repository.getUrl() ); - - return buffer.toString(); - } - - private void writeLastUpdated( File touchfile, String key, String error ) - { - synchronized ( touchfile.getAbsolutePath().intern() ) - { - if ( !touchfile.getParentFile().exists() && !touchfile.getParentFile().mkdirs() ) - { - getLogger().debug( "Failed to create directory: " + touchfile.getParent() - + " for tracking artifact metadata resolution." ); - return; - } - - FileChannel channel = null; - FileLock lock = null; - try - { - Properties props = new Properties(); - - channel = new RandomAccessFile( touchfile, "rw" ).getChannel(); - lock = channel.lock(); - - if ( touchfile.canRead() ) - { - getLogger().debug( "Reading resolution-state from: " + touchfile ); - props.load( Channels.newInputStream( channel ) ); - } - - props.setProperty( key, Long.toString( System.currentTimeMillis() ) ); - - if ( error != null ) - { - props.setProperty( key + ERROR_KEY_SUFFIX, error ); - } - else - { - props.remove( key + ERROR_KEY_SUFFIX ); - } - - getLogger().debug( "Writing resolution-state to: " + touchfile ); - channel.truncate( 0 ); - props.store( Channels.newOutputStream( channel ), "Last modified on: " + new Date() ); - - lock.release(); - lock = null; - - channel.close(); - channel = null; - } - catch ( IOException e ) - { - getLogger().debug( - "Failed to record lastUpdated information for resolution.\nFile: " + touchfile.toString() - + "; key: " + key, e ); - } - finally - { - if ( lock != null ) - { - try - { - lock.release(); - } - catch ( IOException e ) - { - getLogger().debug( "Error releasing exclusive lock for resolution tracking file: " + touchfile, - e ); - } - } - - if ( channel != null ) - { - try - { - channel.close(); - } - catch ( IOException e ) - { - getLogger().debug( "Error closing FileChannel for resolution tracking file: " + touchfile, e ); - } - } - } - } - } - - Date readLastUpdated( File touchfile, String key ) - { - getLogger().debug( "Searching for " + key + " in resolution tracking file." ); - - Properties props = read( touchfile ); - if ( props != null ) - { - String rawVal = props.getProperty( key ); - if ( rawVal != null ) - { - try - { - return new Date( Long.parseLong( rawVal ) ); - } - catch ( NumberFormatException e ) - { - getLogger().debug( "Cannot parse lastUpdated date: \'" + rawVal + "\'. Ignoring.", e ); - } - } - } - return null; - } - - private String getError( File touchFile, String key ) - { - Properties props = read( touchFile ); - if ( props != null ) - { - return props.getProperty( key + ERROR_KEY_SUFFIX ); - } - return null; - } - - private Properties read( File touchfile ) - { - if ( !touchfile.canRead() ) - { - getLogger().debug( "Skipped unreadable resolution tracking file " + touchfile ); - return null; - } - - synchronized ( touchfile.getAbsolutePath().intern() ) - { - FileInputStream in = null; - FileLock lock = null; - - try - { - Properties props = new Properties(); - - in = new FileInputStream( touchfile ); - lock = in.getChannel().lock( 0, Long.MAX_VALUE, true ); - - getLogger().debug( "Reading resolution-state from: " + touchfile ); - props.load( in ); - - lock.release(); - lock = null; - - in.close(); - in = null; - - return props; - } - catch ( IOException e ) - { - getLogger().debug( "Failed to read resolution tracking file " + touchfile, e ); - - return null; - } - finally - { - if ( lock != null ) - { - try - { - lock.release(); - } - catch ( IOException e ) - { - getLogger().debug( "Error releasing shared lock for resolution tracking file: " + touchfile, - e ); - } - } - - if ( in != null ) - { - try - { - in.close(); - } - catch ( IOException e ) - { - getLogger().debug( "Error closing FileChannel for resolution tracking file: " + touchfile, e ); - } - } - } - } - } - - File getTouchfile( Artifact artifact ) - { - StringBuilder sb = new StringBuilder( 128 ); - sb.append( artifact.getArtifactId() ); - sb.append( '-' ).append( artifact.getBaseVersion() ); - if ( artifact.getClassifier() != null ) - { - sb.append( '-' ).append( artifact.getClassifier() ); - } - sb.append( '.' ).append( artifact.getType() ).append( LAST_UPDATE_TAG ); - return new File( artifact.getFile().getParentFile(), sb.toString() ); - } - - File getTouchfile( RepositoryMetadata metadata, File file ) - { - return new File( file.getParent(), TOUCHFILE_NAME ); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java deleted file mode 100644 index 0bd821905d3c..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java +++ /dev/null @@ -1,918 +0,0 @@ -package org.apache.maven.repository.legacy; - -/* - * 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.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.apache.maven.RepositoryUtils; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.InvalidRepositoryException; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.metadata.ArtifactMetadata; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory; -import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; -import org.apache.maven.artifact.repository.Authentication; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; -import org.apache.maven.artifact.resolver.ArtifactResolutionResult; -import org.apache.maven.artifact.resolver.ArtifactResolver; -import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.maven.model.Dependency; -import org.apache.maven.model.Exclusion; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.Repository; -import org.apache.maven.model.RepositoryPolicy; -import org.apache.maven.repository.DelegatingLocalArtifactRepository; -import org.apache.maven.repository.LocalArtifactRepository; -import org.apache.maven.repository.ArtifactTransferListener; -import org.apache.maven.repository.MirrorSelector; -import org.apache.maven.repository.Proxy; -import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.repository.ArtifactDoesNotExistException; -import org.apache.maven.repository.ArtifactTransferFailedException; -import org.apache.maven.settings.Mirror; -import org.apache.maven.settings.Server; -import org.apache.maven.settings.building.SettingsProblem; -import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest; -import org.apache.maven.settings.crypto.SettingsDecrypter; -import org.apache.maven.settings.crypto.SettingsDecryptionRequest; -import org.apache.maven.settings.crypto.SettingsDecryptionResult; -import org.apache.maven.wagon.proxy.ProxyInfo; -import org.apache.maven.wagon.proxy.ProxyUtils; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.util.StringUtils; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.repository.AuthenticationContext; -import org.eclipse.aether.repository.AuthenticationSelector; -import org.eclipse.aether.repository.ProxySelector; -import org.eclipse.aether.repository.RemoteRepository; - -/** - * @author Jason van Zyl - */ -@Component( role = RepositorySystem.class, hint = "default" ) -public class LegacyRepositorySystem - implements RepositorySystem -{ - - @Requirement - private Logger logger; - - @Requirement - private ArtifactFactory artifactFactory; - - @Requirement - private ArtifactResolver artifactResolver; - - @Requirement - private ArtifactRepositoryFactory artifactRepositoryFactory; - - @Requirement( role = ArtifactRepositoryLayout.class ) - private Map layouts; - - @Requirement - private WagonManager wagonManager; - - @Requirement - private PlexusContainer plexus; - - @Requirement - private MirrorSelector mirrorSelector; - - @Requirement - private SettingsDecrypter settingsDecrypter; - - public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type ) - { - return artifactFactory.createArtifact( groupId, artifactId, version, scope, type ); - } - - public Artifact createArtifact( String groupId, String artifactId, String version, String packaging ) - { - return artifactFactory.createBuildArtifact( groupId, artifactId, version, packaging ); - } - - public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type, - String classifier ) - { - return artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier ); - } - - public Artifact createProjectArtifact( String groupId, String artifactId, String metaVersionId ) - { - return artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId ); - } - - public Artifact createDependencyArtifact( Dependency d ) - { - VersionRange versionRange; - try - { - versionRange = VersionRange.createFromVersionSpec( d.getVersion() ); - } - catch ( InvalidVersionSpecificationException e ) - { - // MNG-5368: Log a message instead of returning 'null' silently. - this.logger.error( String.format( "Invalid version specification '%s' creating dependency artifact '%s'.", - d.getVersion(), d ), e ); - return null; - } - - Artifact artifact = - artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), versionRange, d.getType(), - d.getClassifier(), d.getScope(), d.isOptional() ); - - if ( Artifact.SCOPE_SYSTEM.equals( d.getScope() ) && d.getSystemPath() != null ) - { - artifact.setFile( new File( d.getSystemPath() ) ); - } - - if ( !d.getExclusions().isEmpty() ) - { - List exclusions = new ArrayList<>(); - - for ( Exclusion exclusion : d.getExclusions() ) - { - exclusions.add( exclusion.getGroupId() + ':' + exclusion.getArtifactId() ); - } - - artifact.setDependencyFilter( new ExcludesArtifactFilter( exclusions ) ); - } - - return artifact; - } - - public Artifact createExtensionArtifact( String groupId, String artifactId, String version ) - { - VersionRange versionRange; - try - { - versionRange = VersionRange.createFromVersionSpec( version ); - } - catch ( InvalidVersionSpecificationException e ) - { - // MNG-5368: Log a message instead of returning 'null' silently. - this.logger.error( String.format( - "Invalid version specification '%s' creating extension artifact '%s:%s:%s'.", - version, groupId, artifactId, version ), e ); - - return null; - } - - return artifactFactory.createExtensionArtifact( groupId, artifactId, versionRange ); - } - - public Artifact createParentArtifact( String groupId, String artifactId, String version ) - { - return artifactFactory.createParentArtifact( groupId, artifactId, version ); - } - - public Artifact createPluginArtifact( Plugin plugin ) - { - String version = plugin.getVersion(); - if ( StringUtils.isEmpty( version ) ) - { - version = "RELEASE"; - } - - VersionRange versionRange; - try - { - versionRange = VersionRange.createFromVersionSpec( version ); - } - catch ( InvalidVersionSpecificationException e ) - { - // MNG-5368: Log a message instead of returning 'null' silently. - this.logger.error( String.format( - "Invalid version specification '%s' creating plugin artifact '%s'.", - version, plugin ), e ); - - return null; - } - - return artifactFactory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange ); - } - - public ArtifactRepositoryPolicy buildArtifactRepositoryPolicy( RepositoryPolicy policy ) - { - boolean enabled = true; - - String updatePolicy = null; - - String checksumPolicy = null; - - if ( policy != null ) - { - enabled = policy.isEnabled(); - - if ( policy.getUpdatePolicy() != null ) - { - updatePolicy = policy.getUpdatePolicy(); - } - if ( policy.getChecksumPolicy() != null ) - { - checksumPolicy = policy.getChecksumPolicy(); - } - } - - return new ArtifactRepositoryPolicy( enabled, updatePolicy, checksumPolicy ); - } - - public ArtifactRepository createDefaultLocalRepository() - throws InvalidRepositoryException - { - return createLocalRepository( RepositorySystem.defaultUserLocalRepository ); - } - - public ArtifactRepository createLocalRepository( File localRepository ) - throws InvalidRepositoryException - { - return createRepository( "file://" + localRepository.toURI().getRawPath(), - RepositorySystem.DEFAULT_LOCAL_REPO_ID, true, - ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, true, - ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, - ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE ); - } - - public ArtifactRepository createDefaultRemoteRepository() - throws InvalidRepositoryException - { - return createRepository( RepositorySystem.DEFAULT_REMOTE_REPO_URL, RepositorySystem.DEFAULT_REMOTE_REPO_ID, - true, ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY, false, - ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY, - ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN ); - } - - public ArtifactRepository createLocalRepository( String url, String repositoryId ) - throws IOException - { - return createRepository( canonicalFileUrl( url ), repositoryId, true, - ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, true, - ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, - ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE ); - } - - private String canonicalFileUrl( String url ) - throws IOException - { - if ( !url.startsWith( "file:" ) ) - { - url = "file://" + url; - } - else if ( url.startsWith( "file:" ) && !url.startsWith( "file://" ) ) - { - url = "file://" + url.substring( "file:".length() ); - } - - // So now we have an url of the form file:// - - // We want to eliminate any relative path nonsense and lock down the path so we - // need to fully resolve it before any sub-modules use the path. This can happen - // when you are using a custom settings.xml that contains a relative path entry - // for the local repository setting. - - File localRepository = new File( url.substring( "file://".length() ) ); - - if ( !localRepository.isAbsolute() ) - { - url = "file://" + localRepository.getCanonicalPath(); - } - - return url; - } - - public ArtifactResolutionResult resolve( ArtifactResolutionRequest request ) - { - /* - * Probably is not worth it, but here I make sure I restore request - * to its original state. - */ - try - { - LocalArtifactRepository ideWorkspace = - plexus.lookup( LocalArtifactRepository.class, LocalArtifactRepository.IDE_WORKSPACE ); - - if ( request.getLocalRepository() instanceof DelegatingLocalArtifactRepository ) - { - DelegatingLocalArtifactRepository delegatingLocalRepository = - (DelegatingLocalArtifactRepository) request.getLocalRepository(); - - LocalArtifactRepository orig = delegatingLocalRepository.getIdeWorkspace(); - - delegatingLocalRepository.setIdeWorkspace( ideWorkspace ); - - try - { - return artifactResolver.resolve( request ); - } - finally - { - delegatingLocalRepository.setIdeWorkspace( orig ); - } - } - else - { - ArtifactRepository localRepository = request.getLocalRepository(); - DelegatingLocalArtifactRepository delegatingLocalRepository = - new DelegatingLocalArtifactRepository( localRepository ); - delegatingLocalRepository.setIdeWorkspace( ideWorkspace ); - request.setLocalRepository( delegatingLocalRepository ); - try - { - return artifactResolver.resolve( request ); - } - finally - { - request.setLocalRepository( localRepository ); - } - } - } - catch ( ComponentLookupException e ) - { - // no ide workspace artifact resolution - } - - return artifactResolver.resolve( request ); - } - -// public void addProxy( String protocol, String host, int port, String username, String password, -// String nonProxyHosts ) -// { -// ProxyInfo proxyInfo = new ProxyInfo(); -// proxyInfo.setHost( host ); -// proxyInfo.setType( protocol ); -// proxyInfo.setPort( port ); -// proxyInfo.setNonProxyHosts( nonProxyHosts ); -// proxyInfo.setUserName( username ); -// proxyInfo.setPassword( password ); -// -// proxies.put( protocol, proxyInfo ); -// -// wagonManager.addProxy( protocol, host, port, username, password, nonProxyHosts ); -// } - - public List getEffectiveRepositories( List repositories ) - { - if ( repositories == null ) - { - return null; - } - - Map> reposByKey = new LinkedHashMap<>(); - - for ( ArtifactRepository repository : repositories ) - { - String key = repository.getId(); - - List aliasedRepos = reposByKey.computeIfAbsent( key, k -> new ArrayList<>() ); - - aliasedRepos.add( repository ); - } - - List effectiveRepositories = new ArrayList<>(); - - for ( List aliasedRepos : reposByKey.values() ) - { - List mirroredRepos = new ArrayList<>(); - - List releasePolicies = - new ArrayList<>( aliasedRepos.size() ); - - for ( ArtifactRepository aliasedRepo : aliasedRepos ) - { - releasePolicies.add( aliasedRepo.getReleases() ); - mirroredRepos.addAll( aliasedRepo.getMirroredRepositories() ); - } - - ArtifactRepositoryPolicy releasePolicy = getEffectivePolicy( releasePolicies ); - - List snapshotPolicies = - new ArrayList<>( aliasedRepos.size() ); - - for ( ArtifactRepository aliasedRepo : aliasedRepos ) - { - snapshotPolicies.add( aliasedRepo.getSnapshots() ); - } - - ArtifactRepositoryPolicy snapshotPolicy = getEffectivePolicy( snapshotPolicies ); - - ArtifactRepository aliasedRepo = aliasedRepos.get( 0 ); - - ArtifactRepository effectiveRepository = - createArtifactRepository( aliasedRepo.getId(), aliasedRepo.getUrl(), aliasedRepo.getLayout(), - snapshotPolicy, releasePolicy ); - - effectiveRepository.setAuthentication( aliasedRepo.getAuthentication() ); - - effectiveRepository.setProxy( aliasedRepo.getProxy() ); - - effectiveRepository.setMirroredRepositories( mirroredRepos ); - - effectiveRepository.setBlocked( aliasedRepo.isBlocked() ); - - effectiveRepositories.add( effectiveRepository ); - } - - return effectiveRepositories; - } - - private ArtifactRepositoryPolicy getEffectivePolicy( Collection policies ) - { - ArtifactRepositoryPolicy effectivePolicy = null; - - for ( ArtifactRepositoryPolicy policy : policies ) - { - if ( effectivePolicy == null ) - { - effectivePolicy = new ArtifactRepositoryPolicy( policy ); - } - else - { - effectivePolicy.merge( policy ); - } - } - - return effectivePolicy; - } - - public Mirror getMirror( ArtifactRepository repository, List mirrors ) - { - return mirrorSelector.getMirror( repository, mirrors ); - } - - public void injectMirror( List repositories, List mirrors ) - { - if ( repositories != null && mirrors != null ) - { - for ( ArtifactRepository repository : repositories ) - { - Mirror mirror = getMirror( repository, mirrors ); - injectMirror( repository, mirror ); - } - } - } - - private Mirror getMirror( RepositorySystemSession session, ArtifactRepository repository ) - { - if ( session != null ) - { - org.eclipse.aether.repository.MirrorSelector selector = session.getMirrorSelector(); - if ( selector != null ) - { - RemoteRepository repo = selector.getMirror( RepositoryUtils.toRepo( repository ) ); - if ( repo != null ) - { - Mirror mirror = new Mirror(); - mirror.setId( repo.getId() ); - mirror.setUrl( repo.getUrl() ); - mirror.setLayout( repo.getContentType() ); - mirror.setBlocked( repo.isBlocked() ); - return mirror; - } - } - } - return null; - } - - public void injectMirror( RepositorySystemSession session, List repositories ) - { - if ( repositories != null && session != null ) - { - for ( ArtifactRepository repository : repositories ) - { - Mirror mirror = getMirror( session, repository ); - injectMirror( repository, mirror ); - } - } - } - - private void injectMirror( ArtifactRepository repository, Mirror mirror ) - { - if ( mirror != null ) - { - ArtifactRepository original = - createArtifactRepository( repository.getId(), repository.getUrl(), repository.getLayout(), - repository.getSnapshots(), repository.getReleases() ); - - repository.setMirroredRepositories( Collections.singletonList( original ) ); - - repository.setId( mirror.getId() ); - repository.setUrl( mirror.getUrl() ); - - if ( StringUtils.isNotEmpty( mirror.getLayout() ) ) - { - repository.setLayout( getLayout( mirror.getLayout() ) ); - } - - repository.setBlocked( mirror.isBlocked() ); - } - } - - public void injectAuthentication( List repositories, List servers ) - { - if ( repositories != null ) - { - Map serversById = new HashMap<>(); - - if ( servers != null ) - { - for ( Server server : servers ) - { - if ( !serversById.containsKey( server.getId() ) ) - { - serversById.put( server.getId(), server ); - } - } - } - - for ( ArtifactRepository repository : repositories ) - { - Server server = serversById.get( repository.getId() ); - - if ( server != null ) - { - SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest( server ); - SettingsDecryptionResult result = settingsDecrypter.decrypt( request ); - server = result.getServer(); - - if ( logger.isDebugEnabled() ) - { - for ( SettingsProblem problem : result.getProblems() ) - { - logger.debug( problem.getMessage(), problem.getException() ); - } - } - - Authentication authentication = new Authentication( server.getUsername(), server.getPassword() ); - authentication.setPrivateKey( server.getPrivateKey() ); - authentication.setPassphrase( server.getPassphrase() ); - - repository.setAuthentication( authentication ); - } - else - { - repository.setAuthentication( null ); - } - } - } - } - - private Authentication getAuthentication( RepositorySystemSession session, ArtifactRepository repository ) - { - if ( session != null ) - { - AuthenticationSelector selector = session.getAuthenticationSelector(); - if ( selector != null ) - { - RemoteRepository repo = RepositoryUtils.toRepo( repository ); - org.eclipse.aether.repository.Authentication auth = selector.getAuthentication( repo ); - if ( auth != null ) - { - repo = new RemoteRepository.Builder( repo ).setAuthentication( auth ).build(); - AuthenticationContext authCtx = AuthenticationContext.forRepository( session, repo ); - Authentication result = - new Authentication( authCtx.get( AuthenticationContext.USERNAME ), - authCtx.get( AuthenticationContext.PASSWORD ) ); - result.setPrivateKey( authCtx.get( AuthenticationContext.PRIVATE_KEY_PATH ) ); - result.setPassphrase( authCtx.get( AuthenticationContext.PRIVATE_KEY_PASSPHRASE ) ); - authCtx.close(); - return result; - } - } - } - return null; - } - - public void injectAuthentication( RepositorySystemSession session, List repositories ) - { - if ( repositories != null && session != null ) - { - for ( ArtifactRepository repository : repositories ) - { - repository.setAuthentication( getAuthentication( session, repository ) ); - } - } - } - - private org.apache.maven.settings.Proxy getProxy( ArtifactRepository repository, - List proxies ) - { - if ( proxies != null && repository.getProtocol() != null ) - { - for ( org.apache.maven.settings.Proxy proxy : proxies ) - { - if ( proxy.isActive() && repository.getProtocol().equalsIgnoreCase( proxy.getProtocol() ) ) - { - if ( StringUtils.isNotEmpty( proxy.getNonProxyHosts() ) ) - { - ProxyInfo pi = new ProxyInfo(); - pi.setNonProxyHosts( proxy.getNonProxyHosts() ); - - org.apache.maven.wagon.repository.Repository repo = - new org.apache.maven.wagon.repository.Repository( repository.getId(), repository.getUrl() ); - - if ( !ProxyUtils.validateNonProxyHosts( pi, repo.getHost() ) ) - { - return proxy; - } - } - else - { - return proxy; - } - } - } - } - - return null; - } - - public void injectProxy( List repositories, List proxies ) - { - if ( repositories != null ) - { - for ( ArtifactRepository repository : repositories ) - { - org.apache.maven.settings.Proxy proxy = getProxy( repository, proxies ); - - if ( proxy != null ) - { - SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest( proxy ); - SettingsDecryptionResult result = settingsDecrypter.decrypt( request ); - proxy = result.getProxy(); - - if ( logger.isDebugEnabled() ) - { - for ( SettingsProblem problem : result.getProblems() ) - { - logger.debug( problem.getMessage(), problem.getException() ); - } - } - - Proxy p = new Proxy(); - p.setHost( proxy.getHost() ); - p.setProtocol( proxy.getProtocol() ); - p.setPort( proxy.getPort() ); - p.setNonProxyHosts( proxy.getNonProxyHosts() ); - p.setUserName( proxy.getUsername() ); - p.setPassword( proxy.getPassword() ); - - repository.setProxy( p ); - } - else - { - repository.setProxy( null ); - } - } - } - } - - private Proxy getProxy( RepositorySystemSession session, ArtifactRepository repository ) - { - if ( session != null ) - { - ProxySelector selector = session.getProxySelector(); - if ( selector != null ) - { - RemoteRepository repo = RepositoryUtils.toRepo( repository ); - org.eclipse.aether.repository.Proxy proxy = selector.getProxy( repo ); - if ( proxy != null ) - { - Proxy p = new Proxy(); - p.setHost( proxy.getHost() ); - p.setProtocol( proxy.getType() ); - p.setPort( proxy.getPort() ); - if ( proxy.getAuthentication() != null ) - { - repo = new RemoteRepository.Builder( repo ).setProxy( proxy ).build(); - AuthenticationContext authCtx = AuthenticationContext.forProxy( session, repo ); - p.setUserName( authCtx.get( AuthenticationContext.USERNAME ) ); - p.setPassword( authCtx.get( AuthenticationContext.PASSWORD ) ); - p.setNtlmDomain( authCtx.get( AuthenticationContext.NTLM_DOMAIN ) ); - p.setNtlmHost( authCtx.get( AuthenticationContext.NTLM_WORKSTATION ) ); - authCtx.close(); - } - return p; - } - } - } - return null; - } - - public void injectProxy( RepositorySystemSession session, List repositories ) - { - if ( repositories != null && session != null ) - { - for ( ArtifactRepository repository : repositories ) - { - repository.setProxy( getProxy( session, repository ) ); - } - } - } - - public void retrieve( ArtifactRepository repository, File destination, String remotePath, - ArtifactTransferListener transferListener ) - throws ArtifactTransferFailedException, ArtifactDoesNotExistException - { - try - { - wagonManager.getRemoteFile( repository, destination, remotePath, - TransferListenerAdapter.newAdapter( transferListener ), - ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN, true ); - } - catch ( org.apache.maven.wagon.TransferFailedException e ) - { - throw new ArtifactTransferFailedException( getMessage( e, "Error transferring artifact." ), e ); - } - catch ( org.apache.maven.wagon.ResourceDoesNotExistException e ) - { - throw new ArtifactDoesNotExistException( getMessage( e, "Requested artifact does not exist." ), e ); - } - } - - public void publish( ArtifactRepository repository, File source, String remotePath, - ArtifactTransferListener transferListener ) - throws ArtifactTransferFailedException - { - try - { - wagonManager.putRemoteFile( repository, source, remotePath, - TransferListenerAdapter.newAdapter( transferListener ) ); - } - catch ( org.apache.maven.wagon.TransferFailedException e ) - { - throw new ArtifactTransferFailedException( getMessage( e, "Error transferring artifact." ), e ); - } - } - - // - // Artifact Repository Creation - // - public ArtifactRepository buildArtifactRepository( Repository repo ) - throws InvalidRepositoryException - { - if ( repo != null ) - { - String id = repo.getId(); - - if ( StringUtils.isEmpty( id ) ) - { - throw new InvalidRepositoryException( "Repository identifier missing", "" ); - } - - String url = repo.getUrl(); - - if ( StringUtils.isEmpty( url ) ) - { - throw new InvalidRepositoryException( "URL missing for repository " + id, id ); - } - - ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repo.getSnapshots() ); - - ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repo.getReleases() ); - - return createArtifactRepository( id, url, getLayout( repo.getLayout() ), snapshots, releases ); - } - else - { - return null; - } - } - - private ArtifactRepository createRepository( String url, String repositoryId, boolean releases, - String releaseUpdates, boolean snapshots, String snapshotUpdates, - String checksumPolicy ) - { - ArtifactRepositoryPolicy snapshotsPolicy = - new ArtifactRepositoryPolicy( snapshots, snapshotUpdates, checksumPolicy ); - - ArtifactRepositoryPolicy releasesPolicy = - new ArtifactRepositoryPolicy( releases, releaseUpdates, checksumPolicy ); - - return createArtifactRepository( repositoryId, url, null, snapshotsPolicy, releasesPolicy ); - } - - public ArtifactRepository createArtifactRepository( String repositoryId, String url, - ArtifactRepositoryLayout repositoryLayout, - ArtifactRepositoryPolicy snapshots, - ArtifactRepositoryPolicy releases ) - { - if ( repositoryLayout == null ) - { - repositoryLayout = layouts.get( "default" ); - } - - ArtifactRepository artifactRepository = - artifactRepositoryFactory.createArtifactRepository( repositoryId, url, repositoryLayout, snapshots, - releases ); - - return artifactRepository; - } - - private static String getMessage( Throwable error, String def ) - { - if ( error == null ) - { - return def; - } - String msg = error.getMessage(); - if ( StringUtils.isNotEmpty( msg ) ) - { - return msg; - } - return getMessage( error.getCause(), def ); - } - - private ArtifactRepositoryLayout getLayout( String id ) - { - ArtifactRepositoryLayout layout = layouts.get( id ); - - if ( layout == null ) - { - layout = new UnknownRepositoryLayout( id, layouts.get( "default" ) ); - } - - return layout; - } - - /** - * In the future, the legacy system might encounter repository types for which no layout components exists because - * the actual communication with the repository happens via a repository connector. As a minimum, the legacy system - * needs to retain the id of this layout so that the content type of the remote repository can still be accurately - * described. - */ - static class UnknownRepositoryLayout - implements ArtifactRepositoryLayout - { - - private final String id; - - private final ArtifactRepositoryLayout fallback; - - UnknownRepositoryLayout( String id, ArtifactRepositoryLayout fallback ) - { - this.id = id; - this.fallback = fallback; - } - - public String getId() - { - return id; - } - - public String pathOf( Artifact artifact ) - { - return fallback.pathOf( artifact ); - } - - public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) - { - return fallback.pathOfLocalRepositoryMetadata( metadata, repository ); - } - - public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata ) - { - return fallback.pathOfRemoteRepositoryMetadata( metadata ); - } - - @Override - public String toString() - { - return getId(); - } - - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/UpdateCheckManager.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/UpdateCheckManager.java deleted file mode 100644 index 0ef8c6ae4a27..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/UpdateCheckManager.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.apache.maven.repository.legacy; - -/* - * 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.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; - -/** - * UpdateCheckManager - */ -public interface UpdateCheckManager -{ - - boolean isUpdateRequired( Artifact artifact, ArtifactRepository repository ); - - void touch( Artifact artifact, ArtifactRepository repository, String error ); - - String getError( Artifact artifact, ArtifactRepository repository ); - - boolean isUpdateRequired( RepositoryMetadata metadata, ArtifactRepository repository, File file ); - - void touch( RepositoryMetadata metadata, ArtifactRepository repository, File file ); - -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/WagonConfigurationException.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/WagonConfigurationException.java deleted file mode 100644 index 554212586ab8..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/WagonConfigurationException.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.apache.maven.repository.legacy; - -/* - * 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.wagon.TransferFailedException; - -/** - * WagonConfigurationException - */ -public class WagonConfigurationException - extends TransferFailedException -{ - - static final long serialVersionUID = 1; - - private final String originalMessage; - private final String repositoryId; - - public WagonConfigurationException( String repositoryId, - String message, - Throwable cause ) - { - super( "While configuring wagon for \'" + repositoryId + "\': " + message, cause ); - - this.repositoryId = repositoryId; - this.originalMessage = message; - } - - public WagonConfigurationException( String repositoryId, - String message ) - { - super( "While configuring wagon for \'" + repositoryId + "\': " + message ); - - this.repositoryId = repositoryId; - this.originalMessage = message; - } - - public final String getRepositoryId() - { - return repositoryId; - } - - public final String getOriginalMessage() - { - return originalMessage; - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/WagonManager.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/WagonManager.java deleted file mode 100644 index 61568186eeef..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/WagonManager.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.apache.maven.repository.legacy; - -/* - * 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.List; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadata; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.wagon.ResourceDoesNotExistException; -import org.apache.maven.wagon.TransferFailedException; -import org.apache.maven.wagon.UnsupportedProtocolException; -import org.apache.maven.wagon.Wagon; -import org.apache.maven.wagon.events.TransferListener; -import org.apache.maven.wagon.repository.Repository; - -/** - * WagonManager - */ -public interface WagonManager -{ - @Deprecated - Wagon getWagon( String protocol ) - throws UnsupportedProtocolException; - - @Deprecated - Wagon getWagon( Repository repository ) - throws UnsupportedProtocolException, WagonConfigurationException; - - // - // Retriever - // - void getArtifact( Artifact artifact, ArtifactRepository repository, TransferListener transferListener, - boolean force ) - throws TransferFailedException, ResourceDoesNotExistException; - - void getArtifact( Artifact artifact, List remoteRepositories, - TransferListener transferListener, boolean force ) - throws TransferFailedException, ResourceDoesNotExistException; - - void getRemoteFile( ArtifactRepository repository, File destination, String remotePath, - TransferListener downloadMonitor, String checksumPolicy, boolean force ) - throws TransferFailedException, ResourceDoesNotExistException; - - void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File destination, - String checksumPolicy ) - throws TransferFailedException, ResourceDoesNotExistException; - - void getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository remoteRepository, - File file, String checksumPolicyWarn ) - throws TransferFailedException, ResourceDoesNotExistException; - - // - // Deployer - // - void putArtifact( File source, Artifact artifact, ArtifactRepository deploymentRepository, - TransferListener downloadMonitor ) - throws TransferFailedException; - - void putRemoteFile( ArtifactRepository repository, File source, String remotePath, - TransferListener downloadMonitor ) - throws TransferFailedException; - - void putArtifactMetadata( File source, ArtifactMetadata artifactMetadata, ArtifactRepository repository ) - throws TransferFailedException; -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/repository/ArtifactRepositoryFactory.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/repository/ArtifactRepositoryFactory.java deleted file mode 100644 index aeb5739d782b..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/repository/ArtifactRepositoryFactory.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.apache.maven.repository.legacy.repository; - -/* - * 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.artifact.UnknownRepositoryLayoutException; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; - -/** @author jdcasey */ -public interface ArtifactRepositoryFactory -{ - - String DEFAULT_LAYOUT_ID = "default"; - - String LOCAL_REPOSITORY_ID = "local"; - - @Deprecated - ArtifactRepositoryLayout getLayout( String layoutId ) - throws UnknownRepositoryLayoutException; - - @Deprecated - ArtifactRepository createDeploymentArtifactRepository( String id, String url, String layoutId, - boolean uniqueVersion ) - throws UnknownRepositoryLayoutException; - - ArtifactRepository createDeploymentArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, - boolean uniqueVersion ); - - ArtifactRepository createArtifactRepository( String id, String url, String layoutId, - ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ) - throws UnknownRepositoryLayoutException; - - ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout, - ArtifactRepositoryPolicy snapshots, - ArtifactRepositoryPolicy releases ); - - void setGlobalUpdatePolicy( String snapshotPolicy ); - - void setGlobalChecksumPolicy( String checksumPolicy ); -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/repository/DefaultArtifactRepositoryFactory.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/repository/DefaultArtifactRepositoryFactory.java deleted file mode 100644 index fc6b4412863d..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/repository/DefaultArtifactRepositoryFactory.java +++ /dev/null @@ -1,144 +0,0 @@ -package org.apache.maven.repository.legacy.repository; - -/* - * 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.Map; - -import org.apache.maven.artifact.UnknownRepositoryLayoutException; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; -import org.apache.maven.artifact.repository.MavenArtifactRepository; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout2; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; - -/** - * @author jdcasey - */ -@Component( role = ArtifactRepositoryFactory.class ) -public class DefaultArtifactRepositoryFactory - implements ArtifactRepositoryFactory -{ - // TODO use settings? - private String globalUpdatePolicy; - - private String globalChecksumPolicy; - - @Requirement( role = ArtifactRepositoryLayout.class ) - private Map repositoryLayouts; - - public ArtifactRepositoryLayout getLayout( String layoutId ) - throws UnknownRepositoryLayoutException - { - return repositoryLayouts.get( layoutId ); - } - - public ArtifactRepository createDeploymentArtifactRepository( String id, String url, String layoutId, - boolean uniqueVersion ) - throws UnknownRepositoryLayoutException - { - ArtifactRepositoryLayout layout = repositoryLayouts.get( layoutId ); - - checkLayout( id, layoutId, layout ); - - return createDeploymentArtifactRepository( id, url, layout, uniqueVersion ); - } - - private void checkLayout( String repositoryId, String layoutId, ArtifactRepositoryLayout layout ) - throws UnknownRepositoryLayoutException - { - if ( layout == null ) - { - throw new UnknownRepositoryLayoutException( repositoryId, layoutId ); - } - } - - public ArtifactRepository createDeploymentArtifactRepository( String id, String url, - ArtifactRepositoryLayout repositoryLayout, - boolean uniqueVersion ) - { - return createArtifactRepository( id, url, repositoryLayout, null, null ); - } - - public ArtifactRepository createArtifactRepository( String id, String url, String layoutId, - ArtifactRepositoryPolicy snapshots, - ArtifactRepositoryPolicy releases ) - throws UnknownRepositoryLayoutException - { - ArtifactRepositoryLayout layout = repositoryLayouts.get( layoutId ); - - checkLayout( id, layoutId, layout ); - - return createArtifactRepository( id, url, layout, snapshots, releases ); - } - - public ArtifactRepository createArtifactRepository( String id, String url, - ArtifactRepositoryLayout repositoryLayout, - ArtifactRepositoryPolicy snapshots, - ArtifactRepositoryPolicy releases ) - { - if ( snapshots == null ) - { - snapshots = new ArtifactRepositoryPolicy(); - } - - if ( releases == null ) - { - releases = new ArtifactRepositoryPolicy(); - } - - if ( globalUpdatePolicy != null ) - { - snapshots.setUpdatePolicy( globalUpdatePolicy ); - releases.setUpdatePolicy( globalUpdatePolicy ); - } - - if ( globalChecksumPolicy != null ) - { - snapshots.setChecksumPolicy( globalChecksumPolicy ); - releases.setChecksumPolicy( globalChecksumPolicy ); - } - - ArtifactRepository repository; - if ( repositoryLayout instanceof ArtifactRepositoryLayout2 ) - { - repository = - ( (ArtifactRepositoryLayout2) repositoryLayout ).newMavenArtifactRepository( id, url, snapshots, - releases ); - } - else - { - repository = new MavenArtifactRepository( id, url, repositoryLayout, snapshots, releases ); - } - - return repository; - } - - public void setGlobalUpdatePolicy( String updatePolicy ) - { - globalUpdatePolicy = updatePolicy; - } - - public void setGlobalChecksumPolicy( String checksumPolicy ) - { - globalChecksumPolicy = checksumPolicy; - } - } diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/LegacyArtifactCollector.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/LegacyArtifactCollector.java deleted file mode 100644 index 90b869f29841..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/LegacyArtifactCollector.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.apache.maven.repository.legacy.resolver; - -/* - * 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.List; -import java.util.Map; -import java.util.Set; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; -import org.apache.maven.artifact.resolver.ArtifactResolutionResult; -import org.apache.maven.artifact.resolver.ResolutionListener; -import org.apache.maven.artifact.resolver.filter.ArtifactFilter; -import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver; - -/** - * Artifact collector - takes a set of original artifacts and resolves all of the best versions to use - * along with their metadata. No artifacts are downloaded. - * - * @author Brett Porter - */ -@Deprecated -@SuppressWarnings( "checkstyle:parameternumber" ) -public interface LegacyArtifactCollector -{ - - ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, - Map managedVersions, - ArtifactResolutionRequest repositoryRequest, ArtifactMetadataSource source, - ArtifactFilter filter, List listeners, - List conflictResolvers ); - - ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, - Map managedVersions, - ArtifactRepository localRepository, List remoteRepositories, - ArtifactMetadataSource source, ArtifactFilter filter, - List listeners, List conflictResolvers ); - - // used by maven-dependency-tree and maven-dependency-plugin - @Deprecated - ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, - Map managedVersions, - ArtifactRepository localRepository, List remoteRepositories, - ArtifactMetadataSource source, ArtifactFilter filter, - List listeners ); - -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/ConflictResolverFactory.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/ConflictResolverFactory.java deleted file mode 100644 index 8f3f9f43e6ba..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/ConflictResolverFactory.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.apache.maven.repository.legacy.resolver.conflict; - -/* - * 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. - */ - -/** - * A factory that produces conflict resolvers of various types. - * - * @author Mark Hobson - * @see ConflictResolver - * @since 3.0 - */ -public interface ConflictResolverFactory -{ - // constants -------------------------------------------------------------- - - /** The plexus role for this component. */ - String ROLE = ConflictResolverFactory.class.getName(); - - // methods ---------------------------------------------------------------- - - /** - * Gets a conflict resolver of the specified type. - * - * @param type the type of conflict resolver to obtain - * @return the conflict resolver - * @throws ConflictResolverNotFoundException - * if the specified type was not found - */ - ConflictResolver getConflictResolver( String type ) - throws ConflictResolverNotFoundException; -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/ConflictResolverNotFoundException.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/ConflictResolverNotFoundException.java deleted file mode 100644 index b5f61ed130e4..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/ConflictResolverNotFoundException.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.apache.maven.repository.legacy.resolver.conflict; - -/* - * 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. - */ - -/** - * Indicates that a specified conflict resolver implementation could not be found. - * - * @author Mark Hobson - * @since 3.0 - */ -public class ConflictResolverNotFoundException - extends Exception -{ - // constants -------------------------------------------------------------- - - /** The serial version ID. */ - private static final long serialVersionUID = 3372412184339653914L; - - // constructors ----------------------------------------------------------- - - /** - * Creates a new ConflictResolverNotFoundException with the specified message. - * - * @param message the message - */ - public ConflictResolverNotFoundException( String message ) - { - super( message ); - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/DefaultConflictResolver.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/DefaultConflictResolver.java deleted file mode 100644 index 76f1929db511..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/DefaultConflictResolver.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.apache.maven.repository.legacy.resolver.conflict; - -/* - * 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; - -/** - * The default conflict resolver that delegates to the nearest strategy. - * - * @author Jason van Zyl - * @see NearestConflictResolver - * @deprecated As of 3.0, use a specific implementation instead, e.g. {@link NearestConflictResolver} - */ -@Deprecated -@Component( role = ConflictResolver.class ) -public class DefaultConflictResolver - extends NearestConflictResolver -{ -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/DefaultConflictResolverFactory.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/DefaultConflictResolverFactory.java deleted file mode 100644 index 9192b1857a43..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/DefaultConflictResolverFactory.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.apache.maven.repository.legacy.resolver.conflict; - -/* - * 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.PlexusConstants; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.context.Context; -import org.codehaus.plexus.context.ContextException; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; - -/** - * A conflict resolver factory that obtains instances from a plexus container. - * - * @author Mark Hobson - * TODO you don't need the container in here with the active maps (jvz). - * @since 3.0 - */ -@Component( role = ConflictResolverFactory.class ) -public class DefaultConflictResolverFactory - implements ConflictResolverFactory, Contextualizable -{ - // fields ----------------------------------------------------------------- - - /** - * The plexus container used to obtain instances from. - */ - @Requirement - private PlexusContainer container; - - // ConflictResolverFactory methods ---------------------------------------- - - /* - * @see org.apache.maven.artifact.resolver.conflict.ConflictResolverFactory#getConflictResolver(java.lang.String) - */ - - public ConflictResolver getConflictResolver( String type ) - throws ConflictResolverNotFoundException - { - try - { - return (ConflictResolver) container.lookup( ConflictResolver.ROLE, type ); - } - catch ( ComponentLookupException exception ) - { - throw new ConflictResolverNotFoundException( "Cannot find conflict resolver of type: " + type ); - } - } - - // Contextualizable methods ----------------------------------------------- - - /* - * @see org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable#contextualize(org.codehaus.plexus.context.Context) - */ - - public void contextualize( Context context ) - throws ContextException - { - container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/FarthestConflictResolver.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/FarthestConflictResolver.java deleted file mode 100644 index 726e9a6db446..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/FarthestConflictResolver.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.apache.maven.repository.legacy.resolver.conflict; - -/* - * 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.artifact.resolver.ResolutionNode; -import org.codehaus.plexus.component.annotations.Component; - -/** - * Resolves conflicting artifacts by always selecting the farthest declaration. Farthest is defined as the - * declaration that has the most transitive steps away from the project being built. - * - * @author Mark Hobson - * @since 3.0 - */ -@Component( role = ConflictResolver.class, hint = "farthest" ) -public class FarthestConflictResolver - implements ConflictResolver -{ - // ConflictResolver methods ----------------------------------------------- - - /* - * @see org.apache.maven.artifact.resolver.conflict.ConflictResolver#resolveConflict(org.apache.maven.artifact.resolver.ResolutionNode, - * org.apache.maven.artifact.resolver.ResolutionNode) - */ - - public ResolutionNode resolveConflict( ResolutionNode node1, ResolutionNode node2 ) - { - return node1.getDepth() >= node2.getDepth() ? node1 : node2; - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/NewestConflictResolver.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/NewestConflictResolver.java deleted file mode 100644 index e5bf55801efd..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/NewestConflictResolver.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.apache.maven.repository.legacy.resolver.conflict; - -/* - * 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.artifact.resolver.ResolutionNode; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.OverConstrainedVersionException; -import org.codehaus.plexus.component.annotations.Component; - -/** - * Resolves conflicting artifacts by always selecting the newest declaration. Newest is defined as the - * declaration whose version is greater according to ArtifactVersion.compareTo. - * - * @author Mark Hobson - * @see ArtifactVersion#compareTo - * @since 3.0 - */ -@Component( role = ConflictResolver.class, hint = "newest" ) -public class NewestConflictResolver - implements ConflictResolver -{ - // ConflictResolver methods ----------------------------------------------- - - /* - * @see org.apache.maven.artifact.resolver.conflict.ConflictResolver#resolveConflict(org.apache.maven.artifact.resolver.ResolutionNode, - * org.apache.maven.artifact.resolver.ResolutionNode) - */ - - public ResolutionNode resolveConflict( ResolutionNode node1, ResolutionNode node2 ) - { - try - { - ArtifactVersion version1 = node1.getArtifact().getSelectedVersion(); - ArtifactVersion version2 = node2.getArtifact().getSelectedVersion(); - - return version1.compareTo( version2 ) > 0 ? node1 : node2; - } - catch ( OverConstrainedVersionException exception ) - { - // TODO log message or throw exception? - - return null; - } - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/OldestConflictResolver.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/OldestConflictResolver.java deleted file mode 100644 index d5e880c86ae1..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/OldestConflictResolver.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.apache.maven.repository.legacy.resolver.conflict; - -/* - * 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.artifact.resolver.ResolutionNode; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.OverConstrainedVersionException; -import org.codehaus.plexus.component.annotations.Component; - -/** - * Resolves conflicting artifacts by always selecting the oldest declaration. Oldest is defined as the - * declaration whose version is less according to ArtifactVersion.compareTo. - * - * @author Mark Hobson - * @see ArtifactVersion#compareTo - * @since 3.0 - */ -@Component( role = ConflictResolver.class, hint = "oldest" ) -public class OldestConflictResolver - implements ConflictResolver -{ - // ConflictResolver methods ----------------------------------------------- - - /* - * @see org.apache.maven.artifact.resolver.conflict.ConflictResolver#resolveConflict(org.apache.maven.artifact.resolver.ResolutionNode, - * org.apache.maven.artifact.resolver.ResolutionNode) - */ - - public ResolutionNode resolveConflict( ResolutionNode node1, ResolutionNode node2 ) - { - try - { - ArtifactVersion version1 = node1.getArtifact().getSelectedVersion(); - ArtifactVersion version2 = node2.getArtifact().getSelectedVersion(); - - return version1.compareTo( version2 ) <= 0 ? node1 : node2; - } - catch ( OverConstrainedVersionException exception ) - { - // TODO log message or throw exception? - - return null; - } - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/AbstractVersionTransformation.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/AbstractVersionTransformation.java deleted file mode 100644 index 1ce54580b92d..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/AbstractVersionTransformation.java +++ /dev/null @@ -1,135 +0,0 @@ -package org.apache.maven.repository.legacy.resolver.transform; - -/* - * 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.List; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.DefaultRepositoryRequest; -import org.apache.maven.artifact.repository.RepositoryRequest; -import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; -import org.apache.maven.artifact.repository.metadata.Metadata; -import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; -import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager; -import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; -import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; -import org.apache.maven.artifact.repository.metadata.Versioning; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.apache.maven.repository.legacy.WagonManager; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.logging.AbstractLogEnabled; - -/** - * Describes a version transformation during artifact resolution. - * - * @author Brett Porter - * TODO try and refactor to remove abstract methods - not particular happy about current design - */ -public abstract class AbstractVersionTransformation - extends AbstractLogEnabled - implements ArtifactTransformation -{ - @Requirement - protected RepositoryMetadataManager repositoryMetadataManager; - - @Requirement - protected WagonManager wagonManager; - - public void transformForResolve( Artifact artifact, List remoteRepositories, - ArtifactRepository localRepository ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - RepositoryRequest request = new DefaultRepositoryRequest(); - request.setLocalRepository( localRepository ); - request.setRemoteRepositories( remoteRepositories ); - transformForResolve( artifact, request ); - } - - protected String resolveVersion( Artifact artifact, ArtifactRepository localRepository, - List remoteRepositories ) - throws RepositoryMetadataResolutionException - { - RepositoryRequest request = new DefaultRepositoryRequest(); - request.setLocalRepository( localRepository ); - request.setRemoteRepositories( remoteRepositories ); - return resolveVersion( artifact, request ); - } - - protected String resolveVersion( Artifact artifact, RepositoryRequest request ) - throws RepositoryMetadataResolutionException - { - RepositoryMetadata metadata; - // Don't use snapshot metadata for LATEST (which isSnapshot returns true for) - if ( !artifact.isSnapshot() || Artifact.LATEST_VERSION.equals( artifact.getBaseVersion() ) ) - { - metadata = new ArtifactRepositoryMetadata( artifact ); - } - else - { - metadata = new SnapshotArtifactRepositoryMetadata( artifact ); - } - - repositoryMetadataManager.resolve( metadata, request ); - - artifact.addMetadata( metadata ); - - Metadata repoMetadata = metadata.getMetadata(); - String version = null; - if ( repoMetadata != null && repoMetadata.getVersioning() != null ) - { - version = constructVersion( repoMetadata.getVersioning(), artifact.getBaseVersion() ); - } - - if ( version == null ) - { - // use the local copy, or if it doesn't exist - go to the remote repo for it - version = artifact.getBaseVersion(); - } - - // TODO also do this logging for other metadata? - // TODO figure out way to avoid duplicated message - if ( getLogger().isDebugEnabled() ) - { - if ( !version.equals( artifact.getBaseVersion() ) ) - { - String message = artifact.getArtifactId() + ": resolved to version " + version; - if ( artifact.getRepository() != null ) - { - message += " from repository " + artifact.getRepository().getId(); - } - else - { - message += " from local repository"; - } - getLogger().debug( message ); - } - else - { - // Locally installed file is newer, don't use the resolved version - getLogger().debug( artifact.getArtifactId() + ": using locally installed snapshot" ); - } - } - return version; - } - - protected abstract String constructVersion( Versioning versioning, String baseVersion ); -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ArtifactTransformation.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ArtifactTransformation.java deleted file mode 100644 index 42604d7549ff..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ArtifactTransformation.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.apache.maven.repository.legacy.resolver.transform; - -/* - * 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.List; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.deployer.ArtifactDeploymentException; -import org.apache.maven.artifact.installer.ArtifactInstallationException; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.RepositoryRequest; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; - -/** - * @author Jason van Zyl - */ -public interface ArtifactTransformation -{ - String ROLE = ArtifactTransformation.class.getName(); - - /** - * Take in a artifact and return the transformed artifact for locating in the remote repository. If no - * transformation has occurred the original artifact is returned. - * - * @param artifact Artifact to be transformed. - * @param request the repositories to check - */ - void transformForResolve( Artifact artifact, RepositoryRequest request ) - throws ArtifactResolutionException, ArtifactNotFoundException; - - /** - * Take in a artifact and return the transformed artifact for locating in the remote repository. If no - * transformation has occurred the original artifact is returned. - * - * @param artifact Artifact to be transformed. - * @param remoteRepositories the repositories to check - * @param localRepository the local repository - */ - void transformForResolve( Artifact artifact, - List remoteRepositories, - ArtifactRepository localRepository ) - throws ArtifactResolutionException, ArtifactNotFoundException; - - /** - * Take in a artifact and return the transformed artifact for locating in the local repository. If no - * transformation has occurred the original artifact is returned. - * - * @param artifact Artifact to be transformed. - * @param localRepository the local repository it will be stored in - */ - void transformForInstall( Artifact artifact, - ArtifactRepository localRepository ) - throws ArtifactInstallationException; - - /** - * Take in a artifact and return the transformed artifact for distributing to remote repository. If no - * transformation has occurred the original artifact is returned. - * - * @param artifact Artifact to be transformed. - * @param remoteRepository the repository to deploy to - * @param localRepository the local repository - */ - void transformForDeployment( Artifact artifact, - ArtifactRepository remoteRepository, - ArtifactRepository localRepository ) - throws ArtifactDeploymentException; - -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ArtifactTransformationManager.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ArtifactTransformationManager.java deleted file mode 100644 index ed3ee9a62b2c..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ArtifactTransformationManager.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.apache.maven.repository.legacy.resolver.transform; - -/* - * 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.List; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.deployer.ArtifactDeploymentException; -import org.apache.maven.artifact.installer.ArtifactInstallationException; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.RepositoryRequest; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; - -/** - * Manages multiple ArtifactTransformation instances and applies them in succession. - */ -public interface ArtifactTransformationManager -{ - String ROLE = ArtifactTransformationManager.class.getName(); - - /** - * Take in a artifact and return the transformed artifact for locating in the remote repository. If no - * transformation has occurred the original artifact is returned. - * - * @param artifact Artifact to be transformed. - * @param request the repositories to check - */ - void transformForResolve( Artifact artifact, RepositoryRequest request ) - throws ArtifactResolutionException, ArtifactNotFoundException; - - /** - * Take in a artifact and return the transformed artifact for locating in the remote repository. If no - * transformation has occurred the original artifact is returned. - * - * @param artifact Artifact to be transformed. - * @param remoteRepositories the repositories to check - * @param localRepository the local repository - */ - void transformForResolve( Artifact artifact, List remoteRepositories, - ArtifactRepository localRepository ) - throws ArtifactResolutionException, ArtifactNotFoundException; - - /** - * Take in a artifact and return the transformed artifact for locating in the local repository. If no - * transformation has occurred the original artifact is returned. - * - * @param artifact Artifact to be transformed. - * @param localRepository the local repository it will be stored in - */ - void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) - throws ArtifactInstallationException; - - /** - * Take in a artifact and return the transformed artifact for distributing to a remote repository. If no - * transformation has occurred the original artifact is returned. - * - * @param artifact Artifact to be transformed. - * @param remoteRepository the repository to deploy to - * @param localRepository the local repository the metadata is stored in - */ - void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, - ArtifactRepository localRepository ) - throws ArtifactDeploymentException; - - List getArtifactTransformations(); -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/DefaultArtifactTransformationManager.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/DefaultArtifactTransformationManager.java deleted file mode 100644 index 024778de9a45..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/DefaultArtifactTransformationManager.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.apache.maven.repository.legacy.resolver.transform; - -/* - * 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.List; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.deployer.ArtifactDeploymentException; -import org.apache.maven.artifact.installer.ArtifactInstallationException; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.RepositoryRequest; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; - -/** - * @author Jason van Zyl - */ -@Component( role = ArtifactTransformationManager.class ) -public class DefaultArtifactTransformationManager - implements ArtifactTransformationManager -{ - @Requirement( role = ArtifactTransformation.class, hints = { "release", "latest", "snapshot" } ) - private List artifactTransformations; - - public void transformForResolve( Artifact artifact, RepositoryRequest request ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - for ( ArtifactTransformation transform : artifactTransformations ) - { - transform.transformForResolve( artifact, request ); - } - } - - public void transformForResolve( Artifact artifact, List remoteRepositories, - ArtifactRepository localRepository ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - for ( ArtifactTransformation transform : artifactTransformations ) - { - transform.transformForResolve( artifact, remoteRepositories, localRepository ); - } - } - - public void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) - throws ArtifactInstallationException - { - for ( ArtifactTransformation transform : artifactTransformations ) - { - transform.transformForInstall( artifact, localRepository ); - } - } - - public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, - ArtifactRepository localRepository ) - throws ArtifactDeploymentException - { - for ( ArtifactTransformation transform : artifactTransformations ) - { - transform.transformForDeployment( artifact, remoteRepository, localRepository ); - } - } - - public List getArtifactTransformations() - { - return artifactTransformations; - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/LatestArtifactTransformation.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/LatestArtifactTransformation.java deleted file mode 100644 index 0bc89c19f07f..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/LatestArtifactTransformation.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.apache.maven.repository.legacy.resolver.transform; - -/* - * 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.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.RepositoryRequest; -import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; -import org.apache.maven.artifact.repository.metadata.Versioning; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.codehaus.plexus.component.annotations.Component; - -/** - * Describes a version transformation during artifact resolution - "latest" type - */ -@Component( role = ArtifactTransformation.class, hint = "latest" ) -public class LatestArtifactTransformation - extends AbstractVersionTransformation -{ - - public void transformForResolve( Artifact artifact, RepositoryRequest request ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - if ( Artifact.LATEST_VERSION.equals( artifact.getVersion() ) ) - { - try - { - String version = resolveVersion( artifact, request ); - if ( Artifact.LATEST_VERSION.equals( version ) ) - { - throw new ArtifactNotFoundException( "Unable to determine the latest version", artifact ); - } - - artifact.setBaseVersion( version ); - artifact.updateVersion( version, request.getLocalRepository() ); - } - catch ( RepositoryMetadataResolutionException e ) - { - throw new ArtifactResolutionException( e.getMessage(), artifact, e ); - } - } - } - - public void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) - { - // metadata is added via addPluginArtifactMetadata - } - - public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, - ArtifactRepository localRepository ) - { - // metadata is added via addPluginArtifactMetadata - } - - protected String constructVersion( Versioning versioning, String baseVersion ) - { - return versioning.getLatest(); - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ReleaseArtifactTransformation.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ReleaseArtifactTransformation.java deleted file mode 100644 index b1d2c7107a5f..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ReleaseArtifactTransformation.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.apache.maven.repository.legacy.resolver.transform; - -/* - * 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.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadata; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.RepositoryRequest; -import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; -import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; -import org.apache.maven.artifact.repository.metadata.Versioning; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.codehaus.plexus.component.annotations.Component; - -/** - * Change the version RELEASE to the appropriate release version from the remote repository. - * - * @author Brett Porter - */ -@Component( role = ArtifactTransformation.class, hint = "release" ) -public class ReleaseArtifactTransformation - extends AbstractVersionTransformation -{ - - public void transformForResolve( Artifact artifact, RepositoryRequest request ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - if ( Artifact.RELEASE_VERSION.equals( artifact.getVersion() ) ) - { - try - { - String version = resolveVersion( artifact, request ); - - if ( Artifact.RELEASE_VERSION.equals( version ) ) - { - throw new ArtifactNotFoundException( "Unable to determine the release version", artifact ); - } - - artifact.setBaseVersion( version ); - artifact.updateVersion( version, request.getLocalRepository() ); - } - catch ( RepositoryMetadataResolutionException e ) - { - throw new ArtifactResolutionException( e.getMessage(), artifact, e ); - } - } - } - - public void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) - { - ArtifactMetadata metadata = createMetadata( artifact ); - - artifact.addMetadata( metadata ); - } - - public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, - ArtifactRepository localRepository ) - { - ArtifactMetadata metadata = createMetadata( artifact ); - - artifact.addMetadata( metadata ); - } - - private ArtifactMetadata createMetadata( Artifact artifact ) - { - Versioning versioning = new Versioning(); - // TODO Should this be changed for MNG-6754 too? - versioning.updateTimestamp(); - versioning.addVersion( artifact.getVersion() ); - - if ( artifact.isRelease() ) - { - versioning.setRelease( artifact.getVersion() ); - } - - return new ArtifactRepositoryMetadata( artifact, versioning ); - } - - protected String constructVersion( Versioning versioning, String baseVersion ) - { - return versioning.getRelease(); - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/SnapshotTransformation.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/SnapshotTransformation.java deleted file mode 100644 index 1a79049b17e4..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/SnapshotTransformation.java +++ /dev/null @@ -1,174 +0,0 @@ -package org.apache.maven.repository.legacy.resolver.transform; - -/* - * 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.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.TimeZone; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.deployer.ArtifactDeploymentException; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.RepositoryRequest; -import org.apache.maven.artifact.repository.metadata.Metadata; -import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; -import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; -import org.apache.maven.artifact.repository.metadata.Snapshot; -import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; -import org.apache.maven.artifact.repository.metadata.Versioning; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.util.StringUtils; - -/** - * @author Brett Porter - * @author Michal Maczka - */ -@Component( role = ArtifactTransformation.class, hint = "snapshot" ) -public class SnapshotTransformation - extends AbstractVersionTransformation -{ - private static final String DEFAULT_SNAPSHOT_TIMESTAMP_FORMAT = "yyyyMMdd.HHmmss"; - - private static final TimeZone DEFAULT_SNAPSHOT_TIME_ZONE = TimeZone.getTimeZone( "Etc/UTC" ); - - private String deploymentTimestamp; - - public void transformForResolve( Artifact artifact, RepositoryRequest request ) - throws ArtifactResolutionException - { - // Only select snapshots that are unresolved (eg 1.0-SNAPSHOT, not 1.0-20050607.123456) - if ( artifact.isSnapshot() && artifact.getBaseVersion().equals( artifact.getVersion() ) ) - { - try - { - String version = resolveVersion( artifact, request ); - artifact.updateVersion( version, request.getLocalRepository() ); - } - catch ( RepositoryMetadataResolutionException e ) - { - throw new ArtifactResolutionException( e.getMessage(), artifact, e ); - } - } - } - - public void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) - { - if ( artifact.isSnapshot() ) - { - Snapshot snapshot = new Snapshot(); - snapshot.setLocalCopy( true ); - RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot ); - - artifact.addMetadata( metadata ); - } - } - - public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, - ArtifactRepository localRepository ) - throws ArtifactDeploymentException - { - if ( artifact.isSnapshot() ) - { - Snapshot snapshot = new Snapshot(); - - // TODO Should this be changed for MNG-6754 too? - snapshot.setTimestamp( getDeploymentTimestamp() ); - - // we update the build number anyway so that it doesn't get lost. It requires the timestamp to take effect - try - { - int buildNumber = resolveLatestSnapshotBuildNumber( artifact, localRepository, remoteRepository ); - - snapshot.setBuildNumber( buildNumber + 1 ); - } - catch ( RepositoryMetadataResolutionException e ) - { - throw new ArtifactDeploymentException( "Error retrieving previous build number for artifact '" - + artifact.getDependencyConflictId() + "': " + e.getMessage(), e ); - } - - RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot ); - - artifact.setResolvedVersion( - constructVersion( metadata.getMetadata().getVersioning(), artifact.getBaseVersion() ) ); - - artifact.addMetadata( metadata ); - } - } - - public String getDeploymentTimestamp() - { - if ( deploymentTimestamp == null ) - { - deploymentTimestamp = getUtcDateFormatter().format( new Date() ); - } - return deploymentTimestamp; - } - - protected String constructVersion( Versioning versioning, String baseVersion ) - { - String version = null; - Snapshot snapshot = versioning.getSnapshot(); - if ( snapshot != null ) - { - if ( snapshot.getTimestamp() != null && snapshot.getBuildNumber() > 0 ) - { - String newVersion = snapshot.getTimestamp() + "-" + snapshot.getBuildNumber(); - version = StringUtils.replace( baseVersion, Artifact.SNAPSHOT_VERSION, newVersion ); - } - else - { - version = baseVersion; - } - } - return version; - } - - private int resolveLatestSnapshotBuildNumber( Artifact artifact, ArtifactRepository localRepository, - ArtifactRepository remoteRepository ) - throws RepositoryMetadataResolutionException - { - RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact ); - - getLogger().info( "Retrieving previous build number from " + remoteRepository.getId() ); - repositoryMetadataManager.resolveAlways( metadata, localRepository, remoteRepository ); - - int buildNumber = 0; - Metadata repoMetadata = metadata.getMetadata(); - if ( ( repoMetadata != null ) - && ( repoMetadata.getVersioning() != null && repoMetadata.getVersioning().getSnapshot() != null ) ) - { - buildNumber = repoMetadata.getVersioning().getSnapshot().getBuildNumber(); - } - return buildNumber; - } - - public static DateFormat getUtcDateFormatter() - { - DateFormat utcDateFormatter = new SimpleDateFormat( DEFAULT_SNAPSHOT_TIMESTAMP_FORMAT ); - utcDateFormatter.setCalendar( new GregorianCalendar() ); - utcDateFormatter.setTimeZone( DEFAULT_SNAPSHOT_TIME_ZONE ); - return utcDateFormatter; - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/ArtifactMetadata.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/ArtifactMetadata.java deleted file mode 100644 index 13b00c3a6d6a..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/ArtifactMetadata.java +++ /dev/null @@ -1,344 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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 org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.ArtifactScopeEnum; - -/** - * Artifact Metadata that is resolved independent of Artifact itself. - * - * @author Oleg Gusakov - */ -public class ArtifactMetadata -{ - /** - * standard glorified artifact coordinates - */ - protected String groupId; - protected String artifactId; - protected String version; - protected String type; - protected ArtifactScopeEnum artifactScope; - protected String classifier; - - /** - * explanation: why this MD was chosen over it's siblings - * in the resulting structure (classpath for now) - */ - protected String why; - - /** dependencies of the artifact behind this metadata */ - protected Collection dependencies; - - /** metadata URI */ - protected String uri; - - /** is metadata found anywhere */ - protected boolean resolved = false; - - /** does the actual artifact for this metadata exists */ - protected boolean artifactExists = false; - /** artifact URI */ - protected String artifactUri; - - /** error message */ - private String error; - - //------------------------------------------------------------------ - /** - * - */ - public ArtifactMetadata( String name ) - { - if ( name == null ) - { - return; - } - int ind1 = name.indexOf( ':' ); - int ind2 = name.lastIndexOf( ':' ); - - if ( ind1 == -1 || ind2 == -1 ) - { - return; - } - - this.groupId = name.substring( 0, ind1 ); - if ( ind1 == ind2 ) - { - this.artifactId = name.substring( ind1 + 1 ); - } - else - { - this.artifactId = name.substring( ind1 + 1, ind2 ); - this.version = name.substring( ind2 + 1 ); - } - } - - public ArtifactMetadata( String groupId, String name, String version ) - { - this( groupId, name, version, null ); - } - - public ArtifactMetadata( String groupId, String name, String version, String type ) - { - this( groupId, name, version, type, null ); - } - - public ArtifactMetadata( String groupId, String name, String version, String type, ArtifactScopeEnum artifactScope ) - { - this( groupId, name, version, type, artifactScope, null ); - } - - public ArtifactMetadata( String groupId, String name, String version, String type, ArtifactScopeEnum artifactScope, - String classifier ) - { - this( groupId, name, version, type, artifactScope, classifier, null ); - } - - public ArtifactMetadata( String groupId, String name, String version, String type, ArtifactScopeEnum artifactScope, - String classifier, String artifactUri ) - { - this( groupId, name, version, type, artifactScope, classifier, artifactUri, null, true, null ); - } - - @SuppressWarnings( "checkstyle:parameternumber" ) - public ArtifactMetadata( String groupId, String name, String version, String type, ArtifactScopeEnum artifactScope, - String classifier, String artifactUri, String why, boolean resolved, String error ) - { - this.groupId = groupId; - this.artifactId = name; - this.version = version; - this.type = type; - this.artifactScope = artifactScope; - this.classifier = classifier; - this.artifactUri = artifactUri; - this.why = why; - this.resolved = resolved; - this.error = error; - } - - @SuppressWarnings( "checkstyle:parameternumber" ) - public ArtifactMetadata( String groupId, String name, String version, String type, String scopeString, - String classifier, String artifactUri, String why, boolean resolved, String error ) - { - this( groupId, name, version, type, - scopeString == null ? ArtifactScopeEnum.DEFAULT_SCOPE : ArtifactScopeEnum.valueOf( scopeString ), - classifier, artifactUri, why, resolved, error ); - } - - public ArtifactMetadata( Artifact af ) - { - /* - if ( af != null ) - { - init( af ); - } - */ - } - //------------------------------------------------------------------ -// public void init( ArtifactMetadata af ) -// { -// setGroupId( af.getGroupId() ); -// setArtifactId( af.getArtifactId() ); -// setVersion( af.getVersion() ); -// setType( af.getType() ); -// setScope( af.getScope() ); -// setClassifier( af.getClassifier() ); -// //setUri( af.getDownloadUrl() ); -// -// this.resolved = af.isResolved(); -// } - - @Override - public String toString() - { - return groupId + ":" + artifactId + ":" + version; - } - - public String toDomainString() - { - return groupId + ":" + artifactId; - } - - public String getGroupId() - { - return groupId; - } - - public void setGroupId( String groupId ) - { - this.groupId = groupId; - } - - public String getArtifactId() - { - return artifactId; - } - - public void setArtifactId( String name ) - { - this.artifactId = name; - } - - public String getVersion() - { - return version; - } - - public void setVersion( String version ) - { - this.version = version; - } - - public String getType() - { - return type; - } - - public String getCheckedType() - { - return type == null ? "jar" : type; - } - - public void setType( String type ) - { - this.type = type; - } - - public ArtifactScopeEnum getArtifactScope() - { - return artifactScope == null ? ArtifactScopeEnum.DEFAULT_SCOPE : artifactScope; - } - - public void setArtifactScope( ArtifactScopeEnum artifactScope ) - { - this.artifactScope = artifactScope; - } - - public void setScope( String scope ) - { - this.artifactScope = scope == null ? ArtifactScopeEnum.DEFAULT_SCOPE : ArtifactScopeEnum.valueOf( scope ); - } - - public String getClassifier() - { - return classifier; - } - - public void setClassifier( String classifier ) - { - this.classifier = classifier; - } - - public boolean isResolved() - { - return resolved; - } - - public void setResolved( boolean resolved ) - { - this.resolved = resolved; - } - - public String getUri() - { - return uri; - } - - public void setUri( String uri ) - { - this.uri = uri; - } - - public String getScope() - { - return getArtifactScope().getScope(); - } - - public ArtifactScopeEnum getScopeAsEnum() - { - return artifactScope == null ? ArtifactScopeEnum.DEFAULT_SCOPE : artifactScope; - } - - public boolean isArtifactExists() - { - return artifactExists; - } - - public void setArtifactExists( boolean artifactExists ) - { - this.artifactExists = artifactExists; - } - - - public Collection getDependencies() - { - return dependencies; - } - - public void setDependencies( Collection dependencies ) - { - this.dependencies = dependencies; - } - - public String getArtifactUri() - { - return artifactUri; - } - - public void setArtifactUri( String artifactUri ) - { - this.artifactUri = artifactUri; - } - - - public String getWhy() - { - return why; - } - - public void setWhy( String why ) - { - this.why = why; - } - - public String getError() - { - return error; - } - - public void setError( String error ) - { - this.error = error; - } - - public boolean isError() - { - return error == null; - } - - public String getDependencyConflictId() - { - return groupId + ":" + artifactId; - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/ClasspathContainer.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/ClasspathContainer.java deleted file mode 100644 index 0630b68589d6..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/ClasspathContainer.java +++ /dev/null @@ -1,144 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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.Iterator; -import java.util.List; - -import org.apache.maven.artifact.ArtifactScopeEnum; - -/** - * classpath container that is aware of the classpath scope - * - * @author Oleg Gusakov - * - */ -public class ClasspathContainer -implements Iterable -{ - private List classpath; - - private ArtifactScopeEnum scope; - - // ------------------------------------------------------------------------------------------- - public ClasspathContainer( ArtifactScopeEnum scope ) - { - this.scope = ArtifactScopeEnum.checkScope( scope ); - } - - // ------------------------------------------------------------------------------------------- - public ClasspathContainer( List classpath, ArtifactScopeEnum scope ) - { - this( scope ); - this.classpath = classpath; - } - - // ------------------------------------------------------------------------------------------- - public Iterator iterator() - { - return classpath == null ? null : classpath.iterator(); - } - - // ------------------------------------------------------------------------------------------- - public ClasspathContainer add( ArtifactMetadata md ) - { - if ( classpath == null ) - { - classpath = new ArrayList<>( 16 ); - } - - classpath.add( md ); - - return this; - } - - // ------------------------------------------------------------------------------------------- - public List getClasspath() - { - return classpath; - } - - // ------------------------------------------------------------------------------------------- - public MetadataTreeNode getClasspathAsTree() - throws MetadataResolutionException - { - if ( classpath == null || classpath.size() < 1 ) - { - return null; - } - - MetadataTreeNode tree = null; - MetadataTreeNode parent = null; - - for ( ArtifactMetadata md : classpath ) - { - MetadataTreeNode node = new MetadataTreeNode( md, parent, md.isResolved(), md.getArtifactScope() ); - if ( tree == null ) - { - tree = node; - } - - if ( parent != null ) - { - parent.setNChildren( 1 ); - parent.addChild( 0, node ); - } - - parent = node; - - } - return tree; - } - - public void setClasspath( List classpath ) - { - this.classpath = classpath; - } - - public ArtifactScopeEnum getScope() - { - return scope; - } - - public void setScope( ArtifactScopeEnum scope ) - { - this.scope = scope; - } - - // ------------------------------------------------------------------------------------------- - @Override - public String toString() - { - StringBuilder sb = new StringBuilder( 256 ); - sb.append( "[scope=" ).append( scope.getScope() ); - if ( classpath != null ) - { - for ( ArtifactMetadata md : classpath ) - { - sb.append( ": " ).append( md.toString() ).append( '{' ).append( md.getArtifactUri() ).append( '}' ); - } - } - sb.append( ']' ); - return sb.toString(); - } - // ------------------------------------------------------------------------------------------- - // ------------------------------------------------------------------------------------------- -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/ClasspathTransformation.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/ClasspathTransformation.java deleted file mode 100644 index eece41330231..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/ClasspathTransformation.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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.artifact.ArtifactScopeEnum; - -/** - * Helper class to conver an Md Graph into some form of a classpath - * - * @author Oleg Gusakov - * - */ -public interface ClasspathTransformation -{ - String ROLE = ClasspathTransformation.class.getName(); - - /** - * Transform Graph into a Collection of metadata objects that - * could serve as a classpath for a particular scope - * - * @param dirtyGraph - dependency graph - * @param scope - which classpath to extract - * @param resolve - whether to resolve artifacts. - * @return Collection of metadata objects in the linked subgraph of the graph which - * contains the graph.getEntry() vertice - */ - ClasspathContainer transform( MetadataGraph dirtyGraph, ArtifactScopeEnum scope, boolean resolve ) - throws MetadataGraphTransformationException; -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultClasspathTransformation.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultClasspathTransformation.java deleted file mode 100644 index a2bac9ccac64..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultClasspathTransformation.java +++ /dev/null @@ -1,173 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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.Arrays; -import java.util.List; - -import org.apache.maven.artifact.ArtifactScopeEnum; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; - -/** - * default implementation of the metadata classpath transformer - * - * @author Oleg Gusakov - * - */ -@Component( role = ClasspathTransformation.class ) -public class DefaultClasspathTransformation - implements ClasspathTransformation -{ - @Requirement - GraphConflictResolver conflictResolver; - - //---------------------------------------------------------------------------------------------------- - public ClasspathContainer transform( MetadataGraph dirtyGraph, ArtifactScopeEnum scope, boolean resolve ) - throws MetadataGraphTransformationException - { - try - { - if ( dirtyGraph == null || dirtyGraph.isEmpty() ) - { - return null; - } - - MetadataGraph cleanGraph = conflictResolver.resolveConflicts( dirtyGraph, scope ); - - if ( cleanGraph == null || cleanGraph.isEmpty() ) - { - return null; - } - - ClasspathContainer cpc = new ClasspathContainer( scope ); - if ( cleanGraph.isEmptyEdges() ) - { - // single entry in the classpath, populated from itself - ArtifactMetadata amd = cleanGraph.getEntry().getMd(); - cpc.add( amd ); - } - else - { - ClasspathGraphVisitor v = new ClasspathGraphVisitor( cleanGraph, cpc ); - MetadataGraphVertex entry = cleanGraph.getEntry(); - // entry point - v.visit( entry ); - } - - return cpc; - } - catch ( GraphConflictResolutionException e ) - { - throw new MetadataGraphTransformationException( e ); - } - } - - //=================================================================================================== - /** - * Helper class to traverse graph. Required to make the containing method thread-safe - * and yet use class level data to lessen stack usage in recursion - */ - private class ClasspathGraphVisitor - { - MetadataGraph graph; - - ClasspathContainer cpc; - - List visited; - - // ----------------------------------------------------------------------- - protected ClasspathGraphVisitor( MetadataGraph cleanGraph, ClasspathContainer cpc ) - { - this.cpc = cpc; - this.graph = cleanGraph; - - visited = new ArrayList<>( cleanGraph.getVertices().size() ); - } - - // ----------------------------------------------------------------------- - protected void visit( MetadataGraphVertex node ) // , String version, String artifactUri ) - { - ArtifactMetadata md = node.getMd(); - if ( visited.contains( node ) ) - { - return; - } - - cpc.add( md ); -// -// TreeSet deps = new TreeSet( -// new Comparator() -// { -// public int compare( MetadataGraphEdge e1 -// , MetadataGraphEdge e2 -// ) -// { -// if( e1.getDepth() == e2.getDepth() ) -// { -// if( e2.getPomOrder() == e1.getPomOrder() ) -// return e1.getTarget().toString().compareTo(e2.getTarget().toString() ); -// -// return e2.getPomOrder() - e1.getPomOrder(); -// } -// -// return e2.getDepth() - e1.getDepth(); -// } -// } -// ); - - List exits = graph.getExcidentEdges( node ); - - if ( exits != null && exits.size() > 0 ) - { - MetadataGraphEdge[] sortedExits = exits.toArray( new MetadataGraphEdge[0] ); - Arrays.sort( sortedExits, ( e1, e2 ) -> - { - if ( e1.getDepth() == e2.getDepth() ) - { - if ( e2.getPomOrder() == e1.getPomOrder() ) - { - return e1.getTarget().toString().compareTo( e2.getTarget().toString() ); - } - return e2.getPomOrder() - e1.getPomOrder(); - } - return e2.getDepth() - e1.getDepth(); - } ); - - for ( MetadataGraphEdge e : sortedExits ) - { - MetadataGraphVertex targetNode = e.getTarget(); - targetNode.getMd().setArtifactScope( e.getScope() ); - targetNode.getMd().setWhy( e.getSource().getMd().toString() ); - visit( targetNode ); - } - } - - } - //----------------------------------------------------------------------- - //----------------------------------------------------------------------- - } - //---------------------------------------------------------------------------------------------------- - //---------------------------------------------------------------------------------------------------- -} - - - diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolutionPolicy.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolutionPolicy.java deleted file mode 100644 index bb7642272e09..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolutionPolicy.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Configuration; - -/** - * @author Oleg Gusakov - * - */ -@Component( role = GraphConflictResolutionPolicy.class ) -public class DefaultGraphConflictResolutionPolicy - implements GraphConflictResolutionPolicy -{ - /** - * artifact, closer to the entry point, is selected - */ - @Configuration( name = "closer-first", value = "true" ) - private boolean closerFirst = true; - - /** - * newer artifact is selected - */ - @Configuration( name = "newer-first", value = "true" ) - private boolean newerFirst = true; - - public MetadataGraphEdge apply( MetadataGraphEdge e1, MetadataGraphEdge e2 ) - { - int depth1 = e1.getDepth(); - int depth2 = e2.getDepth(); - - if ( depth1 == depth2 ) - { - ArtifactVersion v1 = new DefaultArtifactVersion( e1.getVersion() ); - ArtifactVersion v2 = new DefaultArtifactVersion( e2.getVersion() ); - - if ( newerFirst ) - { - return v1.compareTo( v2 ) > 0 ? e1 : e2; - } - - return v1.compareTo( v2 ) > 0 ? e2 : e1; - } - - if ( closerFirst ) - { - return depth1 < depth2 ? e1 : e2; - } - - return depth1 < depth2 ? e2 : e1; - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolver.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolver.java deleted file mode 100644 index 9a27bf44dc11..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolver.java +++ /dev/null @@ -1,249 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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.List; -import java.util.TreeSet; - -import org.apache.maven.artifact.ArtifactScopeEnum; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; - -/** - * Default conflict resolver.Implements closer newer first policy by default, but could be configured via plexus - * - * @author Oleg Gusakov - */ -@Component( role = GraphConflictResolver.class ) -public class DefaultGraphConflictResolver - implements GraphConflictResolver -{ - /** - * artifact, closer to the entry point, is selected - */ - @Requirement( role = GraphConflictResolutionPolicy.class ) - protected GraphConflictResolutionPolicy policy; - - // ------------------------------------------------------------------------------------- - // ------------------------------------------------------------------------------------- - public MetadataGraph resolveConflicts( MetadataGraph graph, ArtifactScopeEnum scope ) - throws GraphConflictResolutionException - { - if ( policy == null ) - { - throw new GraphConflictResolutionException( "no GraphConflictResolutionPolicy injected" ); - } - - if ( graph == null ) - { - return null; - } - - final MetadataGraphVertex entry = graph.getEntry(); - if ( entry == null ) - { - return null; - } - - if ( graph.isEmpty() ) - { - throw new GraphConflictResolutionException( "graph with an entry, but not vertices do not exist" ); - } - - if ( graph.isEmptyEdges() ) - { - return null; // no edges - nothing to worry about - } - - final TreeSet vertices = graph.getVertices(); - - try - { - // edge case - single vertex graph - if ( vertices.size() == 1 ) - { - return new MetadataGraph( entry ); - } - - final ArtifactScopeEnum requestedScope = ArtifactScopeEnum.checkScope( scope ); - - MetadataGraph res = new MetadataGraph( vertices.size() ); - res.setVersionedVertices( false ); - res.setScopedVertices( false ); - - MetadataGraphVertex resEntry = res.addVertex( entry.getMd() ); - res.setEntry( resEntry ); - - res.setScope( requestedScope ); - - for ( MetadataGraphVertex v : vertices ) - { - final List ins = graph.getIncidentEdges( v ); - final MetadataGraphEdge edge = cleanEdges( v, ins, requestedScope ); - - if ( edge == null ) - { // no edges - don't need this vertex any more - if ( entry.equals( v ) ) - { // unless it's an entry point. - // currently processing the entry point - it should not have any entry incident edges - res.getEntry().getMd().setWhy( "This is a graph entry point. No links." ); - } - else - { - // System.out.println("--->"+v.getMd().toDomainString() - // +" has been terminated on this entry set\n-------------------\n" - // +ins - // +"\n-------------------\n" - // ); - } - } - else - { - // System.out.println("+++>"+v.getMd().toDomainString()+" still has "+edge.toString() ); - // fill in domain md with actual version data - ArtifactMetadata md = v.getMd(); - ArtifactMetadata newMd = - new ArtifactMetadata( md.getGroupId(), md.getArtifactId(), edge.getVersion(), md.getType(), - md.getScopeAsEnum(), md.getClassifier(), edge.getArtifactUri(), - edge.getSource() == null ? "" : edge.getSource().getMd().toString(), - edge.isResolved(), edge.getTarget() == null ? null - : edge.getTarget().getMd().getError() ); - MetadataGraphVertex newV = res.addVertex( newMd ); - MetadataGraphVertex sourceV = res.addVertex( edge.getSource().getMd() ); - - res.addEdge( sourceV, newV, edge ); - } - } - MetadataGraph linkedRes = findLinkedSubgraph( res ); - // System.err.println("Original graph("+graph.getVertices().size()+"):\n"+graph.toString()); - // System.err.println("Cleaned("+requestedScope+") graph("+res.getVertices().size()+"):\n"+res.toString()); - // System.err.println("Linked("+requestedScope+") - // subgraph("+linkedRes.getVertices().size()+"):\n"+linkedRes.toString()); - return linkedRes; - } - catch ( MetadataResolutionException e ) - { - throw new GraphConflictResolutionException( e ); - } - } - - // ------------------------------------------------------------------------------------- - private MetadataGraph findLinkedSubgraph( MetadataGraph g ) - { - if ( g.getVertices().size() == 1 ) - { - return g; - } - - List visited = new ArrayList<>( g.getVertices().size() ); - visit( g.getEntry(), visited, g ); - - List dropList = new ArrayList<>( g.getVertices().size() ); - - // collect drop list - for ( MetadataGraphVertex v : g.getVertices() ) - { - if ( !visited.contains( v ) ) - { - dropList.add( v ); - } - } - - if ( dropList.size() < 1 ) - { - return g; - } - - // now - drop vertices - TreeSet vertices = g.getVertices(); - for ( MetadataGraphVertex v : dropList ) - { - vertices.remove( v ); - } - - return g; - } - - // ------------------------------------------------------------------------------------- - private void visit( MetadataGraphVertex from, List visited, MetadataGraph graph ) - { - if ( visited.contains( from ) ) - { - return; - } - - visited.add( from ); - - List exitList = graph.getExcidentEdges( from ); - // String s = "|---> "+from.getMd().toString()+" - "+(exitList == null ? -1 : exitList.size()) + " exit links"; - if ( exitList != null && exitList.size() > 0 ) - { - for ( MetadataGraphEdge e : graph.getExcidentEdges( from ) ) - { - visit( e.getTarget(), visited, graph ); - } - } - } - - // ------------------------------------------------------------------------------------- - private MetadataGraphEdge cleanEdges( MetadataGraphVertex v, List edges, - ArtifactScopeEnum scope ) - { - if ( edges == null || edges.isEmpty() ) - { - return null; - } - - if ( edges.size() == 1 ) - { - MetadataGraphEdge e = edges.get( 0 ); - if ( scope.encloses( e.getScope() ) ) - { - return e; - } - - return null; - } - - MetadataGraphEdge res = null; - - for ( MetadataGraphEdge e : edges ) - { - if ( !scope.encloses( e.getScope() ) ) - { - continue; - } - - if ( res == null ) - { - res = e; - } - else - { - res = policy.apply( e, res ); - } - } - - return res; - } - // ------------------------------------------------------------------------------------- - // ------------------------------------------------------------------------------------- -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/GraphConflictResolutionException.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/GraphConflictResolutionException.java deleted file mode 100644 index 035904aa8047..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/GraphConflictResolutionException.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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. - */ - -/** - * - * @author Oleg Gusakov - * - */ -public class GraphConflictResolutionException - extends Exception -{ - private static final long serialVersionUID = 2677613140287940255L; - - public GraphConflictResolutionException() - { - } - - public GraphConflictResolutionException( String message ) - { - super( message ); - } - - public GraphConflictResolutionException( Throwable cause ) - { - super( cause ); - } - - public GraphConflictResolutionException( String message, Throwable cause ) - { - super( message, cause ); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/GraphConflictResolutionPolicy.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/GraphConflictResolutionPolicy.java deleted file mode 100644 index 979d3831ff64..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/GraphConflictResolutionPolicy.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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. - */ - -/** - * MetadataGraph edge selection policy. Complements - * GraphConflictResolver by being injected into it - * - * @author Oleg Gusakov - * - */ - -public interface GraphConflictResolutionPolicy -{ - String ROLE = GraphConflictResolutionPolicy.class.getName(); - - MetadataGraphEdge apply( MetadataGraphEdge e1, MetadataGraphEdge e2 ); -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/GraphConflictResolver.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/GraphConflictResolver.java deleted file mode 100644 index ef70baa24cda..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/GraphConflictResolver.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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.artifact.ArtifactScopeEnum; - -/** - * Resolves conflicts in the supplied dependency graph. - * Different implementations will implement different conflict resolution policies. - * - * @author Oleg Gusakov - */ -public interface GraphConflictResolver -{ - String ROLE = GraphConflictResolver.class.getName(); - - /** - * Cleanses the supplied graph by leaving only one directed versioned edge\ - * between any two nodes, if multiple exists. Uses scope relationships, defined - * in ArtifactScopeEnum - * - * @param graph the "dirty" graph to be simplified via conflict resolution - * @param scope scope for which the graph should be resolved - * - * @return resulting "clean" graph for the specified scope - * - * @since 3.0 - */ - MetadataGraph resolveConflicts( MetadataGraph graph, ArtifactScopeEnum scope ) - throws GraphConflictResolutionException; -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraph.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraph.java deleted file mode 100644 index c6ec04882e34..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraph.java +++ /dev/null @@ -1,514 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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.HashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeSet; - -import org.apache.maven.artifact.ArtifactScopeEnum; - -/** - * maven dependency metadata graph - * - * @author Oleg Gusakov - * - */ -public class MetadataGraph -{ - public static final int DEFAULT_VERTICES = 32; - public static final int DEFAULT_EDGES = 64; - - // flags to indicate the granularity of vertices - private boolean versionedVertices = false; - private boolean scopedVertices = false; - /** - * the entry point we started building the graph from - */ - MetadataGraphVertex entry; - - // graph vertices - TreeSet vertices; - - /** - * incident and excident edges per node - */ - Map> incidentEdges; - Map> excidentEdges; - - /** - * null in dirty graph, actual - * scope for conflict-resolved graph - */ - ArtifactScopeEnum scope; - - //------------------------------------------------------------------------ - /** - * init graph - */ - public MetadataGraph( int nVertices ) - { - init( nVertices, 2 * nVertices ); - } - public MetadataGraph( int nVertices, int nEdges ) - { - init( nVertices, nEdges ); - } - //------------------------------------------------------------------------ - /** - * construct a single vertex - */ - public MetadataGraph( MetadataGraphVertex entry ) - throws MetadataResolutionException - { - checkVertex( entry ); - checkVertices( 1 ); - - entry.setCompareVersion( versionedVertices ); - entry.setCompareScope( scopedVertices ); - - vertices.add( entry ); - this.entry = entry; - } - //------------------------------------------------------------------------ - /** - * construct graph from a "dirty" tree - */ - public MetadataGraph( MetadataTreeNode tree ) - throws MetadataResolutionException - { - this( tree, false, false ); - } - //------------------------------------------------------------------------ - /** - * construct graph from a "dirty" tree - * - * @param tree "dirty" tree root - * @param versionedVertices true if graph nodes should be versioned (different versions -> different nodes) - * @param scopedVertices true if graph nodes should be versioned and scoped - * (different versions and/or scopes -> different nodes) - * - */ - public MetadataGraph( MetadataTreeNode tree, boolean versionedVertices, boolean scopedVertices ) - throws MetadataResolutionException - { - if ( tree == null ) - { - throw new MetadataResolutionException( "tree is null" ); - } - - setVersionedVertices( versionedVertices ); - setScopedVertices( scopedVertices ); - - this.versionedVertices = scopedVertices || versionedVertices; - this.scopedVertices = scopedVertices; - - int count = countNodes( tree ); - - init( count, count + ( count / 2 ) ); - - processTreeNodes( null, tree, 0, 0 ); - } - //------------------------------------------------------------------------ - private void processTreeNodes( MetadataGraphVertex parentVertex, MetadataTreeNode node, int depth, int pomOrder ) - throws MetadataResolutionException - { - if ( node == null ) - { - return; - } - - MetadataGraphVertex vertex = new MetadataGraphVertex( node.md, versionedVertices, scopedVertices ); - if ( !vertices.contains( vertex ) ) - { - vertices.add( vertex ); - } - - if ( parentVertex != null ) // then create the edge - { - ArtifactMetadata md = node.getMd(); - MetadataGraphEdge e = - new MetadataGraphEdge( md.version, md.resolved, md.artifactScope, md.artifactUri, depth, pomOrder ); - addEdge( parentVertex, vertex, e ); - } - else - { - entry = vertex; - } - - MetadataTreeNode[] kids = node.getChildren(); - if ( kids == null || kids.length < 1 ) - { - return; - } - - for ( int i = 0; i < kids.length; i++ ) - { - MetadataTreeNode n = kids[i]; - processTreeNodes( vertex, n, depth + 1, i ); - } - } - //------------------------------------------------------------------------ - public MetadataGraphVertex findVertex( ArtifactMetadata md ) - { - if ( md == null || vertices == null || vertices.size() < 1 ) - { - return null; - } - - MetadataGraphVertex v = new MetadataGraphVertex( md ); - v.setCompareVersion( versionedVertices ); - v.setCompareScope( scopedVertices ); - - for ( MetadataGraphVertex gv : vertices ) - { - if ( gv.equals( v ) ) - { - return gv; - } - } - - return null; - } - //------------------------------------------------------------------------ - public MetadataGraphVertex addVertex( ArtifactMetadata md ) - { - if ( md == null ) - { - return null; - } - - checkVertices(); - - MetadataGraphVertex v = findVertex( md ); - if ( v != null ) - { - return v; - } - - v = new MetadataGraphVertex( md ); - - v.setCompareVersion( versionedVertices ); - v.setCompareScope( scopedVertices ); - - vertices.add( v ); - return v; - } - //------------------------------------------------------------------------ - /** - * init graph - */ - private void init( int nVertices, int nEdges ) - { - int nV = nVertices; - if ( nVertices < 1 ) - { - nV = 1; - } - - checkVertices( nV ); - - int nE = nVertices; - if ( nEdges <= nV ) - { - nE = 2 * nE; - } - - checkEdges( nE ); - } - - private void checkVertices() - { - checkVertices( DEFAULT_VERTICES ); - } - - private void checkVertices( int nVertices ) - { - if ( vertices == null ) - { - vertices = new TreeSet<>(); - } - } - private void checkEdges() - { - int count = DEFAULT_EDGES; - - if ( vertices != null ) - { - count = vertices.size() + vertices.size() / 2; - } - - checkEdges( count ); - } - private void checkEdges( int nEdges ) - { - if ( incidentEdges == null ) - { - incidentEdges = new HashMap<>( nEdges ); - } - if ( excidentEdges == null ) - { - excidentEdges = new HashMap<>( nEdges ); - } - } - //------------------------------------------------------------------------ - private static void checkVertex( MetadataGraphVertex v ) - throws MetadataResolutionException - { - if ( v == null ) - { - throw new MetadataResolutionException( "null vertex" ); - } - if ( v.getMd() == null ) - { - throw new MetadataResolutionException( "vertex without metadata" ); - } - } - //------------------------------------------------------------------------ - private static void checkEdge( MetadataGraphEdge e ) - throws MetadataResolutionException - { - if ( e == null ) - { - throw new MetadataResolutionException( "badly formed edge" ); - } - } - //------------------------------------------------------------------------ - public List getEdgesBetween( MetadataGraphVertex vFrom, MetadataGraphVertex vTo ) - { - List edges = getIncidentEdges( vTo ); - if ( edges == null || edges.isEmpty() ) - { - return null; - } - - List res = new ArrayList<>( edges.size() ); - - for ( MetadataGraphEdge e : edges ) - { - if ( e.getSource().equals( vFrom ) ) - { - res.add( e ); - } - } - - return res; - } - //------------------------------------------------------------------------ - public MetadataGraph addEdge( MetadataGraphVertex vFrom, MetadataGraphVertex vTo, MetadataGraphEdge e ) - throws MetadataResolutionException - { - checkVertex( vFrom ); - checkVertex( vTo ); - - checkVertices(); - - checkEdge( e ); - checkEdges(); - - e.setSource( vFrom ); - e.setTarget( vTo ); - - vFrom.setCompareVersion( versionedVertices ); - vFrom.setCompareScope( scopedVertices ); - - List exList = excidentEdges.computeIfAbsent( vFrom, k -> new ArrayList<>() ); - - if ( !exList.contains( e ) ) - { - exList.add( e ); - } - - List inList = incidentEdges.computeIfAbsent( vTo, k -> new ArrayList<>() ); - - if ( !inList.contains( e ) ) - { - inList.add( e ); - } - - return this; - } - //------------------------------------------------------------------------ - public MetadataGraph removeVertex( MetadataGraphVertex v ) - { - if ( vertices != null && v != null ) - { - vertices.remove( v ); - } - - if ( incidentEdges != null ) - { - incidentEdges.remove( v ); - } - - if ( excidentEdges != null ) - { - excidentEdges.remove( v ); - } - - return this; - - } - //------------------------------------------------------------------------ - private static int countNodes( MetadataTreeNode tree ) - { - if ( tree == null ) - { - return 0; - } - - int count = 1; - MetadataTreeNode[] kids = tree.getChildren(); - if ( kids == null || kids.length < 1 ) - { - return count; - } - for ( MetadataTreeNode n : kids ) - { - count += countNodes( n ); - } - - return count; - } - - //------------------------------------------------------------------------ - public MetadataGraphVertex getEntry() - { - return entry; - } - - public void setEntry( MetadataGraphVertex entry ) - { - this.entry = entry; - } - - public TreeSet getVertices() - { - return vertices; - } - - public List getIncidentEdges( MetadataGraphVertex vertex ) - { - checkEdges(); - return incidentEdges.get( vertex ); - } - - public List getExcidentEdges( MetadataGraphVertex vertex ) - { - checkEdges(); - return excidentEdges.get( vertex ); - } - - public boolean isVersionedVertices() - { - return versionedVertices; - } - - public void setVersionedVertices( boolean versionedVertices ) - { - this.versionedVertices = versionedVertices; - } - - public boolean isScopedVertices() - { - return scopedVertices; - } - - public void setScopedVertices( boolean scopedVertices ) - { - this.scopedVertices = scopedVertices; - - // scoped graph is versioned by definition - if ( scopedVertices ) - { - versionedVertices = true; - } - } - - public ArtifactScopeEnum getScope() - { - return scope; - } - - public void setScope( ArtifactScopeEnum scope ) - { - this.scope = scope; - } - - // ------------------------------------------------------------------------ - public boolean isEmpty() - { - return entry == null || vertices == null || vertices.isEmpty(); - } - - //------------------------------------------------------------------------ - public boolean isEmptyEdges() - { - return isEmpty() || incidentEdges == null || incidentEdges.isEmpty(); - } - //------------------------------------------------------------------------ - @Override - public String toString() - { - StringBuilder sb = new StringBuilder( 512 ); - if ( isEmpty() ) - { - return "empty"; - } - for ( MetadataGraphVertex v : vertices ) - { - sb.append( "Vertex: " ).append( v.getMd().toString() ).append( '\n' ); - List ins = getIncidentEdges( v ); - if ( ins != null ) - { - for ( MetadataGraphEdge e : ins ) - { - sb.append( " from : " ).append( e.toString() ).append( '\n' ); - } - } - else - { - sb.append( " no entries\n" ); - } - - List outs = getExcidentEdges( v ); - if ( outs != null ) - { - for ( MetadataGraphEdge e : outs ) - { - sb.append( " to : " ).append( e.toString() ).append( '\n' ); - } - } - else - { - sb.append( " no exit\n" ); - } - - sb.append( "-------------------------------------------------\n" ); - } - sb.append( "=============================================================\n" ); - return sb.toString(); - } - - //------------------------------------------------------------------------ - //------------------------------------------------------------------------ -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraphEdge.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraphEdge.java deleted file mode 100644 index 16fe9bc07f2f..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraphEdge.java +++ /dev/null @@ -1,191 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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.artifact.ArtifactScopeEnum; - -/** - * metadata graph edge - combination of version, scope and depth define - * an edge in the graph - * - * @author Oleg Gusakov - * - */ - -public class MetadataGraphEdge -{ - String version; - ArtifactScopeEnum scope; - int depth = -1; - int pomOrder = -1; - boolean resolved = true; - String artifactUri; - - /** - * capturing where this link came from - * and where it is linked to. - * - * In the first implementation only source used for explanatory function - */ - MetadataGraphVertex source; - MetadataGraphVertex target; - - //---------------------------------------------------------------------------- - public MetadataGraphEdge( String version, boolean resolved, ArtifactScopeEnum scope, String artifactUri, int depth, - int pomOrder ) - { - super(); - this.version = version; - this.scope = scope; - this.artifactUri = artifactUri; - this.depth = depth; - this.resolved = resolved; - this.pomOrder = pomOrder; - } - //---------------------------------------------------------------------------- - /** - * helper for equals - */ - private static boolean objectsEqual( Object o1, Object o2 ) - { - if ( o1 == null && o2 == null ) - { - return true; - } - if ( o1 == null || o2 == null ) - { - return false; // as they are not both null - } - return o1.equals( o2 ); - } - - //---------------------------------------------------------------------------- - /** - * used to eliminate exact duplicates in the edge list - */ - @Override - @SuppressWarnings( "checkstyle:equalshashcode" ) - public boolean equals( Object o ) - { - if ( o instanceof MetadataGraphEdge ) - { - MetadataGraphEdge e = (MetadataGraphEdge) o; - - return objectsEqual( version, e.version ) - && ArtifactScopeEnum.checkScope( scope ).getScope(). - equals( ArtifactScopeEnum.checkScope( e.scope ).getScope() ) - && depth == e.depth; - } - return false; - } - - //---------------------------------------------------------------------------- - public String getVersion() - { - return version; - } - - public void setVersion( String version ) - { - this.version = version; - } - - public ArtifactScopeEnum getScope() - { - return scope; - } - - public void setScope( ArtifactScopeEnum scope ) - { - this.scope = scope; - } - - public int getDepth() - { - return depth; - } - - public void setDepth( int depth ) - { - this.depth = depth; - } - - public boolean isResolved() - { - return resolved; - } - - public void setResolved( boolean resolved ) - { - this.resolved = resolved; - } - - public int getPomOrder() - { - return pomOrder; - } - - public void setPomOrder( int pomOrder ) - { - this.pomOrder = pomOrder; - } - - public String getArtifactUri() - { - return artifactUri; - } - - public void setArtifactUri( String artifactUri ) - { - this.artifactUri = artifactUri; - } - - public MetadataGraphVertex getSource() - { - return source; - } - - public void setSource( MetadataGraphVertex source ) - { - this.source = source; - } - - public MetadataGraphVertex getTarget() - { - return target; - } - - public void setTarget( MetadataGraphVertex target ) - { - this.target = target; - } - - @Override - public String toString() - { - return "[ " + "FROM:(" - + ( source == null ? "no source" : ( source.md == null ? "no source MD" : source.md.toString() ) ) + ") " - + "TO:(" + ( target == null ? "no target" : ( target.md == null ? "no target MD" : target.md.toString() ) ) - + ") " + "version=" + version + ", scope=" + ( scope == null ? "null" : scope.getScope() ) + ", depth=" - + depth + "]"; - } - //---------------------------------------------------------------------------- - //---------------------------------------------------------------------------- -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraphTransformationException.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraphTransformationException.java deleted file mode 100644 index 7861b48ede8b..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraphTransformationException.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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. - */ - -/** - * @author Oleg Gusakov - */ -public class MetadataGraphTransformationException - extends Exception -{ - - private static final long serialVersionUID = -4029897098314019152L; - - public MetadataGraphTransformationException() - { - } - - public MetadataGraphTransformationException( String message ) - { - super( message ); - } - - public MetadataGraphTransformationException( Throwable cause ) - { - super( cause ); - } - - public MetadataGraphTransformationException( String message, Throwable cause ) - { - super( message, cause ); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraphVertex.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraphVertex.java deleted file mode 100644 index 495d061ca64d..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraphVertex.java +++ /dev/null @@ -1,216 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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.artifact.ArtifactScopeEnum; - -/** - * metadata graph vertice - just a wrapper around artifact's metadata - * - * @author Oleg Gusakov - */ -public class MetadataGraphVertex - implements Comparable -{ - ArtifactMetadata md; - - // indications to use these in comparison - private boolean compareVersion = false; - private boolean compareScope = false; - - public MetadataGraphVertex( ArtifactMetadata md ) - { - super(); - this.md = md; - } - - public MetadataGraphVertex( ArtifactMetadata md, boolean compareVersion, boolean compareScope ) - { - this( md ); - this.compareVersion = compareVersion; - this.compareScope = compareScope; - } - - public ArtifactMetadata getMd() - { - return md; - } - - public void setMd( ArtifactMetadata md ) - { - this.md = md; - } - - // --------------------------------------------------------------------- - public boolean isCompareVersion() - { - return compareVersion; - } - - public void setCompareVersion( boolean compareVersion ) - { - this.compareVersion = compareVersion; - } - - public boolean isCompareScope() - { - return compareScope; - } - - public void setCompareScope( boolean compareScope ) - { - this.compareScope = compareScope; - } - - // --------------------------------------------------------------------- - @Override - public String toString() - { - return "[" + ( md == null ? "no metadata" : md.toString() ) + "]"; - } - - // --------------------------------------------------------------------- - private static int compareStrings( String s1, String s2 ) - { - if ( s1 == null && s2 == null ) - { - return 0; - } - - if ( s1 == null /* && s2 != null */ ) - { - return -1; - } - - if ( /* s1 != null && */ s2 == null ) - { - return 1; - } - - return s1.compareTo( s2 ); - } - - // --------------------------------------------------------------------- - public int compareTo( MetadataGraphVertex vertex ) - { - if ( vertex == null || vertex.getMd() == null ) - { - return 1; - } - - ArtifactMetadata vmd = vertex.getMd(); - - if ( vmd == null ) - { - if ( md == null ) - { - return 0; - } - else - { - return 1; - } - } - - int g = compareStrings( md.groupId, vmd.groupId ); - - if ( g == 0 ) - { - int a = compareStrings( md.artifactId, vmd.artifactId ); - if ( a == 0 ) - { - if ( compareVersion ) - { - int v = compareStrings( md.version, vmd.version ); - if ( v == 0 ) - { - if ( compareScope ) - { - String s1 = ArtifactScopeEnum.checkScope( md.artifactScope ).getScope(); - String s2 = ArtifactScopeEnum.checkScope( vmd.artifactScope ).getScope(); - return s1.compareTo( s2 ); - } - else - { - return 0; - } - } - else - { - return v; - } - } - else - { - return 0; - } - } - else - { - return a; - } - } - - return g; - } - - // --------------------------------------------------------------------- - @Override - public boolean equals( Object vo ) - { - if ( vo == null || !( vo instanceof MetadataGraphVertex ) ) - { - return false; - } - return compareTo( (MetadataGraphVertex) vo ) == 0; - } - - // --------------------------------------------------------------------- - - @Override - public int hashCode() - { - if ( md == null ) - { - return super.hashCode(); - } - StringBuilder hashString = new StringBuilder( 128 ); - hashString.append( md.groupId ).append( '|' ); - hashString.append( md.artifactId ).append( '|' ); - - if ( compareVersion ) - { - hashString.append( md.version ).append( '|' ); - } - - if ( compareScope ) - { - hashString.append( md.getArtifactScope() ).append( '|' ); - } - - return hashString.toString().hashCode(); - - // BASE64Encoder b64 = new BASE64Encoder(); - // return b64.encode( hashString.toString().getBytes() ).hashCode(); - } - - // --------------------------------------------------------------------- - // --------------------------------------------------------------------- -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolution.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolution.java deleted file mode 100644 index 9a9130b2fa4c..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolution.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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 org.apache.maven.artifact.repository.ArtifactRepository; - -/** - * - * @author Jason van Zyl - * - */ -public class MetadataResolution -{ - /** resolved MD */ - private ArtifactMetadata artifactMetadata; - - /** repositories, added by this POM */ - private Collection metadataRepositories; - //------------------------------------------------------------------- - public MetadataResolution( ArtifactMetadata artifactMetadata ) - { - this.artifactMetadata = artifactMetadata; - } - //------------------------------------------------------------------- - public MetadataResolution( ArtifactMetadata artifactMetadata, Collection metadataRepositories ) - { - this( artifactMetadata ); - this.metadataRepositories = metadataRepositories; - } - //------------------------------------------------------------------- - public Collection getMetadataRepositories() - { - return metadataRepositories; - } - - public void setMetadataRepositories( Collection metadataRepositories ) - { - this.metadataRepositories = metadataRepositories; - } - //------------------------------------------------------------------- - public ArtifactMetadata getArtifactMetadata() - { - return artifactMetadata; - } - - public void setArtifactMetadata( ArtifactMetadata artifactMetadata ) - { - this.artifactMetadata = artifactMetadata; - } - //------------------------------------------------------------------- - //------------------------------------------------------------------- -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionException.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionException.java deleted file mode 100644 index 149d2ac69b39..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionException.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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. - */ - -/** - * MetadataResolutionException - */ -public class MetadataResolutionException - extends Exception -{ - - public MetadataResolutionException() - { - // TODO Auto-generated constructor stub - } - - public MetadataResolutionException( String message ) - { - super( message ); - // TODO Auto-generated constructor stub - } - - public MetadataResolutionException( Throwable cause ) - { - super( cause ); - // TODO Auto-generated constructor stub - } - - public MetadataResolutionException( String message, Throwable cause ) - { - super( message, cause ); - // TODO Auto-generated constructor stub - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionRequest.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionRequest.java deleted file mode 100644 index e1f6fe1ee847..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionRequest.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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.List; - -import org.apache.maven.artifact.repository.ArtifactRepository; - -/** @author Oleg Gusakov */ -public class MetadataResolutionRequest -{ - protected ArtifactMetadata query; - protected ArtifactRepository localRepository; - protected List remoteRepositories; - - //-------------------------------------------------------------------- - public MetadataResolutionRequest() - { - } - - //-------------------------------------------------------------------- - public MetadataResolutionRequest( ArtifactMetadata query, ArtifactRepository localRepository, - List remoteRepositories ) - { - this.query = query; - this.localRepository = localRepository; - this.remoteRepositories = remoteRepositories; - } - - //-------------------------------------------------------------------- - public ArtifactMetadata getQuery() - { - return query; - } - - public void setQuery( ArtifactMetadata query ) - { - this.query = query; - } - - public ArtifactRepository getLocalRepository() - { - return localRepository; - } - - public void setLocalRepository( ArtifactRepository localRepository ) - { - this.localRepository = localRepository; - } - - public List getRemoteRepositories() - { - return remoteRepositories; - } - - public void setRemoteRepositories( List remoteRepositories ) - { - this.remoteRepositories = remoteRepositories; - } - //-------------------------------------------------------------------- - //-------------------------------------------------------------------- -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionRequestTypeEnum.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionRequestTypeEnum.java deleted file mode 100644 index 31e3e9123ad1..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionRequestTypeEnum.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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. - */ - -/** - * MetadataResolutionRequestTypeEnum - */ -public enum MetadataResolutionRequestTypeEnum -{ - tree( 1 ) - , graph( 2 ) - , classpathCompile( 3 ) - , classpathTest( 4 ) - , classpathRuntime( 5 ) - , versionedGraph( 6 ) - , scopedGraph( 7 ) - ; - - private int id; - - // Constructor - MetadataResolutionRequestTypeEnum( int id ) - { - this.id = id; - } - - int getId() - { - return id; - } -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionResult.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionResult.java deleted file mode 100644 index 74a342773779..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionResult.java +++ /dev/null @@ -1,168 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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.artifact.ArtifactScopeEnum; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; - -/** - * This object is tinted with ClasspathTransformation and GraphConflictResolver. - * Get rid of them after debugging - * - * @author Oleg Gusakov - */ -public class MetadataResolutionResult -{ - MetadataTreeNode treeRoot; - - /** - * these components are are initialized on demand by - * explicit call of the initTreeProcessing() - */ - ClasspathTransformation classpathTransformation; - GraphConflictResolver conflictResolver; - - //---------------------------------------------------------------------------- - public MetadataResolutionResult( ) - { - } - //---------------------------------------------------------------------------- - public MetadataResolutionResult( MetadataTreeNode root ) - { - this.treeRoot = root; - } - //---------------------------------------------------------------------------- - public MetadataTreeNode getTree() - { - return treeRoot; - } - //---------------------------------------------------------------------------- - public void setTree( MetadataTreeNode root ) - { - this.treeRoot = root; - } - - public void initTreeProcessing( PlexusContainer plexus ) - throws ComponentLookupException - { - classpathTransformation = plexus.lookup( ClasspathTransformation.class ); - conflictResolver = plexus.lookup( GraphConflictResolver.class ); - } - //---------------------------------------------------------------------------- - public MetadataGraph getGraph() - throws MetadataResolutionException - { - return treeRoot == null ? null : new MetadataGraph( treeRoot ); - } - //---------------------------------------------------------------------------- - public MetadataGraph getGraph( ArtifactScopeEnum scope ) - throws MetadataResolutionException, GraphConflictResolutionException - { - if ( treeRoot == null ) - { - return null; - } - - if ( conflictResolver == null ) - { - return null; - } - - return conflictResolver.resolveConflicts( getGraph(), scope ); - } - //---------------------------------------------------------------------------- - public MetadataGraph getGraph( MetadataResolutionRequestTypeEnum requestType ) - throws MetadataResolutionException, GraphConflictResolutionException - { - if ( requestType == null ) - { - return null; - } - - if ( treeRoot == null ) - { - return null; - } - - if ( conflictResolver == null ) - { - return null; - } - - if ( requestType.equals( MetadataResolutionRequestTypeEnum.classpathCompile ) ) - { - return conflictResolver.resolveConflicts( getGraph(), ArtifactScopeEnum.compile ); - } - else if ( requestType.equals( MetadataResolutionRequestTypeEnum.classpathRuntime ) ) - { - return conflictResolver.resolveConflicts( getGraph(), ArtifactScopeEnum.runtime ); - } - else if ( requestType.equals( MetadataResolutionRequestTypeEnum.classpathTest ) ) - { - return conflictResolver.resolveConflicts( getGraph(), ArtifactScopeEnum.test ); - } - else if ( requestType.equals( MetadataResolutionRequestTypeEnum.graph ) ) - { - return getGraph(); - } - else if ( requestType.equals( MetadataResolutionRequestTypeEnum.versionedGraph ) ) - { - return new MetadataGraph( getTree(), true, false ); - } - else if ( requestType.equals( MetadataResolutionRequestTypeEnum.scopedGraph ) ) - { - return new MetadataGraph( getTree(), true, true ); - } - return null; - } - //---------------------------------------------------------------------------- - public ClasspathContainer getClasspath( ArtifactScopeEnum scope ) - throws MetadataGraphTransformationException, MetadataResolutionException - { - if ( classpathTransformation == null ) - { - return null; - } - - MetadataGraph dirtyGraph = getGraph(); - if ( dirtyGraph == null ) - { - return null; - } - - return classpathTransformation.transform( dirtyGraph, scope, false ); - } - - //---------------------------------------------------------------------------- - public MetadataTreeNode getClasspathTree( ArtifactScopeEnum scope ) - throws MetadataGraphTransformationException, MetadataResolutionException - { - ClasspathContainer cpc = getClasspath( scope ); - if ( cpc == null ) - { - return null; - } - - return cpc.getClasspathAsTree(); - } - //---------------------------------------------------------------------------- - //---------------------------------------------------------------------------- -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataRetrievalException.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataRetrievalException.java deleted file mode 100644 index f5461d716632..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataRetrievalException.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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. - */ - -/** - * Error while retrieving repository metadata from the repository. - * - * @author Jason van Zyl - */ -public class MetadataRetrievalException - extends Exception -{ - - private ArtifactMetadata artifact; - - public MetadataRetrievalException( String message ) - { - this( message, null, null ); - } - - public MetadataRetrievalException( Throwable cause ) - { - this( null, cause, null ); - } - - public MetadataRetrievalException( String message, Throwable cause ) - { - this( message, cause, null ); - } - - public MetadataRetrievalException( String message, Throwable cause, ArtifactMetadata artifact ) - { - super( message, cause ); - - this.artifact = artifact; - } - - public ArtifactMetadata getArtifactMetadata() - { - return artifact; - } -} \ No newline at end of file diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataSource.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataSource.java deleted file mode 100644 index 3ca6ce84f54d..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataSource.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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.List; - -import org.apache.maven.artifact.repository.ArtifactRepository; - -/** - * Provides some metadata operations, like querying the remote repository for a list of versions available for an - * artifact. - * - * @author Jason van Zyl - */ -public interface MetadataSource -{ - String ROLE = MetadataSource.class.getName(); - - MetadataResolution retrieve( ArtifactMetadata artifact, ArtifactRepository localRepository, - List remoteRepositories ) - throws MetadataRetrievalException; -} \ No newline at end of file diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataTreeNode.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataTreeNode.java deleted file mode 100644 index dd720d386673..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataTreeNode.java +++ /dev/null @@ -1,148 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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.artifact.Artifact; -import org.apache.maven.artifact.ArtifactScopeEnum; - -/** - * metadata [dirty] Tree - * - * @author Oleg Gusakov - * - */ -public class MetadataTreeNode -{ - ArtifactMetadata md; // this node - - MetadataTreeNode parent; // papa - - /** default # of children. Used for tree creation optimization only */ - int nChildren = 8; - - MetadataTreeNode[] children; // of cause - - public int getNChildren() - { - return nChildren; - } - - public void setNChildren( int children ) - { - nChildren = children; - } - - //------------------------------------------------------------------------ - public MetadataTreeNode() - { - } - //------------------------------------------------------------------------ - public MetadataTreeNode( ArtifactMetadata md, MetadataTreeNode parent, boolean resolved, ArtifactScopeEnum scope ) - { - if ( md != null ) - { - md.setArtifactScope( ArtifactScopeEnum.checkScope( scope ) ); - md.setResolved( resolved ); - } - - this.md = md; - this.parent = parent; - } - //------------------------------------------------------------------------ - public MetadataTreeNode( Artifact af, MetadataTreeNode parent, boolean resolved, ArtifactScopeEnum scope ) - { - this( new ArtifactMetadata( af ), parent, resolved, scope ); - } - - // ------------------------------------------------------------------------ - public void addChild( int index, MetadataTreeNode kid ) - { - if ( kid == null ) - { - return; - } - - if ( children == null ) - { - children = new MetadataTreeNode[nChildren]; - } - - children[index % nChildren] = kid; - } - - //------------------------------------------------------------------ - @Override - public String toString() - { - return md == null ? "no metadata" : md.toString(); - } - - //------------------------------------------------------------------ - public String graphHash() - throws MetadataResolutionException - { - if ( md == null ) - { - throw new MetadataResolutionException( "treenode without metadata, parent: " - + ( parent == null ? "null" : parent.toString() ) ); - } - - return md.groupId + ":" + md.artifactId; - } - - //------------------------------------------------------------------------ - public boolean hasChildren() - { - return children != null; - } - //------------------------------------------------------------------------ - public ArtifactMetadata getMd() - { - return md; - } - - public void setMd( ArtifactMetadata md ) - { - this.md = md; - } - - public MetadataTreeNode getParent() - { - return parent; - } - - public void setParent( MetadataTreeNode parent ) - { - this.parent = parent; - } - - public MetadataTreeNode[] getChildren() - { - return children; - } - - public void setChildren( MetadataTreeNode[] children ) - { - this.children = children; - } - //------------------------------------------------------------------------ - //------------------------------------------------------------------------ - -} diff --git a/maven-compat/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.java b/maven-compat/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.java deleted file mode 100644 index d001562fa288..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.maven.usability.plugin; - -/* - * 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. - */ - -/** - * ExpressionDocumentationException - */ -public class ExpressionDocumentationException - extends Exception -{ - static final long serialVersionUID = 1; - - public ExpressionDocumentationException( String message, Throwable cause ) - { - super( message, cause ); - } - - public ExpressionDocumentationException( String message ) - { - super( message ); - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java b/maven-compat/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java deleted file mode 100644 index f4e7bf928e8f..000000000000 --- a/maven-compat/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java +++ /dev/null @@ -1,176 +0,0 @@ -package org.apache.maven.usability.plugin; - -/* - * 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.usability.plugin.io.xpp3.ParamdocXpp3Reader; -import org.codehaus.plexus.util.ReaderFactory; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * ExpressionDocumenter - */ -public class ExpressionDocumenter -{ - - private static final String[] EXPRESSION_ROOTS = - { - "project", "settings", "session", "plugin", "rootless" - }; - - private static final String EXPRESSION_DOCO_ROOTPATH = "META-INF/maven/plugin-expressions/"; - - private static Map expressionDocumentation; - - public static Map load() - throws ExpressionDocumentationException - { - if ( expressionDocumentation == null ) - { - expressionDocumentation = new HashMap<>(); - - ClassLoader docLoader = initializeDocLoader(); - - for ( String root : EXPRESSION_ROOTS ) - { - try ( InputStream docStream = docLoader.getResourceAsStream( - EXPRESSION_DOCO_ROOTPATH + root + ".paramdoc.xml" ) ) - { - if ( docStream != null ) - { - Map doco = parseExpressionDocumentation( docStream ); - - expressionDocumentation.putAll( doco ); - } - } - catch ( IOException e ) - { - throw new ExpressionDocumentationException( - "Failed to read documentation for expression root: " + root, e ); - } - catch ( XmlPullParserException e ) - { - throw new ExpressionDocumentationException( - "Failed to parse documentation for expression root: " + root, e ); - } - - } - } - - return expressionDocumentation; - } - - /** - * - * - * project.distributionManagementArtifactRepository - * - * - * some-repo - * scp://host/path - * - * - * some-snap-repo - * scp://host/snapshot-path - * - * - * ]]> - * - * - * - * - * @throws IOException - * @throws XmlPullParserException - */ - private static Map parseExpressionDocumentation( InputStream docStream ) - throws IOException, XmlPullParserException - { - Reader reader = new BufferedReader( ReaderFactory.newXmlReader( docStream ) ); - - ParamdocXpp3Reader paramdocReader = new ParamdocXpp3Reader(); - - ExpressionDocumentation documentation = paramdocReader.read( reader, true ); - - List expressions = documentation.getExpressions(); - - Map bySyntax = new HashMap<>(); - - if ( expressions != null && !expressions.isEmpty() ) - { - for ( Expression expression : expressions ) - { - bySyntax.put( expression.getSyntax(), expression ); - } - } - - return bySyntax; - } - - private static ClassLoader initializeDocLoader() - throws ExpressionDocumentationException - { - String myResourcePath = ExpressionDocumenter.class.getName().replace( '.', '/' ) + ".class"; - - URL myResource = ExpressionDocumenter.class.getClassLoader().getResource( myResourcePath ); - - assert myResource != null : "The resource is this class itself loaded by its own classloader and must exist"; - - String myClasspathEntry = myResource.getPath(); - - myClasspathEntry = myClasspathEntry.substring( 0, myClasspathEntry.length() - ( myResourcePath.length() + 2 ) ); - - if ( myClasspathEntry.startsWith( "file:" ) ) - { - myClasspathEntry = myClasspathEntry.substring( "file:".length() ); - } - - URL docResource; - try - { - docResource = new File( myClasspathEntry ).toURL(); - } - catch ( MalformedURLException e ) - { - throw new ExpressionDocumentationException( - "Cannot construct expression documentation classpath" + " resource base.", e ); - } - - return new URLClassLoader( new URL[] - { - docResource - } ); - } - -} diff --git a/maven-compat/src/main/mdo/paramdoc.mdo b/maven-compat/src/main/mdo/paramdoc.mdo deleted file mode 100644 index ab253316db5c..000000000000 --- a/maven-compat/src/main/mdo/paramdoc.mdo +++ /dev/null @@ -1,154 +0,0 @@ - - - - - - paramdoc - Paramdoc - - - - package - org.apache.maven.usability.plugin - - - - - 1.0.0 - ExpressionDocumentation - The root of a parameter plugin expression document. - - - 1.0.0 - expressions - The list of plugin parameter expressions described by this - document. - - Expression - * - - - - - - 1.0.0 - - - - - - 1.0.0 - Expression - A plugin parameter expression supported by Maven - - - 1.0.0 - syntax - The syntax of the expression - String - true - - - 1.0.0 - description - The description of what this expression references, and what it's generally used for. - String - true - - - 1.0.0 - configuration - The place and syntax used to change the value of this expression. - String - - - 1.0.0 - cliOptions - The command-line switches used to change the value of this expression. - Properties - - String - * - - - - 1.0.0 - apiMethods - The programmatic methods used to change the value of this expression. - Properties - - String - * - - - - 1.0.0 - deprecation - A preferred alternative to this expression, in the case where it's deprecated. - String - - - 1.0.0 - ban - A preferred alternative to this expression, in the case where it's banned from use. - String - - - 1.0.0 - editable - Whether the value of this expression can be changed. - boolean - true - - - - - diff --git a/maven-compat/src/main/mdo/profiles.mdo b/maven-compat/src/main/mdo/profiles.mdo deleted file mode 100644 index 5132490d9a55..000000000000 --- a/maven-compat/src/main/mdo/profiles.mdo +++ /dev/null @@ -1,400 +0,0 @@ - - - - profiles - Profiles - - - - package - org.apache.maven.profiles - - - - - ProfilesRoot - 1.0.0 - Root element of the profiles.xml file. - - - profiles - 1.0.0 - - - Profile - * - - - - activeProfiles - 1.0.0 - - - String - * - - - - - - Profile - 1.0.0 - - - - id - true - 1.0.0 - String - The ID of this build profile, for activation - purposes. - - - activation - 1.0.0 - - - Activation - - - - properties - Extended configuration specific to this profile goes - here. - Properties - - String - * - - - - repositories - 1.0.0 - - - - Repository - * - - - - pluginRepositories - 1.0.0 - - - Repository - * - - - - - - - Activation - 1.0.0 - - - - activeByDefault - 1.0.0 - boolean - Flag specifying whether this profile is active as a default. - - - jdk - 1.0.0 - String - - - - os - 1.0.0 - - - ActivationOS - - - - property - 1.0.0 - - - ActivationProperty - - - - file - 1.0.0 - - - ActivationFile - - - - - - - - RepositoryBase - 1.0.0 - - - - id - 1.0.0 - - String - - - name - 1.0.0 - - String - - - url - 1.0.0 - - String - - - layout - 1.0.0 - The type of layout this repository uses for locating and storing artifacts - can be "legacy" or - "default". - String - default - - - - - 1.0.0 - - - - - - Repository - RepositoryBase - 1.0.0 - - Repository contains the information needed for establishing connections with remote repository - - - - releases - 1.0.0 - How to handle downloading of releases from this repository - - RepositoryPolicy - - - - snapshots - 1.0.0 - How to handle downloading of snapshots from this repository - - RepositoryPolicy - - - - - - - 1.0.0 - - - - - - - RepositoryPolicy - 1.0.0 - Download policy - - - enabled - 1.0.0 - Whether to use this repository for downloading this type of artifact - boolean - true - - - updatePolicy - 1.0.0 - - The frequency for downloading updates - can be "always", "daily" (default), "interval:XXX" (in minutes) or - "never" (only if it doesn't exist locally). - - String - - - checksumPolicy - 1.0.0 - - What to do when verification of an artifact checksum fails. Valid values are "fail" (default for Maven 4 and - above), "warn" (default for Maven 2 and 3) or "ignore". - - String - - - - - ActivationProperty - 1.0.0 - - - - name - 1.0.0 - String - true - The name of the property to be used to activate a profile - - - value - 1.0.0 - String - The value of the property to be used to activate a profile - - - - - ActivationFile - 1.0.0 - - - - missing - 1.0.0 - String - The name of the file that should be missing to activate a profile - - - exists - 1.0.0 - String - The name of the file that should exist to activate a profile - - - - - ActivationOS - 1.0.0 - - - - name - 1.0.0 - String - The name of the OS to be used to activate a profile - - - family - 1.0.0 - String - The general family of the OS to be used to activate a profile (e.g. 'windows') - - - arch - 1.0.0 - String - The architecture of the OS to be used to activate a profile - - - version - 1.0.0 - String - The version of the OS to be used to activate a profile - - - - - diff --git a/maven-compat/src/main/resources/META-INF/maven/plugin-expressions/project.paramdoc.xml b/maven-compat/src/main/resources/META-INF/maven/plugin-expressions/project.paramdoc.xml deleted file mode 100644 index 9acebefc4d8e..000000000000 --- a/maven-compat/src/main/resources/META-INF/maven/plugin-expressions/project.paramdoc.xml +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - - project.distributionManagementArtifactRepository - - - - - repo - Repository Name - scp://host/path/to/repo - - - - repo - Repository Name - scp://host/path/to/repo - - - ]]> - This is the ArtifactRepository used to deploy artifacts built by this - Maven. - - - - project.artifact - - project.group -project-artifact -0.0.0.0 -type - ]]> - This is the Artifact instance created from the essential project - attributes: groupId, artifactId, version, and packaging (with a default packaging of - 'jar'). - - - - project.parent - - - project.group - project-artifact - 0.0.0.0 - - ]]> - This is the MavenProject instance for the parent of the current POM. - - - - project.file - This is the File instance that refers to the location of the current POM on - disk. - - - - project.artifacts - - - ... - - ]]> - - - - - project.parentArtifact - - - project.group - project-artifact - 0.0.0.0 - - ]]> - This is the Artifact instance for the parent of the current POM. - - - - project.pluginArtifacts - - - - ... - - - ]]> - - - - - project.remoteArtifactRepositories - - - ... - - ]]> - - - - - project.pluginArtifactRepositories - - - ... - - ]]> - - - - - project.attachedArtifacts - - - - - \ No newline at end of file diff --git a/maven-compat/src/main/resources/META-INF/maven/plugin-expressions/rootless.paramdoc.xml b/maven-compat/src/main/resources/META-INF/maven/plugin-expressions/rootless.paramdoc.xml deleted file mode 100644 index 27f03435c329..000000000000 --- a/maven-compat/src/main/resources/META-INF/maven/plugin-expressions/rootless.paramdoc.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - localRepository - - /path/to/local/repository - ]]> - The ArtifactRepository instance referencing the local artifact - repository. - - - -Dmaven.repo.local=/path/to/local/repo - Override the local repository location on a per-build basis. - - - - - reactorProjects - This is the current list of projects being built by - Maven. - - - diff --git a/maven-compat/src/main/resources/META-INF/maven/plugin-expressions/settings.paramdoc.xml b/maven-compat/src/main/resources/META-INF/maven/plugin-expressions/settings.paramdoc.xml deleted file mode 100644 index e058218a461a..000000000000 --- a/maven-compat/src/main/resources/META-INF/maven/plugin-expressions/settings.paramdoc.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - settings.offline - - true - ]]> - - - - - settings.interactiveMode - - true - ]]> - - - - - \ No newline at end of file diff --git a/maven-compat/src/main/resources/META-INF/maven/plugin.xml b/maven-compat/src/main/resources/META-INF/maven/plugin.xml deleted file mode 100644 index da5a62c092e0..000000000000 --- a/maven-compat/src/main/resources/META-INF/maven/plugin.xml +++ /dev/null @@ -1,218 +0,0 @@ - - - - - - Maven Internal State-Management Plugins - org.apache.maven.plugins.internal - maven-state-management - 2.1 - statemgmt - false - true - - - start-fork - Setup the appropriate build state to initiate a forked execution. - false - false - false - false - false - true - org.apache.maven.lifecycle.statemgmt.StartForkedExecutionMojo - java - per-lookup - once-per-session - - - project - org.apache.maven.project.MavenProject - true - false - The current MavenProject instance, which will have a new executionProject set after execution. - - - session - org.apache.maven.execution.MavenSession - true - false - The current MavenSession instance, which will handle the fork context. - - - forkId - int - true - true - The current fork identifier. - - - - - - ${forkId} - - - - end-fork - Restore the non-fork currentProject instance, for use in the forking mojo. - false - false - false - false - false - true - org.apache.maven.lifecycle.statemgmt.EndForkedExecutionMojo - java - per-lookup - once-per-session - - - session - org.apache.maven.execution.MavenSession - true - false - The current MavenSession instance, which will handle the fork context. - - - forkId - int - true - true - The current fork identifier. - - - - - ${forkId} - - - - clear-fork-context - Tear down any build state used during the previous forked execution. - false - false - false - false - false - true - org.apache.maven.lifecycle.statemgmt.ClearForkedContextMojo - java - per-lookup - once-per-session - - - project - org.apache.maven.project.MavenProject - true - false - The current MavenProject instance, which will have the current executionProject cleared after execution. - - - forkId - int - true - true - The current fork identifier. - - - - - ${forkId} - - - - resolve-late-bound-plugin - Resolve a late-bound plugin during a build, right before it is to be used. - false - false - false - false - false - true - org.apache.maven.lifecycle.statemgmt.ResolveLateBoundPluginMojo - java - per-lookup - once-per-session - - - project - org.apache.maven.project.MavenProject - true - false - The current MavenProject instance, for building a new MojoBinding instance. - - - session - org.apache.maven.execution.MavenSession - true - false - The current MavenSession instance, which will handle the fork context. - - - groupId - java.lang.String - true - true - The plugin's groupId. - - - artifactId - java.lang.String - true - true - The plugin's artifactId. - - - version - java.lang.String - false - true - The plugin's version. - - - goal - java.lang.String - true - true - The mojo's goal that we're looking for, as an extra validation step. - - - - - - ${groupId} - ${artifactId} - ${version} - ${goal} - - - - org.apache.maven.plugin.loader.PluginLoader - pluginLoader - - - org.apache.maven.lifecycle.binding.MojoBindingFactory - bindingFactory - - - - - \ No newline at end of file diff --git a/maven-compat/src/site/apt/index.apt b/maven-compat/src/site/apt/index.apt deleted file mode 100644 index a288cdcc3d2e..000000000000 --- a/maven-compat/src/site/apt/index.apt +++ /dev/null @@ -1,32 +0,0 @@ -~~ 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 - ----- - 2016-05-29 - ----- - -Maven Compat - - Maven2 classes maintained as compatibility layer for plugins that need to keep Maven2 compatibility. - - Plugins should avoid these classes and be updated to use only Maven3 dependencies (and require Maven3): see - {{{https://cwiki.apache.org/confluence/display/MAVEN/Plugin+migration+to+Maven3+dependencies} Plugin migration to Maven3 dependencies}} - documentation to get hints on how to make the update. diff --git a/maven-compat/src/site/site.xml b/maven-compat/src/site/site.xml deleted file mode 100644 index e475330c4063..000000000000 --- a/maven-compat/src/site/site.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - ${project.scm.url} - - - - - - - - - - - - - \ No newline at end of file diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java b/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java deleted file mode 100644 index 735c6499f210..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java +++ /dev/null @@ -1,375 +0,0 @@ -package org.apache.maven.artifact; - -/* - * 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.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.util.ArrayList; -import java.util.List; - -import javax.inject.Inject; -import javax.inject.Named; - -import org.codehaus.plexus.testing.PlexusTest; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.execution.DefaultMavenExecutionRequest; -import org.apache.maven.execution.DefaultMavenExecutionResult; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.LegacySupport; -import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory; -import org.codehaus.plexus.PlexusContainer; -import org.eclipse.aether.DefaultRepositorySystemSession; -import org.eclipse.aether.RepositorySystemSession; -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.internal.impl.SimpleLocalRepositoryManagerFactory; -import org.eclipse.aether.repository.LocalRepository; -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; -import org.junit.jupiter.api.BeforeEach; - -import static org.codehaus.plexus.testing.PlexusExtension.getBasedir; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * @author Jason van Zyl - */ -@PlexusTest -public abstract class AbstractArtifactComponentTestCase //extends PlexusTestCase -{ - @Inject - protected ArtifactFactory artifactFactory; - - @Inject - protected ArtifactRepositoryFactory artifactRepositoryFactory; - - @Inject - LegacySupport legacySupport; - - @Inject @Named( "default" ) - ArtifactRepositoryLayout repoLayout; - - @Inject - PlexusContainer container; - - public PlexusContainer getContainer() { - return container; - } - - @BeforeEach - public void setUp() - throws Exception - { - RepositorySystemSession repoSession = initRepoSession(); - MavenSession session = new MavenSession( getContainer(), repoSession, new DefaultMavenExecutionRequest(), - new DefaultMavenExecutionResult() ); - - legacySupport.setSession( session ); - } - - protected abstract String component(); - - /** - * Return an existing file, not a directory - causes creation to fail. - * - * @throws Exception - */ - protected ArtifactRepository badLocalRepository() - throws Exception - { - String path = "target/test-repositories/" + component() + "/bad-local-repository"; - - File f = new File( getBasedir(), path ); - - f.createNewFile(); - - return artifactRepositoryFactory.createArtifactRepository( "test", "file://" + f.getPath(), repoLayout, null, - null ); - } - - protected String getRepositoryLayout() - { - return "default"; - } - - protected ArtifactRepository localRepository() - throws Exception - { - String path = "target/test-repositories/" + component() + "/local-repository"; - - File f = new File( getBasedir(), path ); - - return artifactRepositoryFactory.createArtifactRepository( "local", "file://" + f.getPath(), repoLayout, null, - null ); - } - - protected ArtifactRepository remoteRepository() - throws Exception - { - String path = "target/test-repositories/" + component() + "/remote-repository"; - - File f = new File( getBasedir(), path ); - - return artifactRepositoryFactory.createArtifactRepository( "test", "file://" + f.getPath(), repoLayout, - new ArtifactRepositoryPolicy(), - new ArtifactRepositoryPolicy() ); - } - - protected ArtifactRepository badRemoteRepository() - throws Exception - { - return artifactRepositoryFactory.createArtifactRepository( "test", "http://foo.bar/repository", repoLayout, - null, null ); - } - - protected void assertRemoteArtifactPresent( Artifact artifact ) - throws Exception - { - ArtifactRepository remoteRepo = remoteRepository(); - - String path = remoteRepo.pathOf( artifact ); - - File file = new File( remoteRepo.getBasedir(), path ); - - assertTrue( file.exists(), "Remote artifact " + file + " should be present." ); - } - - protected void assertLocalArtifactPresent( Artifact artifact ) - throws Exception - { - ArtifactRepository localRepo = localRepository(); - - String path = localRepo.pathOf( artifact ); - - File file = new File( localRepo.getBasedir(), path ); - - assertTrue( file.exists(), "Local artifact " + file + " should be present." ); - } - - protected void assertRemoteArtifactNotPresent( Artifact artifact ) - throws Exception - { - ArtifactRepository remoteRepo = remoteRepository(); - - String path = remoteRepo.pathOf( artifact ); - - File file = new File( remoteRepo.getBasedir(), path ); - - assertFalse( file.exists(), "Remote artifact " + file + " should not be present." ); - } - - protected void assertLocalArtifactNotPresent( Artifact artifact ) - throws Exception - { - ArtifactRepository localRepo = localRepository(); - - String path = localRepo.pathOf( artifact ); - - File file = new File( localRepo.getBasedir(), path ); - - assertFalse( file.exists(), "Local artifact " + file + " should not be present." ); - } - - // ---------------------------------------------------------------------- - // - // ---------------------------------------------------------------------- - - protected List remoteRepositories() - throws Exception - { - List remoteRepositories = new ArrayList<>(); - - remoteRepositories.add( remoteRepository() ); - - return remoteRepositories; - } - - // ---------------------------------------------------------------------- - // Test artifact generation for unit tests - // ---------------------------------------------------------------------- - - protected Artifact createLocalArtifact( String artifactId, String version ) - throws Exception - { - Artifact artifact = createArtifact( artifactId, version ); - - createArtifact( artifact, localRepository() ); - - return artifact; - } - - protected Artifact createRemoteArtifact( String artifactId, String version ) - throws Exception - { - Artifact artifact = createArtifact( artifactId, version ); - - createArtifact( artifact, remoteRepository() ); - - return artifact; - } - - protected void createLocalArtifact( Artifact artifact ) - throws Exception - { - createArtifact( artifact, localRepository() ); - } - - protected void createRemoteArtifact( Artifact artifact ) - throws Exception - { - createArtifact( artifact, remoteRepository() ); - } - - protected void createArtifact( Artifact artifact, ArtifactRepository repository ) - throws Exception - { - String path = repository.pathOf( artifact ); - - File artifactFile = new File( repository.getBasedir(), path ); - - if ( !artifactFile.getParentFile().exists() ) - { - artifactFile.getParentFile().mkdirs(); - } - try ( Writer writer = new OutputStreamWriter( new FileOutputStream( artifactFile ), StandardCharsets.ISO_8859_1) ) - { - writer.write( artifact.getId() ); - } - - MessageDigest md = MessageDigest.getInstance( "MD5" ); - md.update( artifact.getId().getBytes() ); - byte[] digest = md.digest(); - - String md5path = repository.pathOf( artifact ) + ".md5"; - File md5artifactFile = new File( repository.getBasedir(), md5path ); - try ( Writer writer = new OutputStreamWriter( new FileOutputStream( md5artifactFile ), StandardCharsets.ISO_8859_1) ) - { - writer.append( printHexBinary( digest ) ); - } - } - - protected Artifact createArtifact( String artifactId, String version ) - throws Exception - { - return createArtifact( artifactId, version, "jar" ); - } - - protected Artifact createArtifact( String artifactId, String version, String type ) - throws Exception - { - return createArtifact( "org.apache.maven", artifactId, version, type ); - } - - protected Artifact createArtifact( String groupId, String artifactId, String version, String type ) - throws Exception - { - Artifact a = artifactFactory.createBuildArtifact( groupId, artifactId, version, type ); - - return a; - } - - protected void deleteLocalArtifact( Artifact artifact ) - throws Exception - { - deleteArtifact( artifact, localRepository() ); - } - - protected void deleteArtifact( Artifact artifact, ArtifactRepository repository ) - throws Exception - { - String path = repository.pathOf( artifact ); - - File artifactFile = new File( repository.getBasedir(), path ); - - if ( artifactFile.exists() ) - { - if ( !artifactFile.delete() ) - { - throw new IOException( "Failure while attempting to delete artifact " + artifactFile ); - } - } - } - - protected RepositorySystemSession initRepoSession() - throws Exception - { - DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(); - session.setArtifactDescriptorPolicy( new SimpleArtifactDescriptorPolicy( true, true ) ); - 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() ); - transformer = new ChainedDependencyGraphTransformer( transformer, new JavaDependencyContextRefiner() ); - session.setDependencyGraphTransformer( transformer ); - - LocalRepository localRepo = new LocalRepository( localRepository().getBasedir() ); - session.setLocalRepositoryManager( - new SimpleLocalRepositoryManagerFactory().newInstance( session, localRepo ) ); - - return session; - } - - private static final char[] hexCode = "0123456789ABCDEF".toCharArray(); - - private static final String printHexBinary( byte[] data ) - { - StringBuilder r = new StringBuilder( data.length * 2 ); - for ( byte b : data ) - { - r.append( hexCode[( b >> 4 ) & 0xF] ); - r.append( hexCode[( b & 0xF )] ); - } - return r.toString(); - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java deleted file mode 100644 index 53cc388acd14..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.apache.maven.artifact.deployer; - -/* - * 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.artifact.AbstractArtifactComponentTestCase; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.codehaus.plexus.util.FileUtils; -import org.junit.jupiter.api.Test; - -import static org.codehaus.plexus.testing.PlexusExtension.getBasedir; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import javax.inject.Inject; - -/** - * @author Jason van Zyl - */ -public class ArtifactDeployerTest - extends AbstractArtifactComponentTestCase -{ - @Inject - private ArtifactDeployer artifactDeployer; - - protected String component() - { - return "deployer"; - } - - @Test - public void testArtifactInstallation() - throws Exception - { - String artifactBasedir = new File( getBasedir(), "src/test/resources/artifact-install" ).getAbsolutePath(); - - Artifact artifact = createArtifact( "artifact", "1.0" ); - - File file = new File( artifactBasedir, "artifact-1.0.jar" ); - assertEquals( "dummy", FileUtils.fileRead( file, "UTF-8" ).trim() ); - - artifactDeployer.deploy( file, artifact, remoteRepository(), localRepository() ); - - ArtifactRepository remoteRepository = remoteRepository(); - File deployedFile = new File( remoteRepository.getBasedir(), remoteRepository.pathOf( artifact ) ); - assertTrue( deployedFile.exists() ); - assertEquals( "dummy", FileUtils.fileRead( deployedFile, "UTF-8" ).trim() ); - } -} \ No newline at end of file diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/deployer/SimpleArtifactMetadataSource.java b/maven-compat/src/test/java/org/apache/maven/artifact/deployer/SimpleArtifactMetadataSource.java deleted file mode 100644 index 8f6caa8265d7..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/artifact/deployer/SimpleArtifactMetadataSource.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.apache.maven.artifact.deployer; - -/* - * 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.List; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.apache.maven.repository.legacy.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.repository.legacy.metadata.ArtifactMetadataSource; -import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; -import org.apache.maven.repository.legacy.metadata.ResolutionGroup; - -import javax.inject.Named; -import javax.inject.Singleton; - -/** @author Jason van Zyl */ -@Named( "classpath" ) -@Singleton -public class SimpleArtifactMetadataSource - implements ArtifactMetadataSource -{ - public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, - List remoteRepositories ) - { - throw new UnsupportedOperationException( "Cannot retrieve metadata in this test case" ); - } - - public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, - List remoteRepositories ) - { - return Collections.singletonList( new DefaultArtifactVersion( "10.1.3" ) ); - } - - public List retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, - ArtifactRepository localRepository, - ArtifactRepository remoteRepository ) - { - return Collections.singletonList( new DefaultArtifactVersion( "10.1.3" ) ); - } - - public ResolutionGroup retrieve( MetadataResolutionRequest request ) - { - return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java deleted file mode 100644 index d124894d6d26..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.apache.maven.artifact.factory; - -/* - * 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 javax.inject.Inject; - -import org.codehaus.plexus.testing.PlexusTest; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.versioning.VersionRange; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -@PlexusTest -public class DefaultArtifactFactoryTest -{ - - @Inject - ArtifactFactory factory; - - @Test - public void testPropagationOfSystemScopeRegardlessOfInheritedScope() - { - Artifact artifact = factory.createDependencyArtifact( "test-grp", "test-artifact", VersionRange.createFromVersion("1.0"), "type", null, "system", "provided" ); - Artifact artifact2 = factory.createDependencyArtifact( "test-grp", "test-artifact-2", VersionRange.createFromVersion("1.0"), "type", null, "system", "test" ); - Artifact artifact3 = factory.createDependencyArtifact( "test-grp", "test-artifact-3", VersionRange.createFromVersion("1.0"), "type", null, "system", "runtime" ); - Artifact artifact4 = factory.createDependencyArtifact( "test-grp", "test-artifact-4", VersionRange.createFromVersion("1.0"), "type", null, "system", "compile" ); - - // this one should never happen in practice... - Artifact artifact5 = factory.createDependencyArtifact( "test-grp", "test-artifact-5", VersionRange.createFromVersion("1.0"), "type", null, "system", "system" ); - - assertEquals( "system", artifact.getScope() ); - assertEquals( "system", artifact2.getScope() ); - assertEquals( "system", artifact3.getScope() ); - assertEquals( "system", artifact4.getScope() ); - assertEquals( "system", artifact5.getScope() ); - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java deleted file mode 100644 index ca99ab2a53cc..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.apache.maven.artifact.installer; - -/* - * 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.artifact.AbstractArtifactComponentTestCase; -import org.apache.maven.artifact.Artifact; -import org.junit.jupiter.api.Test; - -import javax.inject.Inject; - -import static org.codehaus.plexus.testing.PlexusExtension.getBasedir; - -/** - * @author Jason van Zyl - */ -public class ArtifactInstallerTest - extends AbstractArtifactComponentTestCase -{ - @Inject - private ArtifactInstaller artifactInstaller; - - protected String component() - { - return "installer"; - } - - @Test - public void testArtifactInstallation() - throws Exception - { - String artifactBasedir = new File( getBasedir(), "src/test/resources/artifact-install" ).getAbsolutePath(); - - Artifact artifact = createArtifact( "artifact", "1.0" ); - - File source = new File( artifactBasedir, "artifact-1.0.jar" ); - - artifactInstaller.install( source, artifact, localRepository() ); - - assertLocalArtifactPresent( artifact ); - } -} \ No newline at end of file diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/metadata/TestMetadataSource.java b/maven-compat/src/test/java/org/apache/maven/artifact/metadata/TestMetadataSource.java deleted file mode 100644 index f1973f9e60dd..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/artifact/metadata/TestMetadataSource.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.apache.maven.artifact.metadata; - -/* - * 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.HashSet; -import java.util.List; -import java.util.Set; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -@Named( "test" ) -@Singleton -public class TestMetadataSource - implements ArtifactMetadataSource -{ - @Inject - private ArtifactFactory factory; - - public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) - throws ArtifactMetadataRetrievalException - { - Set dependencies = new HashSet<>(); - - if ( "g".equals( artifact.getArtifactId() ) ) - { - Artifact a = null; - try - { - a = factory.createBuildArtifact( "org.apache.maven", "h", "1.0", "jar" ); - dependencies.add( a ); - } - catch ( Exception e ) - { - throw new ArtifactMetadataRetrievalException( "Error retrieving metadata", e, a ); - } - } - - if ( "i".equals( artifact.getArtifactId() ) ) - { - Artifact a = null; - try - { - a = factory.createBuildArtifact( "org.apache.maven", "j", "1.0-SNAPSHOT", "jar" ); - dependencies.add( a ); - } - catch ( Exception e ) - { - throw new ArtifactMetadataRetrievalException( "Error retrieving metadata", e, a ); - } - } - - - return new ResolutionGroup( artifact, dependencies, remoteRepositories ); - } - - public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) - throws ArtifactMetadataRetrievalException - { - throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); - } - - public List retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository ) - throws ArtifactMetadataRetrievalException - { - throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); - } - - public ResolutionGroup retrieve( MetadataResolutionRequest request ) - throws ArtifactMetadataRetrievalException - { - return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); - } - - public List retrieveAvailableVersions( MetadataResolutionRequest request ) - throws ArtifactMetadataRetrievalException - { - return retrieveAvailableVersions( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/repository/MavenArtifactRepositoryTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/repository/MavenArtifactRepositoryTest.java deleted file mode 100644 index 4e7b5dc8c1d3..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/artifact/repository/MavenArtifactRepositoryTest.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.apache.maven.artifact.repository; - -/* - * 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.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class MavenArtifactRepositoryTest -{ - private static class MavenArtifactRepositorySubclass extends MavenArtifactRepository - { - String id; - - public MavenArtifactRepositorySubclass(String id) - { - this.id = id; - } - - @Override - public String getId() - { - return id; - } - } - - @Test - public void testHashCodeEquals() - { - MavenArtifactRepositorySubclass r1 = new MavenArtifactRepositorySubclass( "foo" ); - MavenArtifactRepositorySubclass r2 = new MavenArtifactRepositorySubclass( "foo" ); - MavenArtifactRepositorySubclass r3 = new MavenArtifactRepositorySubclass( "bar" ); - - assertTrue( r1.hashCode() == r2.hashCode() ); - assertFalse( r1.hashCode() == r3.hashCode() ); - - assertTrue( r1.equals( r2 ) ); - assertTrue( r2.equals( r1 ) ); - - assertFalse( r1.equals( r3 ) ); - assertFalse( r3.equals( r1 ) ); - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java deleted file mode 100644 index e6b0e567a20a..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.apache.maven.artifact.resolver; - -/* - * 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.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Test the artifact resolution exception message - * - * @author Mauro Talevi - */ -public class ArtifactResolutionExceptionTest -{ - private static final String LS = System.lineSeparator(); - - @Test - public void testMissingArtifactMessageFormat() - { - String message = "Missing artifact"; - String indentation = " "; - String groupId = "aGroupId"; - String artifactId = "anArtifactId"; - String version = "aVersion"; - String type = "jar"; - String classifier = "aClassifier"; - String downloadUrl = "http://somewhere.com/download"; - List path = Arrays.asList( "dependency1", "dependency2" ); - String expected = - "Missing artifact" + LS + LS + " Try downloading the file manually from: " + LS - + " http://somewhere.com/download" + LS + LS + " Then, install it using the command: " + LS - + " mvn install:install-file -DgroupId=aGroupId -DartifactId=anArtifactId -Dversion=aVersion " - + "-Dclassifier=aClassifier -Dpackaging=jar -Dfile=/path/to/file" + LS + LS - + " Alternatively, if you host your own repository you can deploy the file there: " + LS - + " mvn deploy:deploy-file -DgroupId=aGroupId -DartifactId=anArtifactId" - + " -Dversion=aVersion -Dclassifier=aClassifier -Dpackaging=jar -Dfile=/path/to/file" - + " -Durl=[url] -DrepositoryId=[id]" + LS + LS + " Path to dependency: " + LS + " \t1) dependency1" - + LS + " \t2) dependency2" + LS + LS; - String actual = - AbstractArtifactResolutionException.constructMissingArtifactMessage( message, indentation, groupId, - artifactId, version, type, classifier, - downloadUrl, path ); - assertEquals( expected, actual ); - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java deleted file mode 100644 index 6aa065297ef9..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java +++ /dev/null @@ -1,277 +0,0 @@ -package org.apache.maven.artifact.resolver; - -/* - * 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.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import org.apache.maven.artifact.AbstractArtifactComponentTestCase; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.metadata.ResolutionGroup; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import javax.inject.Inject; - -// It would be cool if there was a hook that i could use to setup a test environment. -// I want to setup a local/remote repositories for testing but i don't want to have -// to change them when i change the layout of the repositories. So i want to generate -// the structure i want to test by using the artifact handler manager which dictates -// the layout used for a particular artifact type. - -/** - * @author Jason van Zyl - */ -public class ArtifactResolverTest - extends AbstractArtifactComponentTestCase -{ - @Inject - private ArtifactResolver artifactResolver; - - private Artifact projectArtifact; - - @BeforeEach - @Override - public void setUp() - throws Exception - { - super.setUp(); - - projectArtifact = createLocalArtifact( "project", "3.0" ); - } - - @Override - protected String component() - { - return "resolver"; - } - - @Test - public void testResolutionOfASingleArtifactWhereTheArtifactIsPresentInTheLocalRepository() - throws Exception - { - Artifact a = createLocalArtifact( "a", "1.0" ); - - artifactResolver.resolve( a, remoteRepositories(), localRepository() ); - - assertLocalArtifactPresent( a ); - } - - @Test - public void testResolutionOfASingleArtifactWhereTheArtifactIsNotPresentLocallyAndMustBeRetrievedFromTheRemoteRepository() - throws Exception - { - Artifact b = createRemoteArtifact( "b", "1.0-SNAPSHOT" ); - deleteLocalArtifact( b ); - artifactResolver.resolve( b, remoteRepositories(), localRepository() ); - assertLocalArtifactPresent( b ); - } - - @Override - protected Artifact createArtifact( String groupId, String artifactId, String version, String type ) - throws Exception - { - // for the anonymous classes - return super.createArtifact( groupId, artifactId, version, type ); - } - - @Test - public void testTransitiveResolutionWhereAllArtifactsArePresentInTheLocalRepository() - throws Exception - { - Artifact g = createLocalArtifact( "g", "1.0" ); - - Artifact h = createLocalArtifact( "h", "1.0" ); - - ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( g ), projectArtifact, remoteRepositories(), localRepository(), null ); - - printErrors( result ); - - assertEquals( 2, result.getArtifacts().size() ); - - assertTrue( result.getArtifacts().contains( g ) ); - - assertTrue( result.getArtifacts().contains( h ) ); - - assertLocalArtifactPresent( g ); - - assertLocalArtifactPresent( h ); - } - - @Test - public void testTransitiveResolutionWhereAllArtifactsAreNotPresentInTheLocalRepositoryAndMustBeRetrievedFromTheRemoteRepository() - throws Exception - { - Artifact i = createRemoteArtifact( "i", "1.0-SNAPSHOT" ); - deleteLocalArtifact( i ); - - Artifact j = createRemoteArtifact( "j", "1.0-SNAPSHOT" ); - deleteLocalArtifact( j ); - - ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( i ), projectArtifact, remoteRepositories(), localRepository(), null ); - - printErrors( result ); - - assertEquals( 2, result.getArtifacts().size() ); - - assertTrue( result.getArtifacts().contains( i ) ); - - assertTrue( result.getArtifacts().contains( j ) ); - - assertLocalArtifactPresent( i ); - - assertLocalArtifactPresent( j ); - } - - @Test - public void testResolutionFailureWhenArtifactNotPresentInRemoteRepository() - throws Exception - { - Artifact k = createArtifact( "k", "1.0" ); - - assertThrows( - ArtifactNotFoundException.class, - () -> artifactResolver.resolve( k, remoteRepositories(), localRepository() ), - "Resolution succeeded when it should have failed" ); - } - - @Test - public void testResolutionOfAnArtifactWhereOneRemoteRepositoryIsBadButOneIsGood() - throws Exception - { - Artifact l = createRemoteArtifact( "l", "1.0-SNAPSHOT" ); - deleteLocalArtifact( l ); - - List repositories = new ArrayList<>(); - repositories.add( remoteRepository() ); - repositories.add( badRemoteRepository() ); - - artifactResolver.resolve( l, repositories, localRepository() ); - - assertLocalArtifactPresent( l ); - } - - @Test - public void testTransitiveResolutionOrder() - throws Exception - { - Artifact m = createLocalArtifact( "m", "1.0" ); - - Artifact n = createLocalArtifact( "n", "1.0" ); - - ArtifactMetadataSource mds = new ArtifactMetadataSource() - { - public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, - List remoteRepositories ) - { - Set dependencies = new HashSet<>(); - - return new ResolutionGroup( artifact, dependencies, remoteRepositories ); - } - - public List retrieveAvailableVersions( Artifact artifact, - ArtifactRepository localRepository, - List remoteRepositories ) - { - throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); - } - - public List retrieveAvailableVersionsFromDeploymentRepository( - Artifact artifact, - ArtifactRepository localRepository, - ArtifactRepository remoteRepository ) - { - throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); - } - - public ResolutionGroup retrieve( MetadataResolutionRequest request ) - { - return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); - } - - public List retrieveAvailableVersions( MetadataResolutionRequest request ) - { - return retrieveAvailableVersions( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); - } - }; - - ArtifactResolutionResult result = null; - - Set set = new LinkedHashSet<>(); - set.add( n ); - set.add( m ); - - result = - artifactResolver.resolveTransitively( set, projectArtifact, remoteRepositories(), localRepository(), mds ); - - printErrors( result ); - - Iterator i = result.getArtifacts().iterator(); - assertEquals( n, i.next(), "n should be first" ); - assertEquals( m, i.next(), "m should be second" ); - - // inverse order - set = new LinkedHashSet<>(); - set.add( m ); - set.add( n ); - - result = - artifactResolver.resolveTransitively( set, projectArtifact, remoteRepositories(), localRepository(), mds ); - - printErrors( result ); - - i = result.getArtifacts().iterator(); - assertEquals( m, i.next(), "m should be first" ); - assertEquals( n, i.next(), "n should be second" ); - } - - private void printErrors( ArtifactResolutionResult result ) - { - if ( result.hasMissingArtifacts() ) - { - for ( Artifact artifact : result.getMissingArtifacts() ) - { - System.err.println( "Missing: " + artifact ); - } - } - - if ( result.hasExceptions() ) - { - for ( Exception e : result.getExceptions() ) - { - e.printStackTrace(); - } - } - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java deleted file mode 100644 index 23e93be88247..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.apache.maven.artifact.resolver; - -/* - * 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 org.apache.maven.artifact.AbstractArtifactComponentTestCase; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.resolver.DefaultArtifactResolver.DaemonThreadCreator; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -import javax.inject.Inject; - -public class DefaultArtifactResolverTest - extends AbstractArtifactComponentTestCase -{ - @Inject - private ArtifactResolver artifactResolver; - - private Artifact projectArtifact; - - @BeforeEach - @Override - public void setUp() - throws Exception - { - super.setUp(); - projectArtifact = createLocalArtifact( "project", "3.0" ); - } - - @Override - protected String component() - { - return "resolver"; - } - - @Test - public void testMNG4738() - throws Exception - { - Artifact g = createLocalArtifact( "g", "1.0" ); - createLocalArtifact( "h", "1.0" ); - artifactResolver.resolveTransitively( Collections.singleton( g ), projectArtifact, remoteRepositories(), - localRepository(), null ); - - // we want to see all top-level thread groups - ThreadGroup tg = Thread.currentThread().getThreadGroup(); - while ( tg.getParent() == null ) - { - tg = tg.getParent(); - } - - ThreadGroup[] tgList = new ThreadGroup[tg.activeGroupCount()]; - tg.enumerate( tgList ); - - boolean seen = false; - - for ( ThreadGroup aTgList : tgList ) - { - if ( !aTgList.getName().equals( DaemonThreadCreator.THREADGROUP_NAME ) ) - { - continue; - } - - seen = true; - - tg = aTgList; - Thread[] ts = new Thread[tg.activeCount()]; - tg.enumerate( ts ); - - for ( Thread active : ts ) - { - String name = active.getName(); - boolean daemon = active.isDaemon(); - assertTrue( daemon, name + " is no daemon Thread." ); - } - - } - - assertTrue( seen, "Could not find ThreadGroup: " + DaemonThreadCreator.THREADGROUP_NAME ); - } - - @Test - public void testLookup() - throws Exception - { - ArtifactResolver resolver = getContainer().lookup( ArtifactResolver.class, "default" ); - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestFileWagon.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestFileWagon.java deleted file mode 100644 index c78c1901bb20..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestFileWagon.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.apache.maven.artifact.resolver; - -/* - * 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.io.InputStream; - -import org.apache.maven.wagon.ResourceDoesNotExistException; -import org.apache.maven.wagon.TransferFailedException; -import org.apache.maven.wagon.authorization.AuthorizationException; -import org.apache.maven.wagon.events.TransferListener; -import org.apache.maven.wagon.providers.file.FileWagon; -import org.apache.maven.wagon.resource.Resource; - -/** - * Wagon used for test cases that annotates some methods. Note that this is not a thread-safe implementation. - */ -public class TestFileWagon - extends FileWagon -{ - private TestTransferListener testTransferListener; - private boolean insideGet; - - protected void getTransfer( Resource resource, - File destination, - InputStream input, - boolean closeInput, - int maxSize ) - throws TransferFailedException - { - addTransfer( "getTransfer " + resource.getName() ); - super.getTransfer( resource, destination, input, closeInput, maxSize ); - } - - public void get( String resourceName, File destination ) - throws TransferFailedException, - ResourceDoesNotExistException, - AuthorizationException - { - addTransfer( "get " + resourceName ); - - insideGet = true; - - super.get( resourceName, destination ); - - insideGet = false; - } - - private void addTransfer( String resourceName ) - { - if ( testTransferListener != null ) - { - testTransferListener.addTransfer( resourceName ); - } - } - - public boolean getIfNewer( String resourceName, File destination, long timestamp ) - throws TransferFailedException, - ResourceDoesNotExistException, - AuthorizationException - { - if ( !insideGet ) - { - addTransfer( "getIfNewer " + resourceName ); - } - return super.getIfNewer( resourceName, destination, timestamp ); - } - - public void addTransferListener( TransferListener listener ) - { - if ( listener instanceof TestTransferListener ) - { - testTransferListener = (TestTransferListener) listener; - } - super.addTransferListener( listener ); - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestTransferListener.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestTransferListener.java deleted file mode 100644 index 82ee63e958cf..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestTransferListener.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.apache.maven.artifact.resolver; - -/* - * 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.List; - -import org.apache.maven.wagon.observers.AbstractTransferListener; - -public class TestTransferListener - extends AbstractTransferListener -{ - - private final List transfers = new ArrayList<>(); - - public List getTransfers() - { - return transfers; - } - - public void addTransfer( String name ) - { - transfers.add( name ); - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/AndArtifactFilterTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/AndArtifactFilterTest.java deleted file mode 100644 index 96a888223200..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/AndArtifactFilterTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.apache.maven.artifact.resolver.filter; - -/* - * 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 org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Tests {@link AndArtifactFilter}. - * - * @author Benjamin Bentmann - */ -public class AndArtifactFilterTest -{ - - private ArtifactFilter newSubFilter() - { - return artifact -> false; - } - - @Test - public void testEquals() - { - AndArtifactFilter filter1 = new AndArtifactFilter(); - - AndArtifactFilter filter2 = new AndArtifactFilter( Arrays.asList( newSubFilter() ) ); - - assertFalse( filter1.equals( null ) ); - assertTrue( filter1.equals( filter1 ) ); - assertEquals( filter1.hashCode(), filter1.hashCode() ); - - assertFalse( filter1.equals( filter2 ) ); - assertFalse( filter2.equals( filter1 ) ); - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/FilterHashEqualsTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/FilterHashEqualsTest.java deleted file mode 100644 index 6c3df9e900fa..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/FilterHashEqualsTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.apache.maven.artifact.resolver.filter; - -/* - * 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.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * @author Igor Fedorenko - */ -public class FilterHashEqualsTest -{ - - @Test - public void testIncludesExcludesArtifactFilter() - { - List patterns = Arrays.asList( "c", "d", "e" ); - - IncludesArtifactFilter f1 = new IncludesArtifactFilter( patterns ); - - IncludesArtifactFilter f2 = new IncludesArtifactFilter( patterns ); - - assertTrue( f1.equals(f2) ); - assertTrue( f2.equals(f1) ); - assertTrue( f1.hashCode() == f2.hashCode() ); - - IncludesArtifactFilter f3 = new IncludesArtifactFilter( Arrays.asList( "d", "c", "e" ) ); - assertTrue( f1.equals( f3 ) ); - assertTrue( f1.hashCode() == f3.hashCode() ); - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/OrArtifactFilterTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/OrArtifactFilterTest.java deleted file mode 100644 index 65d9caa2b248..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/OrArtifactFilterTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.apache.maven.artifact.resolver.filter; - -/* - * 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 org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Tests {@link OrArtifactFilter}. - * - * @author Benjamin Bentmann - */ -public class OrArtifactFilterTest -{ - - private ArtifactFilter newSubFilter() - { - return artifact -> false; - } - - @Test - public void testEquals() - { - OrArtifactFilter filter1 = new OrArtifactFilter(); - - OrArtifactFilter filter2 = new OrArtifactFilter( Arrays.asList( newSubFilter() ) ); - - assertFalse( filter1.equals( null ) ); - assertTrue( filter1.equals( filter1 ) ); - assertEquals( filter1.hashCode(), filter1.hashCode() ); - - assertFalse( filter1.equals( filter2 ) ); - assertFalse( filter2.equals( filter1 ) ); - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/ScopeArtifactFilterTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/ScopeArtifactFilterTest.java deleted file mode 100644 index 914ff99bcbaa..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/ScopeArtifactFilterTest.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.apache.maven.artifact.resolver.filter; - -/* - * 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.artifact.Artifact; -import org.apache.maven.artifact.DefaultArtifact; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Tests {@link ScopeArtifactFilter}. - * - * @author Benjamin Bentmann - */ -public class ScopeArtifactFilterTest -{ - - private Artifact newArtifact( String scope ) - { - return new DefaultArtifact( "g", "a", "1.0", scope, "jar", "", null ); - } - - @Test - public void testInclude_Compile() - { - ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE ); - - assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) ); - assertFalse( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) ); - assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) ); - } - - @Test - public void testInclude_CompilePlusRuntime() - { - ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE_PLUS_RUNTIME ); - - assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) ); - assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) ); - } - - @Test - public void testInclude_Runtime() - { - ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME ); - - assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) ); - assertFalse( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) ); - assertFalse( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) ); - assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) ); - } - - @Test - public void testInclude_RuntimePlusSystem() - { - ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME_PLUS_SYSTEM ); - - assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) ); - assertFalse( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) ); - assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) ); - } - - @Test - public void testInclude_Test() - { - ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_TEST ); - - assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) ); - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java b/maven-compat/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java deleted file mode 100644 index 558b5a5ca326..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java +++ /dev/null @@ -1,218 +0,0 @@ -package org.apache.maven.artifact.testutils; - -/* - * 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. - */ - -/* - * 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.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.codehaus.plexus.util.FileUtils; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class TestFileManager -{ - - public static final String TEMP_DIR_PATH = System.getProperty( "java.io.tmpdir" ); - - private List filesToDelete = new ArrayList<>(); - - private final String baseFilename; - - private final String fileSuffix; - - private StackTraceElement callerInfo; - - private Thread cleanupWarning; - - private boolean warnAboutCleanup = false; - - public TestFileManager( String baseFilename, String fileSuffix ) - { - this.baseFilename = baseFilename; - this.fileSuffix = fileSuffix; - - initializeCleanupMonitoring(); - } - - private void initializeCleanupMonitoring() - { - callerInfo = new NullPointerException().getStackTrace()[2]; - - Runnable warning = this::maybeWarnAboutCleanUp; - - cleanupWarning = new Thread( warning ); - - Runtime.getRuntime().addShutdownHook( cleanupWarning ); - } - - private void maybeWarnAboutCleanUp() - { - if ( warnAboutCleanup ) - { - System.out.println( "[WARNING] TestFileManager from: " + callerInfo.getClassName() + " not cleaned up!" ); - } - } - - public void markForDeletion( File toDelete ) - { - filesToDelete.add( toDelete ); - warnAboutCleanup = true; - } - - public synchronized File createTempDir() - { - try - { - Thread.sleep( 20 ); - } - catch ( InterruptedException e ) - { - // ignore - } - - File dir = new File( TEMP_DIR_PATH, baseFilename + System.currentTimeMillis() ); - - dir.mkdirs(); - markForDeletion( dir ); - - return dir; - } - - public synchronized File createTempFile() - throws IOException - { - File tempFile = File.createTempFile( baseFilename, fileSuffix ); - tempFile.deleteOnExit(); - markForDeletion( tempFile ); - - return tempFile; - } - - public void cleanUp() - throws IOException - { - for ( Iterator it = filesToDelete.iterator(); it.hasNext(); ) - { - File file = (File) it.next(); - - if ( file.exists() ) - { - if ( file.isDirectory() ) - { - FileUtils.deleteDirectory( file ); - } - else - { - file.delete(); - } - } - - it.remove(); - } - - warnAboutCleanup = false; - } - - public void assertFileExistence( File dir, String filename, boolean shouldExist ) - { - File file = new File( dir, filename ); - - if ( shouldExist ) - { - assertTrue( file.exists() ); - } - else - { - assertFalse( file.exists() ); - } - } - - public void assertFileContents( File dir, String filename, String contentsTest, String encoding ) - throws IOException - { - assertFileExistence( dir, filename, true ); - - File file = new File( dir, filename ); - - String contents = FileUtils.fileRead( file, encoding ); - - assertEquals( contentsTest, contents ); - } - - public File createFile( File dir, String filename, String contents, String encoding ) - throws IOException - { - File file = new File( dir, filename ); - - file.getParentFile().mkdirs(); - - FileUtils.fileWrite( file.getPath(), encoding, contents ); - - markForDeletion( file ); - - return file; - } - - public String getFileContents( File file, String encoding ) - throws IOException - { - return FileUtils.fileRead( file, encoding ); - } - - protected void finalize() - throws Throwable - { - maybeWarnAboutCleanUp(); - - super.finalize(); - } - - public File createFile( String filename, String content, String encoding ) - throws IOException - { - File dir = createTempDir(); - return createFile( dir, filename, content, encoding ); - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java deleted file mode 100644 index 68a7522d5f99..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.apache.maven.artifact.transform; - -/* - * 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.List; - -import org.apache.maven.repository.legacy.resolver.transform.ArtifactTransformation; -import org.apache.maven.repository.legacy.resolver.transform.ArtifactTransformationManager; -import org.apache.maven.repository.legacy.resolver.transform.LatestArtifactTransformation; -import org.apache.maven.repository.legacy.resolver.transform.ReleaseArtifactTransformation; -import org.apache.maven.repository.legacy.resolver.transform.SnapshotTransformation; -import org.codehaus.plexus.testing.PlexusTest; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import javax.inject.Inject; - -/** @author Jason van Zyl */ -@PlexusTest -public class TransformationManagerTest -{ - @Inject - ArtifactTransformationManager tm; - - @Test - public void testTransformationManager() - { - List tms = tm.getArtifactTransformations(); - - assertEquals( 3, tms.size() ); - - assertTrue( tms.get(0) instanceof ReleaseArtifactTransformation, "We expected the release transformation and got " + tms.get(0) ); - - assertTrue( tms.get(1) instanceof LatestArtifactTransformation, "We expected the latest transformation and got " + tms.get(1) ); - - assertTrue( tms.get(2) instanceof SnapshotTransformation, "We expected the snapshot transformation and got " + tms.get(2) ); - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java b/maven-compat/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java deleted file mode 100644 index bcb50a1ad2db..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java +++ /dev/null @@ -1,249 +0,0 @@ -package org.apache.maven.profiles.manager; - -/* - * 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.List; -import java.util.Properties; - -import javax.inject.Inject; - -import org.codehaus.plexus.testing.PlexusTest; -import org.apache.maven.model.Activation; -import org.apache.maven.model.ActivationProperty; -import org.apache.maven.model.Profile; -import org.apache.maven.profiles.DefaultProfileManager; -import org.apache.maven.profiles.ProfileManager; -import org.codehaus.plexus.PlexusContainer; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -@PlexusTest -public class DefaultProfileManagerTest -{ - - @Inject - PlexusContainer container; - - protected PlexusContainer getContainer() { - return container; - } - - @Test - public void testShouldActivateDefaultProfile() - throws Exception - { - Profile notActivated = new Profile(); - notActivated.setId( "notActivated" ); - - Activation nonActivation = new Activation(); - - nonActivation.setJdk( "19.2" ); - - notActivated.setActivation( nonActivation ); - - Profile defaultActivated = new Profile(); - defaultActivated.setId( "defaultActivated" ); - - Activation defaultActivation = new Activation(); - - defaultActivation.setActiveByDefault( true ); - - defaultActivated.setActivation( defaultActivation ); - - Properties props = System.getProperties(); - - ProfileManager profileManager = new DefaultProfileManager( getContainer(), props ); - - profileManager.addProfile( notActivated ); - profileManager.addProfile( defaultActivated ); - - List active = profileManager.getActiveProfiles(); - - assertNotNull( active ); - assertEquals( 1, active.size() ); - assertEquals( "defaultActivated", ( (Profile) active.get( 0 ) ).getId() ); - } - - @Test - public void testShouldNotActivateDefaultProfile() - throws Exception - { - Profile syspropActivated = new Profile(); - syspropActivated.setId( "syspropActivated" ); - - Activation syspropActivation = new Activation(); - - ActivationProperty syspropProperty = new ActivationProperty(); - syspropProperty.setName( "java.version" ); - - syspropActivation.setProperty( syspropProperty ); - - syspropActivated.setActivation( syspropActivation ); - - Profile defaultActivated = new Profile(); - defaultActivated.setId( "defaultActivated" ); - - Activation defaultActivation = new Activation(); - - defaultActivation.setActiveByDefault( true ); - - defaultActivated.setActivation( defaultActivation ); - - Properties props = System.getProperties(); - - ProfileManager profileManager = new DefaultProfileManager( getContainer(), props ); - - profileManager.addProfile( syspropActivated ); - profileManager.addProfile( defaultActivated ); - - List active = profileManager.getActiveProfiles(); - - assertNotNull( active ); - assertEquals( 1, active.size() ); - assertEquals( "syspropActivated", ( (Profile) active.get( 0 ) ).getId() ); - } - - - @Test - public void testShouldNotActivateReversalOfPresentSystemProperty() - throws Exception - { - Profile syspropActivated = new Profile(); - syspropActivated.setId( "syspropActivated" ); - - Activation syspropActivation = new Activation(); - - ActivationProperty syspropProperty = new ActivationProperty(); - syspropProperty.setName( "!java.version" ); - - syspropActivation.setProperty( syspropProperty ); - - syspropActivated.setActivation( syspropActivation ); - - Properties props = System.getProperties(); - - ProfileManager profileManager = new DefaultProfileManager( getContainer(), props ); - - profileManager.addProfile( syspropActivated ); - - List active = profileManager.getActiveProfiles(); - - assertNotNull( active ); - assertEquals( 0, active.size() ); - } - - @Test - public void testShouldOverrideAndActivateInactiveProfile() - throws Exception - { - Profile syspropActivated = new Profile(); - syspropActivated.setId( "syspropActivated" ); - - Activation syspropActivation = new Activation(); - - ActivationProperty syspropProperty = new ActivationProperty(); - syspropProperty.setName( "!java.version" ); - - syspropActivation.setProperty( syspropProperty ); - - syspropActivated.setActivation( syspropActivation ); - - Properties props = System.getProperties(); - - ProfileManager profileManager = new DefaultProfileManager( getContainer(), props ); - - profileManager.addProfile( syspropActivated ); - - profileManager.explicitlyActivate( "syspropActivated" ); - - List active = profileManager.getActiveProfiles(); - - assertNotNull( active ); - assertEquals( 1, active.size() ); - assertEquals( "syspropActivated", ( (Profile) active.get( 0 ) ).getId() ); - } - - @Test - public void testShouldOverrideAndDeactivateActiveProfile() - throws Exception - { - Profile syspropActivated = new Profile(); - syspropActivated.setId( "syspropActivated" ); - - Activation syspropActivation = new Activation(); - - ActivationProperty syspropProperty = new ActivationProperty(); - syspropProperty.setName( "java.version" ); - - syspropActivation.setProperty( syspropProperty ); - - syspropActivated.setActivation( syspropActivation ); - - Properties props = System.getProperties(); - - ProfileManager profileManager = new DefaultProfileManager( getContainer(), props ); - - profileManager.addProfile( syspropActivated ); - - profileManager.explicitlyDeactivate( "syspropActivated" ); - - List active = profileManager.getActiveProfiles(); - - assertNotNull( active ); - assertEquals( 0, active.size() ); - } - - @Test - @Disabled - public void testOsActivationProfile() - throws Exception - { - /* - Profile osActivated = new Profile(); - osActivated.setId( "os-profile" ); - - Activation osActivation = new Activation(); - - ActivationOS activationOS = new ActivationOS(); - - activationOS.setName( "!dddd" ); - - osActivation.setOs( activationOS ); - - osActivated.setActivation( osActivation ); - - Properties props = System.getProperties(); - ProfileActivationContext ctx = new ProfileActivationContext( props, false ); - - ProfileManager profileManager = new DefaultProfileManager( getContainer(), props ); - - profileManager.addProfile( osActivated ); - - List active = profileManager.getActiveProfiles( null ); - - assertNotNull( active ); - assertEquals( 1, active.size() ); - */ - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java b/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java deleted file mode 100644 index 482a5b4730d6..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java +++ /dev/null @@ -1,169 +0,0 @@ -package org.apache.maven.project; - -/* - * 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.io.FileNotFoundException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.Arrays; - -import javax.inject.Inject; - -import org.codehaus.plexus.testing.PlexusTest; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.model.building.ModelBuildingException; -import org.apache.maven.model.building.ModelProblem; -import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.repository.internal.MavenRepositorySystemUtils; -import org.codehaus.plexus.PlexusContainer; -import org.eclipse.aether.DefaultRepositorySystemSession; -import org.junit.jupiter.api.BeforeEach; - -import static org.junit.jupiter.api.Assertions.fail; - -/** - * @author Jason van Zyl - */ -@PlexusTest -public abstract class AbstractMavenProjectTestCase -{ - protected ProjectBuilder projectBuilder; - - @Inject - protected RepositorySystem repositorySystem; - - @Inject - protected PlexusContainer container; - - public PlexusContainer getContainer() { - return container; - } - - @BeforeEach - public void setUp() - throws Exception - { - if ( getContainer().hasComponent( ProjectBuilder.class, "test" ) ) - { - projectBuilder = getContainer().lookup( ProjectBuilder.class, "test" ); - } - else - { - // default over to the main project builder... - projectBuilder = getContainer().lookup( ProjectBuilder.class ); - } - } - - protected ProjectBuilder getProjectBuilder() - { - return projectBuilder; - } - - // ---------------------------------------------------------------------- - // Local repository - // ---------------------------------------------------------------------- - - protected File getLocalRepositoryPath() - throws FileNotFoundException, URISyntaxException - { - File markerFile = getFileForClasspathResource( "local-repo/marker.txt" ); - - return markerFile.getAbsoluteFile().getParentFile(); - } - - protected static File getFileForClasspathResource( String resource ) - throws FileNotFoundException - { - ClassLoader cloader = Thread.currentThread().getContextClassLoader(); - - URL resourceUrl = cloader.getResource( resource ); - - if ( resourceUrl == null ) - { - throw new FileNotFoundException( "Unable to find: " + resource ); - } - - return new File( URI.create( resourceUrl.toString().replaceAll( " ", "%20" ) ) ); - } - - protected ArtifactRepository getLocalRepository() - throws Exception - { - ArtifactRepositoryLayout repoLayout = getContainer().lookup( ArtifactRepositoryLayout.class ); - - ArtifactRepository r = repositorySystem.createArtifactRepository( "local", "file://" + getLocalRepositoryPath().getAbsolutePath(), repoLayout, null, null ); - - return r; - } - - // ---------------------------------------------------------------------- - // Project building - // ---------------------------------------------------------------------- - - protected MavenProject getProjectWithDependencies( File pom ) - throws Exception - { - ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest(); - configuration.setLocalRepository( getLocalRepository() ); - configuration.setRemoteRepositories( Arrays.asList( new ArtifactRepository[] {} ) ); - configuration.setProcessPlugins( false ); - configuration.setResolveDependencies( true ); - initRepoSession( configuration ); - - try - { - return projectBuilder.build( pom, configuration ).getProject(); - } - catch ( Exception e ) - { - Throwable cause = e.getCause(); - if ( cause instanceof ModelBuildingException ) - { - String message = "In: " + pom + "\n\n"; - for ( ModelProblem problem : ( (ModelBuildingException) cause ).getProblems() ) - { - message += problem + "\n"; - } - System.out.println( message ); - fail( message ); - } - - throw e; - } - } - - protected MavenProject getProject( File pom ) - throws Exception - { - ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest(); - configuration.setLocalRepository( getLocalRepository() ); - initRepoSession( configuration ); - - return projectBuilder.build( pom, configuration ).getProject(); - } - - protected void initRepoSession( ProjectBuildingRequest request ) - { - File localRepo = new File( request.getLocalRepository().getBasedir() ); - DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); - session.setLocalRepositoryManager( new LegacyLocalRepositoryManager( localRepo ) ); - request.setRepositorySession( session ); - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java b/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java deleted file mode 100644 index f4813593f852..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.apache.maven.project; - -/* - * 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.FileNotFoundException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.impl.ArtifactResolver; -import org.eclipse.aether.resolution.ArtifactRequest; -import org.eclipse.aether.resolution.ArtifactResolutionException; -import org.eclipse.aether.resolution.ArtifactResult; -import org.eclipse.aether.transfer.ArtifactNotFoundException; - -import javax.inject.Named; -import javax.inject.Singleton; - -/** - * @author Benjamin Bentmann - */ -@Named( "classpath" ) -@Singleton -public class ClasspathArtifactResolver - implements ArtifactResolver -{ - - public List resolveArtifacts( RepositorySystemSession session, - Collection requests ) - throws ArtifactResolutionException - { - List results = new ArrayList<>(); - - for ( ArtifactRequest request : requests ) - { - ArtifactResult result = new ArtifactResult( request ); - results.add( result ); - - Artifact artifact = request.getArtifact(); - if ( "maven-test".equals( artifact.getGroupId() ) ) - { - String scope = artifact.getArtifactId().substring( "scope-".length() ); - - try - { - artifact = - artifact.setFile( ProjectClasspathTest.getFileForClasspathResource( ProjectClasspathTest.dir - + "transitive-" + scope + "-dep.xml" ) ); - result.setArtifact( artifact ); - } - catch ( FileNotFoundException e ) - { - throw new IllegalStateException( "Missing test POM for " + artifact ); - } - } - else - { - result.addException( new ArtifactNotFoundException( artifact, null ) ); - throw new ArtifactResolutionException( results ); - } - } - - return results; - } - - public ArtifactResult resolveArtifact( RepositorySystemSession session, ArtifactRequest request ) - throws ArtifactResolutionException - { - return resolveArtifacts( session, Collections.singleton( request ) ).get( 0 ); - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java b/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java deleted file mode 100644 index 21c73497623e..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.apache.maven.project; - -/* - * 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.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import org.apache.maven.execution.MavenSession; -import org.apache.maven.lifecycle.DefaultLifecycles; -import org.apache.maven.lifecycle.LifecycleExecutor; -import org.apache.maven.lifecycle.MavenExecutionPlan; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginExecution; -import org.apache.maven.plugin.MojoExecution; - -/** - * A stub implementation that assumes an empty lifecycle to bypass interaction with the plugin manager and to avoid - * plugin artifact resolution from repositories. - * - * @author Benjamin Bentmann - */ -public class EmptyLifecycleExecutor - implements LifecycleExecutor -{ - - public MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks ) - { - return new MavenExecutionPlan( null, new DefaultLifecycles() ); - } - - public MavenExecutionPlan calculateExecutionPlan( MavenSession session, boolean setup, String... tasks ) - { - return new MavenExecutionPlan( null, new DefaultLifecycles() ); - } - - public void execute( MavenSession session ) - { - } - - public Set getPluginsBoundByDefaultToAllLifecycles( String packaging ) - { - Set plugins; - - // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests - if ( "JAR".equals( packaging ) ) - { - plugins = new LinkedHashSet<>(); - - plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) ); - plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) ); - plugins.add( newPlugin( "maven-surefire-plugin", "test" ) ); - plugins.add( newPlugin( "maven-jar-plugin", "jar" ) ); - plugins.add( newPlugin( "maven-install-plugin", "install" ) ); - plugins.add( newPlugin( "maven-deploy-plugin", "deploy" ) ); - } - else - { - plugins = Collections.emptySet(); - } - - return plugins; - } - - private Plugin newPlugin( String artifactId, String... goals ) - { - Plugin plugin = new Plugin(); - - plugin.setGroupId( "org.apache.maven.plugins" ); - plugin.setArtifactId( artifactId ); - - for ( String goal : goals ) - { - PluginExecution pluginExecution = new PluginExecution(); - pluginExecution.setId( "default-" + goal ); - pluginExecution.addGoal( goal ); - plugin.addExecution( pluginExecution ); - } - - return plugin; - } - - public void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session ) - { - } - - public List executeForkedExecutions( MojoExecution mojoExecution, MavenSession session ) - { - return Collections.emptyList(); - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java b/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java deleted file mode 100644 index 672e07b35eb2..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.apache.maven.project; - -/* - * 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.LinkedHashSet; -import java.util.Set; - -import org.apache.maven.lifecycle.LifeCyclePluginAnalyzer; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginExecution; - -/** - * @author Benjamin Bentmann - */ -public class EmptyLifecyclePluginAnalyzer - implements LifeCyclePluginAnalyzer -{ - public Set getPluginsBoundByDefaultToAllLifecycles( String packaging ) - { - Set plugins; - - // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests - if ( "JAR".equals( packaging ) ) - { - plugins = new LinkedHashSet<>(); - - plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) ); - plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) ); - plugins.add( newPlugin( "maven-surefire-plugin", "test" ) ); - plugins.add( newPlugin( "maven-jar-plugin", "jar" ) ); - plugins.add( newPlugin( "maven-install-plugin", "install" ) ); - plugins.add( newPlugin( "maven-deploy-plugin", "deploy" ) ); - } - else - { - plugins = Collections.emptySet(); - } - - return plugins; - } - - private Plugin newPlugin( String artifactId, String... goals ) - { - Plugin plugin = new Plugin(); - - plugin.setGroupId( "org.apache.maven.plugins" ); - plugin.setArtifactId( artifactId ); - - for ( String goal : goals ) - { - PluginExecution pluginExecution = new PluginExecution(); - pluginExecution.setId( "default-" + goal ); - pluginExecution.addGoal( goal ); - plugin.addExecution( pluginExecution ); - } - - return plugin; - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java b/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java deleted file mode 100644 index c919cdf77670..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java +++ /dev/null @@ -1,192 +0,0 @@ -package org.apache.maven.project; - -/* - * 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.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.metadata.Metadata; -import org.eclipse.aether.repository.LocalArtifactRegistration; -import org.eclipse.aether.repository.LocalArtifactRequest; -import org.eclipse.aether.repository.LocalArtifactResult; -import org.eclipse.aether.repository.LocalMetadataRegistration; -import org.eclipse.aether.repository.LocalMetadataRequest; -import org.eclipse.aether.repository.LocalMetadataResult; -import org.eclipse.aether.repository.LocalRepository; -import org.eclipse.aether.repository.LocalRepositoryManager; -import org.eclipse.aether.repository.RemoteRepository; - -/** - * @author Benjamin Bentmann - */ -public class LegacyLocalRepositoryManager - implements LocalRepositoryManager -{ - - private final LocalRepository repository; - - public LegacyLocalRepositoryManager( File basedir ) - { - this.repository = new LocalRepository( basedir.getAbsoluteFile(), "legacy" ); - } - - public LocalRepository getRepository() - { - return repository; - } - - public String getPathForLocalArtifact( Artifact artifact ) - { - StringBuilder path = new StringBuilder( 128 ); - - path.append( artifact.getGroupId() ).append( '/' ); - - path.append( artifact.getExtension() ).append( "s/" ); - - path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() ); - - if ( artifact.getClassifier().length() > 0 ) - { - path.append( '-' ).append( artifact.getClassifier() ); - } - - path.append( '.' ).append( artifact.getExtension() ); - - return path.toString(); - } - - public String getPathForRemoteArtifact( Artifact artifact, RemoteRepository repository, String context ) - { - return getPathForLocalArtifact( artifact ); - } - - public String getPathForLocalMetadata( Metadata metadata ) - { - return getPath( metadata, "local" ); - } - - public String getPathForRemoteMetadata( Metadata metadata, RemoteRepository repository, String context ) - { - return getPath( metadata, getRepositoryKey( repository, context ) ); - } - - String getRepositoryKey( RemoteRepository repository, String context ) - { - return repository.getId(); - } - - private String getPath( Metadata metadata, String repositoryKey ) - { - StringBuilder path = new StringBuilder( 128 ); - - if ( metadata.getGroupId().length() > 0 ) - { - path.append( metadata.getGroupId().replace( '.', '/' ) ).append( '/' ); - - if ( metadata.getArtifactId().length() > 0 ) - { - path.append( metadata.getArtifactId() ).append( '/' ); - - if ( metadata.getVersion().length() > 0 ) - { - path.append( metadata.getVersion() ).append( '/' ); - } - } - } - - path.append( insertRepositoryKey( metadata.getType(), repositoryKey ) ); - - return path.toString(); - } - - private String insertRepositoryKey( String filename, String repositoryKey ) - { - String result; - int idx = filename.indexOf( '.' ); - if ( idx < 0 ) - { - result = filename + '-' + repositoryKey; - } - else - { - result = filename.substring( 0, idx ) + '-' + repositoryKey + filename.substring( idx ); - } - return result; - } - - public LocalArtifactResult find( RepositorySystemSession session, LocalArtifactRequest request ) - { - String path = getPathForLocalArtifact( request.getArtifact() ); - File file = new File( getRepository().getBasedir(), path ); - - LocalArtifactResult result = new LocalArtifactResult( request ); - if ( file.isFile() ) - { - result.setFile( file ); - result.setAvailable( true ); - } - - return result; - } - - public void add( RepositorySystemSession session, LocalArtifactRegistration request ) - { - // noop - } - - public LocalMetadataResult find( RepositorySystemSession session, LocalMetadataRequest request ) - { - LocalMetadataResult result = new LocalMetadataResult( request ); - - String path; - - Metadata metadata = request.getMetadata(); - String context = request.getContext(); - RemoteRepository remote = request.getRepository(); - - if ( remote != null ) - { - path = getPathForRemoteMetadata( metadata, remote, context ); - } - else - { - path = getPathForLocalMetadata( metadata ); - } - - File file = new File( getRepository().getBasedir(), path ); - if ( file.isFile() ) - { - result.setFile( file ); - } - - return result; - } - - public void add( RepositorySystemSession session, LocalMetadataRegistration request ) - { - // noop - } - - public String toString() - { - return String.valueOf( getRepository() ); - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java b/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java deleted file mode 100644 index 74178d98c386..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java +++ /dev/null @@ -1,637 +0,0 @@ -package org.apache.maven.project; - -/* - * 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.IOException; -import java.io.StringReader; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.apache.maven.model.Build; -import org.apache.maven.model.Dependency; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginContainer; -import org.apache.maven.model.PluginExecution; -import org.codehaus.plexus.util.xml.Xpp3Dom; -import org.codehaus.plexus.util.xml.Xpp3DomBuilder; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertSame; - -public class ModelUtilsTest -{ - - @Test - public void testShouldUseMainPluginDependencyVersionOverManagedDepVersion() - { - Plugin mgtPlugin = createPlugin( "group", "artifact", "1", Collections.EMPTY_MAP ); - Dependency mgtDep = createDependency( "g", "a", "2" ); - mgtPlugin.addDependency( mgtDep ); - - Plugin plugin = createPlugin( "group", "artifact", "1", Collections.EMPTY_MAP ); - Dependency dep = createDependency( "g", "a", "1" ); - plugin.addDependency( dep ); - - ModelUtils.mergePluginDefinitions( plugin, mgtPlugin, false ); - - assertEquals( dep.getVersion(), plugin.getDependencies().get( 0 ).getVersion() ); - } - - private Dependency createDependency( String gid, - String aid, - String ver ) - { - Dependency dep = new Dependency(); - dep.setGroupId( gid ); - dep.setArtifactId( aid ); - dep.setVersion( ver ); - - return dep; - } - - @Test - public void testShouldNotInheritPluginWithInheritanceSetToFalse() - { - PluginContainer parent = new PluginContainer(); - - Plugin parentPlugin = createPlugin( "group", "artifact", "1.0", Collections.EMPTY_MAP ); - parentPlugin.setInherited( "false" ); - - parent.addPlugin( parentPlugin ); - - PluginContainer child = new PluginContainer(); - - child.addPlugin( createPlugin( "group3", "artifact3", "1.0", Collections.EMPTY_MAP ) ); - - ModelUtils.mergePluginLists( child, parent, true ); - - List results = child.getPlugins(); - - assertEquals( 1, results.size() ); - - Plugin result1 = (Plugin) results.get( 0 ); - assertEquals( "group3", result1.getGroupId() ); - assertEquals( "artifact3", result1.getArtifactId() ); - } - - /** - * Test that this is the resulting ordering of plugins after merging: - *

- * Given: - *

- *
-     *   parent: X -> A -> B -> D -> E
-     *   child: Y -> A -> C -> D -> F
-     * 
- *

- * Result: - *

- *
-     *   X -> Y -> A -> B -> C -> D -> E -> F
-     * 
- */ - @Test - public void testShouldPreserveChildOrderingOfPluginsAfterParentMerge() - { - PluginContainer parent = new PluginContainer(); - - parent.addPlugin( createPlugin( "group", "artifact", "1.0", Collections.EMPTY_MAP ) ); - parent.addPlugin( createPlugin( "group2", "artifact2", "1.0", Collections.singletonMap( "key", "value" ) ) ); - - PluginContainer child = new PluginContainer(); - - child.addPlugin( createPlugin( "group3", "artifact3", "1.0", Collections.EMPTY_MAP ) ); - child.addPlugin( createPlugin( "group2", "artifact2", "1.0", Collections.singletonMap( "key2", "value2" ) ) ); - - ModelUtils.mergePluginLists( child, parent, true ); - - List results = child.getPlugins(); - - assertEquals( 3, results.size() ); - - Plugin result1 = (Plugin) results.get( 0 ); - - assertEquals( "group", result1.getGroupId() ); - assertEquals( "artifact", result1.getArtifactId() ); - - Plugin result2 = (Plugin) results.get( 1 ); - - assertEquals( "group3", result2.getGroupId() ); - assertEquals( "artifact3", result2.getArtifactId() ); - - Plugin result3 = (Plugin) results.get( 2 ); - - assertEquals( "group2", result3.getGroupId() ); - assertEquals( "artifact2", result3.getArtifactId() ); - - Xpp3Dom result3Config = (Xpp3Dom) result3.getConfiguration(); - - assertNotNull( result3Config ); - - assertEquals( "value", result3Config.getChild( "key" ).getValue() ); - assertEquals( "value2", result3Config.getChild( "key2" ).getValue() ); - } - - private Plugin createPlugin( String groupId, String artifactId, String version, Map configuration ) - { - Plugin plugin = new Plugin(); - plugin.setGroupId( groupId ); - plugin.setArtifactId( artifactId ); - plugin.setVersion( version ); - - Xpp3Dom config = new Xpp3Dom( "configuration" ); - - if( configuration != null ) - { - for ( Object o : configuration.entrySet() ) - { - Map.Entry entry = (Map.Entry) o; - - Xpp3Dom param = new Xpp3Dom( String.valueOf( entry.getKey() ) ); - param.setValue( String.valueOf( entry.getValue() ) ); - - config.addChild( param ); - } - } - - plugin.setConfiguration( config ); - - return plugin; - } - - @Test - public void testShouldInheritOnePluginWithExecution() - { - Plugin parent = new Plugin(); - parent.setArtifactId( "testArtifact" ); - parent.setGroupId( "testGroup" ); - parent.setVersion( "1.0" ); - - PluginExecution parentExecution = new PluginExecution(); - parentExecution.setId( "testExecution" ); - - parent.addExecution( parentExecution ); - - Plugin child = new Plugin(); - child.setArtifactId( "testArtifact" ); - child.setGroupId( "testGroup" ); - child.setVersion( "1.0" ); - - ModelUtils.mergePluginDefinitions( child, parent, false ); - - assertEquals( 1, child.getExecutions().size() ); - } - - @Test - public void testShouldMergeInheritedPluginHavingExecutionWithLocalPlugin() - { - Plugin parent = new Plugin(); - parent.setArtifactId( "testArtifact" ); - parent.setGroupId( "testGroup" ); - parent.setVersion( "1.0" ); - - PluginExecution parentExecution = new PluginExecution(); - parentExecution.setId( "testExecution" ); - - parent.addExecution( parentExecution ); - - Plugin child = new Plugin(); - child.setArtifactId( "testArtifact" ); - child.setGroupId( "testGroup" ); - child.setVersion( "1.0" ); - - PluginExecution childExecution = new PluginExecution(); - childExecution.setId( "testExecution2" ); - - child.addExecution( childExecution ); - - ModelUtils.mergePluginDefinitions( child, parent, false ); - - assertEquals( 2, child.getExecutions().size() ); - } - - @Test - public void testShouldMergeOnePluginWithInheritExecutionWithoutDuplicatingPluginInList() - { - Plugin parent = new Plugin(); - parent.setArtifactId( "testArtifact" ); - parent.setGroupId( "testGroup" ); - parent.setVersion( "1.0" ); - - PluginExecution parentExecution = new PluginExecution(); - parentExecution.setId( "testExecution" ); - - parent.addExecution( parentExecution ); - - Build parentContainer = new Build(); - parentContainer.addPlugin( parent ); - - Plugin child = new Plugin(); - child.setArtifactId( "testArtifact" ); - child.setGroupId( "testGroup" ); - child.setVersion( "1.0" ); - - Build childContainer = new Build(); - childContainer.addPlugin( child ); - - ModelUtils.mergePluginLists( childContainer, parentContainer, true ); - - List plugins = childContainer.getPlugins(); - - assertEquals( 1, plugins.size() ); - - Plugin plugin = (Plugin) plugins.get( 0 ); - - assertEquals( 1, plugin.getExecutions().size() ); - } - - @Test - public void testShouldMergePluginWithDifferentExecutionFromParentWithoutDuplicatingPluginInList() - { - Plugin parent = new Plugin(); - parent.setArtifactId( "testArtifact" ); - parent.setGroupId( "testGroup" ); - parent.setVersion( "1.0" ); - - PluginExecution parentExecution = new PluginExecution(); - parentExecution.setId( "testExecution" ); - - parent.addExecution( parentExecution ); - - Build parentContainer = new Build(); - parentContainer.addPlugin( parent ); - - Plugin child = new Plugin(); - child.setArtifactId( "testArtifact" ); - child.setGroupId( "testGroup" ); - child.setVersion( "1.0" ); - - PluginExecution childExecution = new PluginExecution(); - childExecution.setId( "testExecution2" ); - - child.addExecution( childExecution ); - - - Build childContainer = new Build(); - childContainer.addPlugin( child ); - - ModelUtils.mergePluginLists( childContainer, parentContainer, true ); - - List plugins = childContainer.getPlugins(); - - assertEquals( 1, plugins.size() ); - - Plugin plugin = (Plugin) plugins.get( 0 ); - - assertEquals( 2, plugin.getExecutions().size() ); - } - - @Test - public void testShouldNOTMergeInheritedPluginHavingInheritEqualFalse() - { - Plugin parent = new Plugin(); - parent.setArtifactId( "testArtifact" ); - parent.setGroupId( "testGroup" ); - parent.setVersion( "1.0" ); - parent.setInherited( "false" ); - - PluginExecution parentExecution = new PluginExecution(); - parentExecution.setId( "testExecution" ); - - parent.addExecution( parentExecution ); - - Plugin child = new Plugin(); - child.setArtifactId( "testArtifact" ); - child.setGroupId( "testGroup" ); - child.setVersion( "1.0" ); - - ModelUtils.mergePluginDefinitions( child, parent, true ); - - assertEquals( 0, child.getExecutions().size() ); - } - - /** - * Verifies MNG-1499: The order of the merged list should be the plugins specified by the parent followed by the - * child list. - */ - @Test - public void testShouldKeepOriginalPluginOrdering() - { - Plugin parentPlugin1 = new Plugin(); - parentPlugin1.setArtifactId( "testArtifact" ); - parentPlugin1.setGroupId( "zzz" ); // This will put this plugin last in the sorted map - parentPlugin1.setVersion( "1.0" ); - - PluginExecution parentExecution1 = new PluginExecution(); - parentExecution1.setId( "testExecution" ); - - parentPlugin1.addExecution( parentExecution1 ); - - Plugin parentPlugin2 = new Plugin(); - parentPlugin2.setArtifactId( "testArtifact" ); - parentPlugin2.setGroupId( "yyy" ); - parentPlugin2.setVersion( "1.0" ); - - PluginExecution parentExecution2 = new PluginExecution(); - parentExecution2.setId( "testExecution" ); - - parentPlugin2.addExecution( parentExecution2 ); - - PluginContainer parentContainer = new PluginContainer(); - parentContainer.addPlugin(parentPlugin1); - parentContainer.addPlugin(parentPlugin2); - - - Plugin childPlugin1 = new Plugin(); - childPlugin1.setArtifactId( "testArtifact" ); - childPlugin1.setGroupId( "bbb" ); - childPlugin1.setVersion( "1.0" ); - - PluginExecution childExecution1 = new PluginExecution(); - childExecution1.setId( "testExecution" ); - - childPlugin1.addExecution( childExecution1 ); - - Plugin childPlugin2 = new Plugin(); - childPlugin2.setArtifactId( "testArtifact" ); - childPlugin2.setGroupId( "aaa" ); - childPlugin2.setVersion( "1.0" ); - - PluginExecution childExecution2 = new PluginExecution(); - childExecution2.setId( "testExecution" ); - - childPlugin2.addExecution( childExecution2 ); - - PluginContainer childContainer = new PluginContainer(); - childContainer.addPlugin(childPlugin1); - childContainer.addPlugin(childPlugin2); - - - ModelUtils.mergePluginLists(childContainer, parentContainer, true); - - assertEquals( 4, childContainer.getPlugins().size() ); - assertSame(parentPlugin1, childContainer.getPlugins().get(0)); - assertSame(parentPlugin2, childContainer.getPlugins().get(1)); - assertSame(childPlugin1, childContainer.getPlugins().get(2)); - assertSame(childPlugin2, childContainer.getPlugins().get(3)); - } - - /** - * Verifies MNG-1499: The ordering of plugin executions should also be in the specified order. - */ - @Test - public void testShouldKeepOriginalPluginExecutionOrdering() - { - Plugin parent = new Plugin(); - parent.setArtifactId( "testArtifact" ); - parent.setGroupId( "testGroup" ); - parent.setVersion( "1.0" ); - - PluginExecution parentExecution1 = new PluginExecution(); - parentExecution1.setId( "zzz" ); // Will show up last in the sorted map - PluginExecution parentExecution2 = new PluginExecution(); - parentExecution2.setId( "yyy" ); // Will show up last in the sorted map - - parent.addExecution( parentExecution1 ); - parent.addExecution( parentExecution2 ); - - // this block verifies MNG-1703 - Dependency dep = new Dependency(); - dep.setGroupId( "depGroupId" ); - dep.setArtifactId( "depArtifactId" ); - dep.setVersion( "depVersion" ); - parent.setDependencies( Collections.singletonList( dep ) ); - - Plugin child = new Plugin(); - child.setArtifactId( "testArtifact" ); - child.setGroupId( "testGroup" ); - child.setVersion( "1.0" ); - - PluginExecution childExecution1 = new PluginExecution(); - childExecution1.setId( "bbb" ); - PluginExecution childExecution2 = new PluginExecution(); - childExecution2.setId( "aaa" ); - - child.addExecution( childExecution1 ); - child.addExecution( childExecution2 ); - - ModelUtils.mergePluginDefinitions( child, parent, false ); - - assertEquals( 4, child.getExecutions().size() ); - assertSame(parentExecution1, child.getExecutions().get(0)); - assertSame(parentExecution2, child.getExecutions().get(1)); - assertSame(childExecution1, child.getExecutions().get(2)); - assertSame(childExecution2, child.getExecutions().get(3)); - - // this block prevents MNG-1703 - assertEquals( 1, child.getDependencies().size() ); - Dependency dep2 = child.getDependencies().get( 0 ); - assertEquals( dep.getManagementKey(), dep2.getManagementKey() ); - } - - @Test - public void testShouldOverwritePluginConfigurationSubItemsByDefault() - throws XmlPullParserException, IOException - { - String parentConfigStr = "onetwo"; - Xpp3Dom parentConfig = Xpp3DomBuilder.build( new StringReader( parentConfigStr ) ); - - Plugin parentPlugin = createPlugin( "group", "artifact", "1", null ); - parentPlugin.setConfiguration( parentConfig ); - - String childConfigStr = "three"; - Xpp3Dom childConfig = Xpp3DomBuilder.build( new StringReader( childConfigStr ) ); - - Plugin childPlugin = createPlugin( "group", "artifact", "1", null ); - childPlugin.setConfiguration( childConfig ); - - ModelUtils.mergePluginDefinitions( childPlugin, parentPlugin, true ); - - Xpp3Dom result = (Xpp3Dom) childPlugin.getConfiguration(); - Xpp3Dom items = result.getChild( "items" ); - - assertEquals( 1, items.getChildCount() ); - - Xpp3Dom item = items.getChild( 0 ); - assertEquals( "three", item.getValue() ); - } - - @Test - public void testShouldMergePluginConfigurationSubItemsWithMergeAttributeSet() - throws XmlPullParserException, IOException - { - String parentConfigStr = "onetwo"; - Xpp3Dom parentConfig = Xpp3DomBuilder.build( new StringReader( parentConfigStr ) ); - - Plugin parentPlugin = createPlugin( "group", "artifact", "1", null ); - parentPlugin.setConfiguration( parentConfig ); - - String childConfigStr = "three"; - Xpp3Dom childConfig = Xpp3DomBuilder.build( new StringReader( childConfigStr ) ); - - Plugin childPlugin = createPlugin( "group", "artifact", "1", null ); - childPlugin.setConfiguration( childConfig ); - - ModelUtils.mergePluginDefinitions( childPlugin, parentPlugin, true ); - - Xpp3Dom result = (Xpp3Dom) childPlugin.getConfiguration(); - Xpp3Dom items = result.getChild( "items" ); - - assertEquals( 3, items.getChildCount() ); - - Xpp3Dom[] item = items.getChildren(); - - List actual = Arrays.asList( item[0].getValue(), item[1].getValue(), item[2].getValue() ); - List expected = Arrays.asList( "one", "two", "three" ); - Collections.sort( actual ); - Collections.sort( expected ); - assertEquals( expected, actual ); - } - - @Test - public void testShouldNotMergePluginExecutionWhenExecInheritedIsFalseAndTreatAsInheritanceIsTrue() - { - String gid = "group"; - String aid = "artifact"; - String ver = "1"; - - PluginContainer parent = new PluginContainer(); - Plugin pParent = createPlugin( gid, aid, ver, Collections.EMPTY_MAP ); - - pParent.setInherited( Boolean.toString( true ) ); - - PluginExecution eParent = new PluginExecution(); - - String testId = "test"; - - eParent.setId( testId ); - eParent.addGoal( "run" ); - eParent.setPhase( "initialize" ); - eParent.setInherited( Boolean.toString( false ) ); - - pParent.addExecution( eParent ); - parent.addPlugin( pParent ); - - PluginContainer child = new PluginContainer(); - Plugin pChild = createPlugin( gid, aid, ver, Collections.EMPTY_MAP ); - PluginExecution eChild = new PluginExecution(); - - eChild.setId( "child-specified" ); - eChild.addGoal( "child" ); - eChild.setPhase( "compile" ); - - pChild.addExecution( eChild ); - child.addPlugin( pChild ); - - ModelUtils.mergePluginDefinitions( pChild, pParent, true ); - - Map executionMap = pChild.getExecutionsAsMap(); - assertNull( executionMap.get( testId ), "test execution should not be inherited from parent." ); - } - - @Test - public void testShouldNotMergePluginExecutionWhenPluginInheritedIsFalseAndTreatAsInheritanceIsTrue() - { - String gid = "group"; - String aid = "artifact"; - String ver = "1"; - - PluginContainer parent = new PluginContainer(); - Plugin pParent = createPlugin( gid, aid, ver, Collections.EMPTY_MAP ); - - pParent.setInherited( Boolean.toString( false ) ); - - PluginExecution eParent = new PluginExecution(); - - String testId = "test"; - - eParent.setId( testId ); - eParent.addGoal( "run" ); - eParent.setPhase( "initialize" ); - eParent.setInherited( Boolean.toString( true ) ); - - pParent.addExecution( eParent ); - parent.addPlugin( pParent ); - - PluginContainer child = new PluginContainer(); - Plugin pChild = createPlugin( gid, aid, ver, Collections.EMPTY_MAP ); - PluginExecution eChild = new PluginExecution(); - - eChild.setId( "child-specified" ); - eChild.addGoal( "child" ); - eChild.setPhase( "compile" ); - - pChild.addExecution( eChild ); - child.addPlugin( pChild ); - - ModelUtils.mergePluginDefinitions( pChild, pParent, true ); - - Map executionMap = pChild.getExecutionsAsMap(); - assertNull( executionMap.get( testId ), "test execution should not be inherited from parent." ); - } - - @Test - public void testShouldMergePluginExecutionWhenExecInheritedIsTrueAndTreatAsInheritanceIsTrue() - { - String gid = "group"; - String aid = "artifact"; - String ver = "1"; - - PluginContainer parent = new PluginContainer(); - Plugin pParent = createPlugin( gid, aid, ver, Collections.EMPTY_MAP ); - - pParent.setInherited( Boolean.toString( true ) ); - - PluginExecution eParent = new PluginExecution(); - - String testId = "test"; - - eParent.setId( testId ); - eParent.addGoal( "run" ); - eParent.setPhase( "initialize" ); - eParent.setInherited( Boolean.toString( true ) ); - - pParent.addExecution( eParent ); - parent.addPlugin( pParent ); - - PluginContainer child = new PluginContainer(); - Plugin pChild = createPlugin( gid, aid, ver, Collections.EMPTY_MAP ); - PluginExecution eChild = new PluginExecution(); - - eChild.setId( "child-specified" ); - eChild.addGoal( "child" ); - eChild.setPhase( "compile" ); - - pChild.addExecution( eChild ); - child.addPlugin( pChild ); - - ModelUtils.mergePluginDefinitions( pChild, pParent, true ); - - Map executionMap = pChild.getExecutionsAsMap(); - assertNotNull( executionMap.get( testId ), "test execution should be inherited from parent." ); - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java b/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java deleted file mode 100644 index a2119cea539d..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java +++ /dev/null @@ -1,147 +0,0 @@ -package org.apache.maven.project; - -/* - * 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.artifact.Artifact; -import org.apache.maven.repository.internal.DefaultArtifactDescriptorReader; -import org.eclipse.aether.impl.ArtifactDescriptorReader; -import org.eclipse.aether.impl.ArtifactResolver; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; - -public class ProjectClasspathTest - extends AbstractMavenProjectTestCase -{ - static final String dir = "projects/scope/"; - - @Override - @BeforeEach - public void setUp() - throws Exception - { - super.setUp(); - - ArtifactResolver resolver = getContainer().lookup( ArtifactResolver.class, "classpath" ); - DefaultArtifactDescriptorReader pomReader = (DefaultArtifactDescriptorReader)getContainer().lookup(ArtifactDescriptorReader.class); - pomReader.setArtifactResolver( resolver ); - - projectBuilder = getContainer().lookup( ProjectBuilder.class, "classpath" ); - } - - @Test - public void testProjectClasspath() - throws Exception - { - File f = getFileForClasspathResource( dir + "project-with-scoped-dependencies.xml" ); - - MavenProject project = getProjectWithDependencies( f ); - - Artifact artifact; - - assertNotNull( project, "Test project can't be null!" ); - - checkArtifactIdScope( project, "provided", "provided" ); - checkArtifactIdScope( project, "test", "test" ); - checkArtifactIdScope( project, "compile", "compile" ); - checkArtifactIdScope( project, "runtime", "runtime" ); - checkArtifactIdScope( project, "default", "compile" ); - - // check all transitive deps of a test dependency are test, except test and provided which is skipped - artifact = getArtifact( project, "maven-test-test", "scope-provided" ); - assertNull( artifact, "Check no provided dependencies are transitive" ); - artifact = getArtifact( project, "maven-test-test", "scope-test" ); - assertNull( artifact, "Check no test dependencies are transitive" ); - - artifact = getArtifact( project, "maven-test-test", "scope-compile" ); - assertNotNull( artifact ); - - System.out.println( "a = " + artifact ); - System.out.println( "b = " + artifact.getScope() ); - assertEquals( "test", artifact.getScope(), "Check scope" ); - artifact = getArtifact( project, "maven-test-test", "scope-default" ); - assertEquals( "test", artifact.getScope(), "Check scope" ); - artifact = getArtifact( project, "maven-test-test", "scope-runtime" ); - assertEquals( "test", artifact.getScope(), "Check scope" ); - - // check all transitive deps of a provided dependency are provided scope, except for test - checkGroupIdScope( project, "provided", "maven-test-provided" ); - artifact = getArtifact( project, "maven-test-provided", "scope-runtime" ); - assertEquals( "provided", artifact.getScope(), "Check scope" ); - - // check all transitive deps of a runtime dependency are runtime scope, except for test - checkGroupIdScope( project, "runtime", "maven-test-runtime" ); - artifact = getArtifact( project, "maven-test-runtime", "scope-runtime" ); - assertEquals( "runtime", artifact.getScope(), "Check scope" ); - - // check all transitive deps of a compile dependency are compile scope, except for runtime and test - checkGroupIdScope( project, "compile", "maven-test-compile" ); - artifact = getArtifact( project, "maven-test-compile", "scope-runtime" ); - assertEquals( "runtime", artifact.getScope(), "Check scope" ); - - // check all transitive deps of a default dependency are compile scope, except for runtime and test - checkGroupIdScope( project, "compile", "maven-test-default" ); - artifact = getArtifact( project, "maven-test-default", "scope-runtime" ); - assertEquals( "runtime", artifact.getScope(), "Check scope" ); - } - - private void checkGroupIdScope( MavenProject project, String scopeValue, String groupId ) - { - Artifact artifact; - artifact = getArtifact( project, groupId, "scope-compile" ); - assertEquals( scopeValue, artifact.getScope(), "Check scope" ); - artifact = getArtifact( project, groupId, "scope-test" ); - assertNull( artifact, "Check test dependency is not transitive" ); - artifact = getArtifact( project, groupId, "scope-provided" ); - assertNull( artifact, "Check provided dependency is not transitive" ); - artifact = getArtifact( project, groupId, "scope-default" ); - assertEquals( scopeValue, artifact.getScope(), "Check scope" ); - } - - private void checkArtifactIdScope( MavenProject project, String scope, String scopeValue ) - { - String artifactId = "scope-" + scope; - Artifact artifact = getArtifact( project, "maven-test", artifactId ); - assertNotNull( artifact ); - assertEquals( scopeValue, artifact.getScope(), "Check scope" ); - } - - private Artifact getArtifact( MavenProject project, String groupId, String artifactId ) - { - System.out.println( "[ Looking for " + groupId + ":" + artifactId + " ]" ); - for ( Artifact a : project.getArtifacts() ) - { - System.out.println( a.toString() ); - if ( artifactId.equals( a.getArtifactId() ) && a.getGroupId().equals( groupId ) ) - { - System.out.println( "RETURN" ); - return a; - } - } - System.out.println( "Return null" ); - return null; - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/TestArtifactResolver.java b/maven-compat/src/test/java/org/apache/maven/project/TestArtifactResolver.java deleted file mode 100644 index 94b30dbb9806..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/TestArtifactResolver.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.apache.maven.project; - -/* - * 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.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.resolver.DefaultArtifactResolver; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -@Named( "classpath" ) -@Singleton -public class TestArtifactResolver - extends DefaultArtifactResolver -{ - private ArtifactMetadataSource source; - - @Inject - public TestArtifactResolver(final @Named( "classpath" ) ArtifactMetadataSource source) { - this.source = source; - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/TestMavenRepositorySystem.java b/maven-compat/src/test/java/org/apache/maven/project/TestMavenRepositorySystem.java deleted file mode 100644 index 1f3767671195..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/TestMavenRepositorySystem.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.apache.maven.project; - -/* - * 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.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.artifact.resolver.ArtifactResolver; -import org.apache.maven.repository.legacy.LegacyRepositorySystem; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; -import java.util.Map; - -@Named( "classpath" ) -@Singleton -public class TestMavenRepositorySystem - extends LegacyRepositorySystem -{ - @Inject - private ArtifactResolver artifactResolver; -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/TestProjectBuilder.java b/maven-compat/src/test/java/org/apache/maven/project/TestProjectBuilder.java deleted file mode 100644 index 18deb4332bee..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/TestProjectBuilder.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.apache.maven.project; - -/* - * 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.Collections; - -import org.apache.maven.artifact.repository.ArtifactRepository; - -import javax.inject.Named; -import javax.inject.Singleton; - -@Named( "classpath" ) -@Singleton -public class TestProjectBuilder - extends DefaultProjectBuilder -{ - - @Override - public ProjectBuildingResult build( File pomFile, ProjectBuildingRequest configuration ) - throws ProjectBuildingException - { - ProjectBuildingResult result = super.build( pomFile, configuration ); - - result.getProject().setRemoteArtifactRepositories( Collections. emptyList() ); - - return result; - } - -} \ No newline at end of file diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/AbstractProjectInheritanceTestCase.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/AbstractProjectInheritanceTestCase.java deleted file mode 100644 index af3655f826a4..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/AbstractProjectInheritanceTestCase.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.apache.maven.project.inheritance; - -/* - * 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.AbstractMavenProjectTestCase; - -import static org.codehaus.plexus.testing.PlexusExtension.getTestFile; - -/** - * @author Jason van Zyl - */ -public abstract class AbstractProjectInheritanceTestCase - extends AbstractMavenProjectTestCase -{ - protected String getTestSeries() - { - String className = getClass().getPackage().getName(); - - return className.substring( className.lastIndexOf( '.' ) + 1 ); - } - - protected File projectFile( String name ) - { - return projectFile( "maven", name ); - } - - protected File projectFile( String groupId, String artifactId ) - { - return new File( getLocalRepositoryPath(), "/" + groupId + "/poms/" + artifactId + "-1.0.pom" ); - } - - // ---------------------------------------------------------------------- - // The local repository for this category of tests - // ---------------------------------------------------------------------- - - protected File getLocalRepositoryPath() - { - return getTestFile("src/test/resources/inheritance-repo/" + getTestSeries() ); - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java deleted file mode 100644 index 936424dbac06..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.apache.maven.project.inheritance.t00; - -/* - * 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.project.MavenProject; -import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * A test which demonstrates maven's recursive inheritance where - * a distinct value is taken from each parent contributing to the - * the final model of the project being assembled. There is no - * overriding going on amongst the models being used in this test: - * each model in the lineage is providing a value that is not present - * anywhere else in the lineage. We are just making sure that values - * down in the lineage are bubbling up where they should. - * - * @author Jason van Zyl - */ -public class ProjectInheritanceTest - extends AbstractProjectInheritanceTestCase -{ - // ---------------------------------------------------------------------- - // - // p4 inherits from p3 - // p3 inherits from p2 - // p2 inherits from p1 - // p1 inherits from p0 - // p0 inherits from super model - // - // or we can show it graphically as: - // - // p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model - // - // ---------------------------------------------------------------------- - - @Test - public void testProjectInheritance() - throws Exception - { - MavenProject p4 = getProject( projectFile( "p4" ) ); - - assertEquals( "p4", p4.getName() ); - - // ---------------------------------------------------------------------- - // Value inherited from p3 - // ---------------------------------------------------------------------- - - assertEquals( "2000", p4.getInceptionYear() ); - - // ---------------------------------------------------------------------- - // Value taken from p2 - // ---------------------------------------------------------------------- - - assertEquals( "mailing-list", p4.getMailingLists().get( 0 ).getName() ); - - // ---------------------------------------------------------------------- - // Value taken from p1 - // ---------------------------------------------------------------------- - - assertEquals( "scm-url/p2/p3/p4", p4.getScm().getUrl() ); - - // ---------------------------------------------------------------------- - // Value taken from p4 - // ---------------------------------------------------------------------- - - assertEquals( "Codehaus", p4.getOrganization().getName() ); - - // ---------------------------------------------------------------------- - // Value taken from super model - // ---------------------------------------------------------------------- - - assertEquals( "4.0.0", p4.getModelVersion() ); - - assertEquals( "4.0.0", p4.getModelVersion() ); - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t01/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t01/ProjectInheritanceTest.java deleted file mode 100644 index 8f8199e9c117..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t01/ProjectInheritanceTest.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.apache.maven.project.inheritance.t01; - -/* - * 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.project.MavenProject; -import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * A test which demonstrates maven's recursive inheritance where - * we are testing to make sure that elements stated in a model are - * not clobbered by the same elements elsewhere in the lineage. - * - * @author Jason van Zyl - */ -public class ProjectInheritanceTest - extends AbstractProjectInheritanceTestCase -{ - // ---------------------------------------------------------------------- - // - // p4 inherits from p3 - // p3 inherits from p2 - // p2 inherits from p1 - // p1 inherits from p0 - // p0 inherits from super model - // - // or we can show it graphically as: - // - // p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model - // - // ---------------------------------------------------------------------- - - @Test - public void testProjectInheritance() - throws Exception - { - // ---------------------------------------------------------------------- - // Check p0 value for org name - // ---------------------------------------------------------------------- - - MavenProject p0 = getProject( projectFile( "maven.t01", "p0" ) ); - - assertEquals( "p0-org", p0.getOrganization().getName() ); - - // ---------------------------------------------------------------------- - // Check p1 value for org name - // ---------------------------------------------------------------------- - - MavenProject p1 = getProject( projectFile( "maven.t01", "p1" ) ); - - assertEquals( "p1-org", p1.getOrganization().getName() ); - - // ---------------------------------------------------------------------- - // Check p2 value for org name - // ---------------------------------------------------------------------- - - MavenProject p2 = getProject( projectFile( "maven.t01", "p2" ) ); - - assertEquals( "p2-org", p2.getOrganization().getName() ); - - // ---------------------------------------------------------------------- - // Check p2 value for org name - // ---------------------------------------------------------------------- - - MavenProject p3 = getProject( projectFile( "maven.t01", "p3" ) ); - - assertEquals( "p3-org", p3.getOrganization().getName() ); - - // ---------------------------------------------------------------------- - // Check p4 value for org name - // ---------------------------------------------------------------------- - - MavenProject p4 = getProject( projectFile( "maven.t01", "p4" ) ); - - assertEquals( "p4-org", p4.getOrganization().getName() ); - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java deleted file mode 100644 index 61a393238b86..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java +++ /dev/null @@ -1,166 +0,0 @@ -package org.apache.maven.project.inheritance.t02; - -/* - * 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.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.maven.model.Build; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginExecution; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * A test which demonstrates maven's recursive inheritance where - * a distinct value is taken from each parent contributing to the - * the final model of the project being assembled. There is no - * overriding going on amongst the models being used in this test: - * each model in the lineage is providing a value that is not present - * anywhere else in the lineage. We are just making sure that values - * down in the lineage are bubbling up where they should. - * - * @author Jason van Zyl - */ -public class ProjectInheritanceTest - extends AbstractProjectInheritanceTestCase -{ - // ---------------------------------------------------------------------- - // - // p4 inherits from p3 - // p3 inherits from p2 - // p2 inherits from p1 - // p1 inherits from p0 - // p0 inherits from super model - // - // or we can show it graphically as: - // - // p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model - // - // ---------------------------------------------------------------------- - - @Test - public void testProjectInheritance() - throws Exception - { - File localRepo = getLocalRepositoryPath(); - - System.out.println( "Local repository is at: " + localRepo.getAbsolutePath() ); - - File pom0 = new File( localRepo, "p0/pom.xml" ); - File pom1 = new File( pom0.getParentFile(), "p1/pom.xml" ); - File pom2 = new File( pom1.getParentFile(), "p2/pom.xml" ); - File pom3 = new File( pom2.getParentFile(), "p3/pom.xml" ); - File pom4 = new File( pom3.getParentFile(), "p4/pom.xml" ); - File pom5 = new File( pom4.getParentFile(), "p5/pom.xml" ); - - System.out.println( "Location of project-4's POM: " + pom4.getPath() ); - - // load everything... - MavenProject project0 = getProject( pom0 ); - MavenProject project1 = getProject( pom1 ); - MavenProject project2 = getProject( pom2 ); - MavenProject project3 = getProject( pom3 ); - MavenProject project4 = getProject( pom4 ); - MavenProject project5 = getProject( pom5 ); - - assertEquals( "p4", project4.getName() ); - - // ---------------------------------------------------------------------- - // Value inherited from p3 - // ---------------------------------------------------------------------- - - assertEquals( "2000", project4.getInceptionYear() ); - - // ---------------------------------------------------------------------- - // Value taken from p2 - // ---------------------------------------------------------------------- - - assertEquals( "mailing-list", project4.getMailingLists().get( 0 ).getName() ); - - // ---------------------------------------------------------------------- - // Value taken from p1 - // ---------------------------------------------------------------------- - - assertEquals( "scm-url/p2/p3/p4", project4.getScm().getUrl() ); - - // ---------------------------------------------------------------------- - // Value taken from p4 - // ---------------------------------------------------------------------- - - assertEquals( "Codehaus", project4.getOrganization().getName() ); - - // ---------------------------------------------------------------------- - // Value taken from super model - // ---------------------------------------------------------------------- - - assertEquals( "4.0.0", project4.getModelVersion() ); - - Build build = project4.getBuild(); - List plugins = build.getPlugins(); - - Map validPluginCounts = new HashMap<>(); - - String testPluginArtifactId = "maven-compiler-plugin"; - - // this is the plugin we're looking for. - validPluginCounts.put( testPluginArtifactId, 0 ); - - // these are injected if -DperformRelease=true - validPluginCounts.put( "maven-deploy-plugin", 0 ); - validPluginCounts.put( "maven-javadoc-plugin", 0 ); - validPluginCounts.put( "maven-source-plugin", 0 ); - - Plugin testPlugin = null; - - for ( Plugin plugin : plugins ) - { - String pluginArtifactId = plugin.getArtifactId(); - - assertTrue( validPluginCounts.containsKey( pluginArtifactId ), "Illegal plugin found: " + pluginArtifactId ); - - if ( pluginArtifactId.equals( testPluginArtifactId ) ) - { - testPlugin = plugin; - } - - Integer count = validPluginCounts.get( pluginArtifactId ); - - assertEquals( 0, (int) count, "Multiple copies of plugin: " + pluginArtifactId + " found in POM." ); - - count = count + 1; - - validPluginCounts.put( pluginArtifactId, count ); - } - - assertNotNull( testPlugin ); - - List executions = testPlugin.getExecutions(); - - assertEquals( 1, executions.size() ); - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t03/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t03/ProjectInheritanceTest.java deleted file mode 100644 index 3c658d8dbdbf..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t03/ProjectInheritanceTest.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.apache.maven.project.inheritance.t03; - -/* - * 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.MavenProject; -import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * A test which demonstrates maven's recursive inheritance where - * a distinct value is taken from each parent contributing to the - * the final model of the project being assembled. There is no - * overriding going on amongst the models being used in this test: - * each model in the lineage is providing a value that is not present - * anywhere else in the lineage. We are just making sure that values - * down in the lineage are bubbling up where they should. - * - * @author Jason van Zyl - */ -public class ProjectInheritanceTest - extends AbstractProjectInheritanceTestCase -{ - // ---------------------------------------------------------------------- - // - // p1 inherits from p0 - // p0 inherits from super model - // - // or we can show it graphically as: - // - // p1 ---> p0 --> super model - // - // ---------------------------------------------------------------------- - - @Test - public void testProjectInheritance() - throws Exception - { - File localRepo = getLocalRepositoryPath(); - File pom0 = new File( localRepo, "p0/pom.xml" ); - - File pom0Basedir = pom0.getParentFile(); - - File pom1 = new File( pom0Basedir, "p1/pom.xml" ); - - // load everything... - MavenProject project0 = getProject( pom0 ); - MavenProject project1 = getProject( pom1 ); - - assertEquals( pom0Basedir, project1.getParent().getBasedir() ); - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java deleted file mode 100644 index 34a31d5e2104..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.apache.maven.project.inheritance.t04; - -/* - * 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.Set; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Verifies the version of a dependency listed in a parent's - * dependencyManagement section is chosen over another version of the same - * dependency, listed transitively. - * - * @author Patrick Schneider - */ -public class ProjectInheritanceTest - extends AbstractProjectInheritanceTestCase -{ - // ---------------------------------------------------------------------- - // - // p1 inherits from p0 - // p0 inherits from super model - // - // or we can show it graphically as: - // - // p1 ---> p0 --> super model - // - // p1 has a depMgmt section that specifies versions 1.0 of jars "a" & "b" - // jar "a" has a transitive dependency on 2.0 of jar "b", but maven should - // prefer to use version 1.0. - // - // ---------------------------------------------------------------------- - - @Test - public void testDependencyManagementOverridesTransitiveDependencyVersion() - throws Exception - { - File localRepo = getLocalRepositoryPath(); - File pom0 = new File( localRepo, "p0/pom.xml" ); - File pom0Basedir = pom0.getParentFile(); - File pom1 = new File( pom0Basedir, "p1/pom.xml" ); - - // load the child project, which inherits from p0... - MavenProject project0 = getProjectWithDependencies( pom0 ); - MavenProject project1 = getProjectWithDependencies( pom1 ); - - assertEquals( pom0Basedir, project1.getParent().getBasedir() ); - Set set = project1.getArtifacts(); - assertNotNull( set, "No artifacts" ); - assertTrue( set.size() > 0, "No Artifacts" ); - assertTrue( set.size() == 3, "Set size should be 3, is " + set.size() ); - - for ( Object aSet : set ) - { - Artifact artifact = (Artifact) aSet; - System.out.println( - "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Optional=" + ( - artifact.isOptional() - ? "true" - : "false" ) ); - assertTrue( artifact.getVersion().equals( "1.0" ), - "Incorrect version for " + artifact.getDependencyConflictId() ); - } - - } -} \ No newline at end of file diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java deleted file mode 100644 index 8af4a2fdf7ac..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.apache.maven.project.inheritance.t05; - -/* - * 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.Set; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * A test which demonstrates maven's dependency management - * - * @author Ralph Goers - */ -public class ProjectInheritanceTest - extends AbstractProjectInheritanceTestCase -{ - // ---------------------------------------------------------------------- - // - // p1 inherits from p0 - // p0 inherits from super model - // - // or we can show it graphically as: - // - // p1 ---> p0 --> super model - // - // ---------------------------------------------------------------------- - - @Test - public void testDependencyManagement() - throws Exception - { - File localRepo = getLocalRepositoryPath(); - File pom0 = new File( localRepo, "p0/pom.xml" ); - - File pom0Basedir = pom0.getParentFile(); - - File pom1 = new File( pom0Basedir, "p1/pom.xml" ); - - // load everything... - MavenProject project0 = getProjectWithDependencies( pom0 ); - MavenProject project1 = getProjectWithDependencies( pom1 ); - - assertEquals( pom0Basedir, project1.getParent().getBasedir() ); - Set set = project1.getArtifacts(); - assertNotNull( set, "No artifacts" ); - assertTrue( set.size() > 0, "No Artifacts" ); - - for ( Object aSet : set ) - { - Artifact artifact = (Artifact) aSet; - System.out.println( - "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Scope: " - + artifact.getScope() ); - assertTrue( artifact.getVersion().equals( "1.0" ), - "Incorrect version for " + artifact.getDependencyConflictId() ); - } - - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t06/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t06/ProjectInheritanceTest.java deleted file mode 100644 index bc37066a05cb..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t06/ProjectInheritanceTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.apache.maven.project.inheritance.t06; - -/* - * 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.Iterator; -import java.util.Set; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * A test which demonstrates maven's dependency management - * - * @author Ralph Goers - */ -public class ProjectInheritanceTest - extends AbstractProjectInheritanceTestCase -{ - // ---------------------------------------------------------------------- - // - // p1 inherits from p0 - // p0 inherits from super model - // - // or we can show it graphically as: - // - // p1 ---> p0 --> super model - // - // ---------------------------------------------------------------------- - - @Test - public void testDependencyManagement() - throws Exception - { - File localRepo = getLocalRepositoryPath(); - File pom0 = new File( localRepo, "p0/pom.xml" ); - - File pom0Basedir = pom0.getParentFile(); - - File pom1 = new File( pom0Basedir, "p1/pom.xml" ); - - // load everything... - MavenProject project0 = getProjectWithDependencies( pom0 ); - MavenProject project1 = getProjectWithDependencies( pom1 ); - - assertEquals( pom0Basedir, project1.getParent().getBasedir() ); - Set set = project1.getArtifacts(); - assertNotNull( set, "No artifacts" ); - assertTrue( set.size() > 0, "No Artifacts" ); - Iterator iter = set.iterator(); - assertTrue( set.size() == 4, "Set size should be 4, is " + set.size() ); - - while ( iter.hasNext() ) - { - Artifact artifact = (Artifact) iter.next(); - System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() - + " Optional=" + ( artifact.isOptional() ? "true" : "false" ) ); - assertTrue( artifact.getVersion().equals( "1.0" ), - "Incorrect version for " + artifact.getDependencyConflictId() ); - } - - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java deleted file mode 100644 index 87b07d3a8058..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.apache.maven.project.inheritance.t07; - -/* - * 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.Set; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * A test which demonstrates maven's dependency management - * - * @author Jason van Zyl - */ -public class ProjectInheritanceTest - extends AbstractProjectInheritanceTestCase -{ - // ---------------------------------------------------------------------- - // - // p1 inherits from p0 - // p0 inherits from super model - // - // or we can show it graphically as: - // - // p1 ---> p0 --> super model - // - // ---------------------------------------------------------------------- - - @Test - public void testDependencyManagement() - throws Exception - { - File localRepo = getLocalRepositoryPath(); - File pom0 = new File( localRepo, "p0/pom.xml" ); - - File pom0Basedir = pom0.getParentFile(); - - File pom1 = new File( pom0Basedir, "p1/pom.xml" ); - - // load everything... - MavenProject project1 = getProjectWithDependencies( pom1 ); - - assertEquals( pom0Basedir, project1.getParent().getBasedir() ); - System.out.println("Project " + project1.getId() + " " + project1); - Set set = project1.getArtifacts(); - assertNotNull( set, "No artifacts" ); - assertTrue( set.size() > 0, "No Artifacts" ); - assertTrue( set.size() == 3, "Set size should be 3, is " + set.size() ); - - for ( Object aSet : set ) - { - Artifact artifact = (Artifact) aSet; - assertFalse( artifact.getArtifactId().equals( "t07-d" ) ); - System.out.println( - "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Optional=" + ( - artifact.isOptional() - ? "true" - : "false" ) ); - assertTrue( artifact.getVersion().equals( "1.0" ), - "Incorrect version for " + artifact.getDependencyConflictId() ); - } - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t08/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t08/ProjectInheritanceTest.java deleted file mode 100644 index c4562dc67e6d..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t08/ProjectInheritanceTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.apache.maven.project.inheritance.t08; - -/* - * 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.Iterator; -import java.util.Set; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * A test which demonstrates maven's dependency management - * - * @author Ralph Goers - */ -public class ProjectInheritanceTest - extends AbstractProjectInheritanceTestCase -{ - // ---------------------------------------------------------------------- - // - // p1 inherits from p0 - // p0 inherits from super model - // - // or we can show it graphically as: - // - // p1 ---> p0 --> super model - // - // ---------------------------------------------------------------------- - - @Test - public void testDependencyManagement() - throws Exception - { - File localRepo = getLocalRepositoryPath(); - File pom0 = new File( localRepo, "p0/pom.xml" ); - - File pom0Basedir = pom0.getParentFile(); - - File pom1 = new File( pom0Basedir, "p1/pom.xml" ); - - // load everything... - MavenProject project0 = getProjectWithDependencies( pom0 ); - MavenProject project1 = getProjectWithDependencies( pom1 ); - - assertEquals( pom0Basedir, project1.getParent().getBasedir() ); - System.out.println( "Project " + project1.getId() + " " + project1 ); - Set set = project1.getArtifacts(); - assertNotNull( set, "No artifacts" ); - assertTrue( set.size() > 0, "No Artifacts" ); - Iterator iter = set.iterator(); - assertTrue( set.size() == 4, "Set size should be 4, is " + set.size() ); - - while ( iter.hasNext() ) - { - Artifact artifact = (Artifact) iter.next(); - System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() - + " Optional=" + ( artifact.isOptional() ? "true" : "false" ) ); - assertTrue( artifact.getVersion().equals( "1.0" ), "Incorrect version for " + artifact.getDependencyConflictId() ); - } - - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t09/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t09/ProjectInheritanceTest.java deleted file mode 100644 index dcc4e8bf7eac..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t09/ProjectInheritanceTest.java +++ /dev/null @@ -1,127 +0,0 @@ -package org.apache.maven.project.inheritance.t09; - -/* - * 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.maven.project.MavenProject; -import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Verifies exclusions listed in dependencyManagement are valid for - * transitive dependencies. - * - * @author Patrick Schneider - */ -public class ProjectInheritanceTest - extends AbstractProjectInheritanceTestCase -{ - // ---------------------------------------------------------------------- - // - // p1 inherits from p0 - // p0 inherits from super model - // - // or we can show it graphically as: - // - // p1 ---> p0 --> super model - // - // ---------------------------------------------------------------------- - - /** - * How the test project is set up: - * - * 1. dependencyManagement lists dependencies on a & b, - * with an exclusion on c in b. - * 2. the child project lists a dependency on project a only - * 3. a depends on b (which is transitive to the child project), - * and b depends on c. - * - * We should see that the resulting size of collected artifacts is two: - * a & b only. - */ - @Test - public void testDependencyManagementExclusionsExcludeTransitively() - throws Exception - { - File localRepo = getLocalRepositoryPath(); - - File pom0 = new File( localRepo, "p0/pom.xml" ); - File pom0Basedir = pom0.getParentFile(); - File pom1 = new File( pom0Basedir, "p1/pom.xml" ); - - // load the child project, which inherits from p0... - MavenProject project0 = getProjectWithDependencies( pom0 ); - MavenProject project1 = getProjectWithDependencies( pom1 ); - - assertNotNull( project1.getParent(), "Parent is null" ); - assertEquals( pom0Basedir, project1.getParent().getBasedir() ); - Map map = project1.getArtifactMap(); - - assertNotNull( map, "No artifacts" ); - assertTrue( map.size() > 0, "No Artifacts" ); - assertTrue( map.size() == 2, "Set size should be 2, is " + map.size() ); - - assertTrue( map.containsKey( "maven-test:t09-a" ), "maven-test:t09-a is not in the project" ); - assertTrue( map.containsKey( "maven-test:t09-b" ), "maven-test:t09-b is not in the project" ); - assertFalse( map.containsKey( "maven-test:t09-c" ), "maven-test:t09-c is in the project" ); - } - - /** - * Setup exactly the same as the above test, except that the child project - * now depends upon d, which has a transitive dependency on c. Even though - * we did list an exclusion on c, it was only from within the context of - * project b. We will pick up project c in this case because no - * restrictions were placed on d. This demonstrates that a, b, c, & d will - * all be collected. - * - * @throws Exception - */ - @Test - public void testDependencyManagementExclusionDoesNotOverrideGloballyForTransitives() - throws Exception - { - File localRepo = getLocalRepositoryPath(); - - File pom0 = new File( localRepo, "p0/pom.xml" ); - File pom0Basedir = pom0.getParentFile(); - File pom2 = new File( pom0Basedir, "p2/pom.xml" ); - - // load the child project, which inherits from p0... - MavenProject project0 = getProjectWithDependencies( pom0 ); - MavenProject project2 = getProjectWithDependencies( pom2 ); - - assertEquals( pom0Basedir, project2.getParent().getBasedir() ); - Map map = project2.getArtifactMap(); - assertNotNull( map, "No artifacts" ); - assertTrue( map.size() > 0, "No Artifacts" ); - assertTrue( map.size() == 4, "Set size should be 4, is " + map.size() ); - - assertTrue( map.containsKey( "maven-test:t09-a" ), "maven-test:t09-a is not in the project" ); - assertTrue( map.containsKey( "maven-test:t09-b" ), "maven-test:t09-b is not in the project" ); - assertTrue( map.containsKey( "maven-test:t09-c" ), "maven-test:t09-c is not in the project" ); - assertTrue( map.containsKey( "maven-test:t09-d" ), "maven-test:t09-d is not in the project" ); - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t10/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t10/ProjectInheritanceTest.java deleted file mode 100644 index b1e74087ba5a..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t10/ProjectInheritanceTest.java +++ /dev/null @@ -1,100 +0,0 @@ -package org.apache.maven.project.inheritance.t10; - -/* - * 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.maven.artifact.Artifact; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Verifies scope inheritance of direct and transitive dependencies. - * - * Should show three behaviors: - * - * 1. dependencyManagement should override the scope of transitive dependencies. - * 2. Direct dependencies should override the scope of dependencyManagement. - * 3. Direct dependencies should inherit scope from dependencyManagement when - * they do not explicitly state a scope. - * - * @author Patrick Schneider - */ -public class ProjectInheritanceTest - extends AbstractProjectInheritanceTestCase -{ - // ---------------------------------------------------------------------- - // - // p1 inherits from p0 - // p0 inherits from super model - // - // or we can show it graphically as: - // - // p1 ---> p0 --> super model - // - // ---------------------------------------------------------------------- - - @Test - public void testDependencyManagementOverridesTransitiveDependencyVersion() - throws Exception - { - File localRepo = getLocalRepositoryPath(); - - File pom0 = new File( localRepo, "p0/pom.xml" ); - File pom0Basedir = pom0.getParentFile(); - File pom1 = new File( pom0Basedir, "p1/pom.xml" ); - - // load the child project, which inherits from p0... - MavenProject project0 = getProjectWithDependencies( pom0 ); - MavenProject project1 = getProjectWithDependencies( pom1 ); - - assertEquals( pom0Basedir, project1.getParent().getBasedir() ); - System.out.println("Project " + project1.getId() + " " + project1); - Map map = project1.getArtifactMap(); - assertNotNull( map, "No artifacts" ); - assertTrue( map.size() > 0, "No Artifacts" ); - assertTrue( map.size() == 3, "Set size should be 3, is " + map.size() ); - - Artifact a = (Artifact) map.get("maven-test:t10-a"); - Artifact b = (Artifact) map.get("maven-test:t10-b"); - Artifact c = (Artifact) map.get("maven-test:t10-c"); - - assertNotNull( a ); - assertNotNull( b ); - assertNotNull( c ); - - // inherited from depMgmt - System.out.println(a.getScope()); - assertTrue( a.getScope().equals("test"), "Incorrect scope for " + a.getDependencyConflictId() ); - - // transitive dep, overridden b depMgmt - assertTrue( b.getScope().equals("runtime"), "Incorrect scope for " + b.getDependencyConflictId() ); - - // direct dep, overrides depMgmt - assertTrue( c.getScope().equals("runtime"), "Incorrect scope for " + c.getDependencyConflictId() ); - - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t11/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t11/ProjectInheritanceTest.java deleted file mode 100644 index 3f21d5e0adb4..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t11/ProjectInheritanceTest.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.apache.maven.project.inheritance.t11; - -/* - * 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.MavenProject; -import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; - -/** - * Verifies scope of root project is preserved regardless of parent dependency management. - * - * @author Patrick Schneider - * @see MNG-2919 - */ -public class ProjectInheritanceTest - extends AbstractProjectInheritanceTestCase -{ - // ---------------------------------------------------------------------- - // - // p1 inherits from p0 - // p0 inherits from super model - // - // or we can show it graphically as: - // - // p1 ---> p0 --> super model - // - // ---------------------------------------------------------------------- - - @Test - public void testDependencyManagementDoesNotOverrideScopeOfCurrentArtifact() - throws Exception - { - File localRepo = getLocalRepositoryPath(); - - File pom0 = new File( localRepo, "p0/pom.xml" ); - File pom0Basedir = pom0.getParentFile(); - File pom1 = new File( pom0Basedir, "p1/pom.xml" ); - - // load the child project, which inherits from p0... - MavenProject project0 = getProjectWithDependencies( pom0 ); - MavenProject project1 = getProjectWithDependencies( pom1 ); - - assertEquals( pom0Basedir, project1.getParent().getBasedir() ); - assertNull( project1.getArtifact().getScope(), - "dependencyManagement has overwritten the scope of the currently building child project" ); - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12/ProjectInheritanceTest.java deleted file mode 100644 index 086d710eb272..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12/ProjectInheritanceTest.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.apache.maven.project.inheritance.t12; - -/* - * 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.maven.model.Plugin; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; - -/** - * Verifies that plugin execution sections in the parent POM that have - * inherit == false are not inherited to the child POM. - */ -public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase -{ - // ---------------------------------------------------------------------- - // - // p1 inherits from p0 - // p0 inherits from super model - // - // or we can show it graphically as: - // - // p1 ---> p0 --> super model - // - // ---------------------------------------------------------------------- - - @Test - public void testFalsePluginExecutionInheritValue() throws Exception - { - File localRepo = getLocalRepositoryPath(); - - File pom0 = new File( localRepo, "p0/pom.xml" ); - File pom0Basedir = pom0.getParentFile(); - File pom1 = new File( pom0Basedir, "p1/pom.xml" ); - - getProjectWithDependencies( pom0 ); - MavenProject project1 = getProjectWithDependencies( pom1 ); - - Map pluginMap = project1.getBuild().getPluginsAsMap(); - Plugin compilerPlugin = (Plugin) pluginMap.get( "org.apache.maven.plugins:maven-compiler-plugin" ); - - assertNotNull( compilerPlugin ); - - Map executionMap = compilerPlugin.getExecutionsAsMap(); - assertNull( executionMap.get( "test" ), "Plugin execution: \'test\' should NOT exist in the compiler plugin specification for the child project!" ); - } -} \ No newline at end of file diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12scm/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12scm/ProjectInheritanceTest.java deleted file mode 100644 index 82aee6c70f69..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12scm/ProjectInheritanceTest.java +++ /dev/null @@ -1,130 +0,0 @@ -package org.apache.maven.project.inheritance.t12scm; - -/* - * 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.MavenProject; -import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Verifies SCM inheritance uses modules statement from parent. - * - * @author jdcasey - */ -public class ProjectInheritanceTest - extends AbstractProjectInheritanceTestCase -{ - // ---------------------------------------------------------------------- - // - // p1 inherits from p0 - // p0 inherits from super model - // - // or we can show it graphically as: - // - // p1 ---> p0 --> super model - // - // ---------------------------------------------------------------------- - - @Test - public void testScmInfoCalculatedCorrectlyOnParentAndChildRead() - throws Exception - { - File localRepo = getLocalRepositoryPath(); - - File pom0 = new File( localRepo, "p0/pom.xml" ); - File pom0Basedir = pom0.getParentFile(); - File pom1 = new File( pom0Basedir, "modules/p1/pom.xml" ); - - // load the child project, which inherits from p0... - MavenProject project0 = getProject( pom0 ); - MavenProject project1 = getProject( pom1 ); - - System.out.println( "\n\n" ); - System.out.println( "Parent SCM URL is: " + project0.getScm().getUrl() ); - System.out.println( "Child SCM URL is: " + project1.getScm().getUrl() ); - System.out.println(); - System.out.println( "Parent SCM connection is: " + project0.getScm().getConnection() ); - System.out.println( "Child SCM connection is: " + project1.getScm().getConnection() ); - System.out.println(); - System.out.println( "Parent SCM developer connection is: " - + project0.getScm().getDeveloperConnection() ); - System.out.println( "Child SCM developer connection is: " - + project1.getScm().getDeveloperConnection() ); - - assertEquals( project1.getScm().getUrl(), project0.getScm().getUrl() + "/modules/p1" ); - assertEquals( project1.getScm().getConnection(), project0.getScm().getConnection() - + "/modules/p1" ); - assertEquals( project1.getScm().getDeveloperConnection(), project0.getScm() - .getDeveloperConnection() - + "/modules/p1" ); - } - - @Test - public void testScmInfoCalculatedCorrectlyOnChildOnlyRead() - throws Exception - { - File localRepo = getLocalRepositoryPath(); - - File pom1 = new File( localRepo, "p0/modules/p1/pom.xml" ); - - // load the child project, which inherits from p0... - MavenProject project1 = getProject( pom1 ); - - System.out.println( "\n\n" ); - System.out.println( "Child SCM URL is: " + project1.getScm().getUrl() ); - System.out.println( "Child SCM connection is: " + project1.getScm().getConnection() ); - System.out.println( "Child SCM developer connection is: " - + project1.getScm().getDeveloperConnection() ); - - assertEquals( "http://host/viewer?path=/p0/modules/p1", project1.getScm().getUrl() ); - assertEquals( "scm:svn:http://host/p0/modules/p1", project1.getScm().getConnection() ); - assertEquals( "scm:svn:https://host/p0/modules/p1", project1.getScm().getDeveloperConnection() ); - } - -// public void testScmInfoCalculatedCorrectlyOnChildReadFromLocalRepository() -// throws Exception -// { -// File localRepo = getLocalRepositoryPath(); -// -// ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.class ); -// Artifact artifact = factory.createProjectArtifact( "maven", "p1", "1.0" ); -// -// ArtifactRepositoryFactory repoFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.class ); -// ArtifactRepository localArtifactRepo = repoFactory.createLocalRepository( localRepo ); -// -// MavenProject project1 = getProjectBuilder().buildFromRepository( artifact, Collections.EMPTY_LIST, localArtifactRepo ); -// -// System.out.println( "\n\n" ); -// System.out.println( "Child SCM URL is: " + project1.getScm().getUrl() ); -// System.out.println( "Child SCM connection is: " + project1.getScm().getConnection() ); -// System.out.println( "Child SCM developer connection is: " -// + project1.getScm().getDeveloperConnection() ); -// -// assertEquals( project1.getScm().getUrl(), "http://host/viewer?path=/p0/modules/p1" ); -// assertEquals( project1.getScm().getConnection(), "scm:svn:http://host/p0/modules/p1" ); -// assertEquals( project1.getScm().getDeveloperConnection(), -// "scm:svn:https://host/p0/modules/p1" ); -// } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/project/path/DefaultPathTranslatorTest.java b/maven-compat/src/test/java/org/apache/maven/project/path/DefaultPathTranslatorTest.java deleted file mode 100644 index 022ccd5592a2..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/project/path/DefaultPathTranslatorTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.apache.maven.project.path; - -/* - * 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.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -@SuppressWarnings( "deprecation" ) -public class DefaultPathTranslatorTest -{ - - @Test - public void testAlignToBasedirWhereBasedirExpressionIsTheCompleteValue() - { - File basedir = new File( System.getProperty( "java.io.tmpdir" ), "test" ).getAbsoluteFile(); - - String aligned = new DefaultPathTranslator().alignToBaseDirectory( "${basedir}", basedir ); - - assertEquals( basedir.getAbsolutePath(), aligned ); - } - - @Test - public void testAlignToBasedirWhereBasedirExpressionIsTheValuePrefix() - { - File basedir = new File( System.getProperty( "java.io.tmpdir" ), "test" ).getAbsoluteFile(); - - String aligned = new DefaultPathTranslator().alignToBaseDirectory( "${basedir}/dir", basedir ); - - assertEquals( new File( basedir, "dir" ).getAbsolutePath(), aligned ); - } - - @Test - public void testUnalignToBasedirWherePathEqualsBasedir() - { - File basedir = new File( System.getProperty( "java.io.tmpdir" ), "test" ).getAbsoluteFile(); - - String unaligned = new DefaultPathTranslator().unalignFromBaseDirectory( basedir.getAbsolutePath(), basedir ); - - assertEquals( ".", unaligned ); - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/DefaultMirrorSelectorTest.java b/maven-compat/src/test/java/org/apache/maven/repository/DefaultMirrorSelectorTest.java deleted file mode 100644 index 97687e32070c..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/DefaultMirrorSelectorTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.apache.maven.repository; - -/* - * 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.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.DefaultArtifactRepository; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertFalse; - -public class DefaultMirrorSelectorTest -{ - @Test - public void testMirrorWithMirrorOfPatternContainingANegationIsNotSelected() - { - ArtifactRepository repository = new DefaultArtifactRepository( "snapshots.repo", "http://whatever", null ); - String pattern = "external:*, !snapshots.repo"; - assertFalse( DefaultMirrorSelector.matchPattern( repository, pattern ) ); - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java b/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java deleted file mode 100644 index f68a9961fb80..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java +++ /dev/null @@ -1,192 +0,0 @@ -package org.apache.maven.repository; - -/* - * 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.List; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; -import org.apache.maven.artifact.resolver.ArtifactResolutionResult; -import org.apache.maven.artifact.resolver.ResolutionErrorHandler; -import org.apache.maven.execution.DefaultMavenExecutionRequest; -import org.apache.maven.execution.DefaultMavenExecutionResult; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.model.Dependency; -import org.apache.maven.model.Repository; -import org.apache.maven.model.RepositoryPolicy; -import org.apache.maven.plugin.LegacySupport; -import org.apache.maven.repository.legacy.LegacyRepositorySystem; -import org.codehaus.plexus.testing.PlexusTest; -import org.codehaus.plexus.PlexusContainer; -import org.eclipse.aether.DefaultRepositorySystemSession; -import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; -import org.eclipse.aether.repository.LocalRepository; -import org.junit.jupiter.api.Test; - -import static org.codehaus.plexus.testing.PlexusExtension.getBasedir; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import javax.inject.Inject; - -/** - * Tests {@link LegacyRepositorySystem}. - * - * @author Benjamin Bentmann - */ -@PlexusTest -public class LegacyRepositorySystemTest -{ - @Inject - private RepositorySystem repositorySystem; - @Inject - private ResolutionErrorHandler resolutionErrorHandler; - @Inject - private PlexusContainer container; - - protected List getRemoteRepositories() - throws Exception - { - File repoDir = new File( getBasedir(), "src/test/remote-repo" ).getAbsoluteFile(); - - RepositoryPolicy policy = new RepositoryPolicy(); - policy.setEnabled( true ); - policy.setChecksumPolicy( "ignore" ); - policy.setUpdatePolicy( "always" ); - - Repository repository = new Repository(); - repository.setId( RepositorySystem.DEFAULT_REMOTE_REPO_ID ); - repository.setUrl( "file://" + repoDir.toURI().getPath() ); - repository.setReleases( policy ); - repository.setSnapshots( policy ); - - return Arrays.asList( repositorySystem.buildArtifactRepository( repository ) ); - } - - protected ArtifactRepository getLocalRepository() - throws Exception - { - File repoDir = new File( getBasedir(), "target/local-repo" ).getAbsoluteFile(); - - return repositorySystem.createLocalRepository( repoDir ); - } - - @Test - public void testThatASystemScopedDependencyIsNotResolvedFromRepositories() - throws Exception - { - // - // We should get a whole slew of dependencies resolving this artifact transitively - // - Dependency d = new Dependency(); - d.setGroupId( "org.apache.maven.its" ); - d.setArtifactId( "b" ); - d.setVersion( "0.1" ); - d.setScope( Artifact.SCOPE_COMPILE ); - Artifact artifact = repositorySystem.createDependencyArtifact( d ); - - ArtifactResolutionRequest request = new ArtifactResolutionRequest() - .setArtifact( artifact ) - .setResolveRoot( true ) - .setResolveTransitively( true ) - .setRemoteRepositories( getRemoteRepositories() ) - .setLocalRepository( getLocalRepository() ); - - DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(); - LocalRepository localRepo = new LocalRepository( request.getLocalRepository().getBasedir() ); - session.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( session, localRepo ) ); - LegacySupport legacySupport = container.lookup( LegacySupport.class ); - legacySupport.setSession( new MavenSession( container, session, new DefaultMavenExecutionRequest(), - new DefaultMavenExecutionResult() ) ); - - ArtifactResolutionResult result = repositorySystem.resolve( request ); - resolutionErrorHandler.throwErrors( request, result ); - assertEquals( 2, result.getArtifacts().size() ); - - // - // System scoped version which should - // - d.setScope( Artifact.SCOPE_SYSTEM ); - File file = new File( getBasedir(), "src/test/repository-system/maven-core-2.1.0.jar" ); - assertTrue( file.exists() ); - d.setSystemPath( file.getCanonicalPath() ); - - artifact = repositorySystem.createDependencyArtifact( d ); - - // - // The request has not set any local or remote repositories as the system scoped dependency being resolved should only - // give us the dependency off the disk and nothing more. - // - request = new ArtifactResolutionRequest() - .setArtifact( artifact ) - .setResolveRoot( true ) - .setResolveTransitively( true ); - - result = repositorySystem.resolve( request ); - resolutionErrorHandler.throwErrors( request, result ); - assertEquals( 1, result.getArtifacts().size() ); - - // - // Put in a bogus file to make sure missing files cause the resolution to fail. - // - file = new File( getBasedir(), "src/test/repository-system/maven-monkey-2.1.0.jar" ); - assertFalse( file.exists() ); - d.setSystemPath( file.getCanonicalPath() ); - artifact = repositorySystem.createDependencyArtifact( d ); - - // - // The request has not set any local or remote repositories as the system scoped dependency being resolved should only - // give us the dependency off the disk and nothing more. - // - request = new ArtifactResolutionRequest() - .setArtifact( artifact ) - .setResolveRoot( true ) - .setResolveTransitively( true ); - - try - { - result = repositorySystem.resolve( request ); - resolutionErrorHandler.throwErrors( request, result ); - } - catch( Exception e ) - { - assertTrue( result.hasMissingArtifacts() ); - } - } - - @Test - public void testLocalRepositoryBasedir() - throws Exception - { - File localRepoDir = new File( "" ).getAbsoluteFile(); - - ArtifactRepository localRepo = repositorySystem.createLocalRepository( localRepoDir ); - - String basedir = localRepo.getBasedir(); - - assertFalse( basedir.endsWith( "/" ) ); - assertFalse( basedir.endsWith( "\\" ) ); - - assertEquals( localRepoDir, new File( basedir ) ); - - assertEquals( localRepoDir.getPath(), basedir ); - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java b/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java deleted file mode 100644 index 9e8ab4e27192..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java +++ /dev/null @@ -1,261 +0,0 @@ -package org.apache.maven.repository; - -/* - * 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.codehaus.plexus.testing.PlexusTest; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; -import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory; -import org.apache.maven.settings.Mirror; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertSame; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import javax.inject.Inject; - -@PlexusTest -public class MirrorProcessorTest -{ - @Inject - private DefaultMirrorSelector mirrorSelector; - - @Inject - private ArtifactRepositoryFactory repositorySystem; - - @Test - public void testExternalURL() - { - assertTrue( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://somehost" ) ) ); - assertTrue( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://somehost:9090/somepath" ) ) ); - assertTrue( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "ftp://somehost" ) ) ); - assertTrue( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://192.168.101.1" ) ) ); - assertTrue( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://" ) ) ); - // these are local - assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://localhost:8080" ) ) ); - assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://127.0.0.1:9090" ) ) ); - assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "file://localhost/somepath" ) ) ); - assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "file://localhost/D:/somepath" ) ) ); - assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://localhost" ) ) ); - assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://127.0.0.1" ) ) ); - assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "file:///somepath" ) ) ); - assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "file://D:/somepath" ) ) ); - - // not a proper url so returns false; - assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "192.168.101.1" ) ) ); - assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "" ) ) ); - } - - @Test - public void testMirrorLookup() - { - Mirror mirrorA = newMirror( "a", "a", "http://a" ); - Mirror mirrorB = newMirror( "b", "b", "http://b" ); - - List mirrors = Arrays.asList( mirrorA, mirrorB ); - - assertSame( mirrorA, mirrorSelector.getMirror( getRepo( "a", "http://a.a" ), mirrors ) ); - - assertSame( mirrorB, mirrorSelector.getMirror( getRepo( "b", "http://a.a" ), mirrors ) ); - - assertNull( mirrorSelector.getMirror( getRepo( "c", "http://c.c" ), mirrors ) ); - } - - @Test - public void testMirrorWildcardLookup() - { - Mirror mirrorA = newMirror( "a", "a", "http://a" ); - Mirror mirrorB = newMirror( "b", "b", "http://b" ); - Mirror mirrorC = newMirror( "c", "*", "http://wildcard" ); - - List mirrors = Arrays.asList( mirrorA, mirrorB, mirrorC ); - - assertSame( mirrorA, mirrorSelector.getMirror( getRepo( "a", "http://a.a" ), mirrors ) ); - - assertSame( mirrorB, mirrorSelector.getMirror( getRepo( "b", "http://a.a" ), mirrors ) ); - - assertSame( mirrorC, mirrorSelector.getMirror( getRepo( "c", "http://c.c" ), mirrors ) ); - } - - @Test - public void testMirrorStopOnFirstMatch() - { - // exact matches win first - Mirror mirrorA2 = newMirror( "a2", "a,b", "http://a2" ); - Mirror mirrorA = newMirror( "a", "a", "http://a" ); - // make sure repeated entries are skipped - Mirror mirrorA3 = newMirror( "a", "a", "http://a3" ); - - Mirror mirrorB = newMirror( "b", "b", "http://b" ); - Mirror mirrorC = newMirror( "c", "d,e", "http://de" ); - Mirror mirrorC2 = newMirror( "c", "*", "http://wildcard" ); - Mirror mirrorC3 = newMirror( "c", "e,f", "http://ef" ); - - List mirrors = Arrays.asList( mirrorA2, mirrorA, mirrorA3, mirrorB, mirrorC, mirrorC2, mirrorC3 ); - - assertSame( mirrorA, mirrorSelector.getMirror( getRepo( "a", "http://a.a" ), mirrors ) ); - - assertSame( mirrorB, mirrorSelector.getMirror( getRepo( "b", "http://a.a" ), mirrors ) ); - - assertSame( mirrorC2, mirrorSelector.getMirror( getRepo( "c", "http://c.c" ), mirrors ) ); - - assertSame( mirrorC, mirrorSelector.getMirror( getRepo( "d", "http://d" ), mirrors ) ); - - assertSame( mirrorC, mirrorSelector.getMirror( getRepo( "e", "http://e" ), mirrors ) ); - - assertSame( mirrorC2, mirrorSelector.getMirror( getRepo( "f", "http://f" ), mirrors ) ); - } - - @Test - public void testPatterns() - { - assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*" ) ); - assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*," ) ); - assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), ",*," ) ); - assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*," ) ); - - assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "a" ) ); - assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "a," ) ); - assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), ",a," ) ); - assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "a," ) ); - - assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "b" ), "a" ) ); - assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "b" ), "a," ) ); - assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "b" ), ",a" ) ); - assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "b" ), ",a," ) ); - - assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "a,b" ) ); - assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "b" ), "a,b" ) ); - - assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "c" ), "a,b" ) ); - - assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*" ) ); - assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*,b" ) ); - assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*,!b" ) ); - - assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*,!a" ) ); - assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "!a,*" ) ); - - assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "c" ), "*,!a" ) ); - assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "c" ), "!a,*" ) ); - - assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "c" ), "!a,!c" ) ); - assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "d" ), "!a,!c*" ) ); - } - - @Test - public void testPatternsWithExternal() - { - assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a", "http://localhost" ), "*" ) ); - assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "a", "http://localhost" ), "external:*" ) ); - - assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a", "http://localhost" ), "external:*,a" ) ); - assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "a", "http://localhost" ), "external:*,!a" ) ); - assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a", "http://localhost" ), "a,external:*" ) ); - assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "a", "http://localhost" ), "!a,external:*" ) ); - - assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "c", "http://localhost" ), "!a,external:*" ) ); - assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "c", "http://somehost" ), "!a,external:*" ) ); - } - - @Test - public void testLayoutPattern() - { - assertTrue( DefaultMirrorSelector.matchesLayout( "default", null ) ); - assertTrue( DefaultMirrorSelector.matchesLayout( "default", "" ) ); - assertTrue( DefaultMirrorSelector.matchesLayout( "default", "*" ) ); - - assertTrue( DefaultMirrorSelector.matchesLayout( "default", "default" ) ); - assertFalse( DefaultMirrorSelector.matchesLayout( "default", "legacy" ) ); - - assertTrue( DefaultMirrorSelector.matchesLayout( "default", "legacy,default" ) ); - assertTrue( DefaultMirrorSelector.matchesLayout( "default", "default,legacy" ) ); - - assertFalse( DefaultMirrorSelector.matchesLayout( "default", "legacy,!default" ) ); - assertFalse( DefaultMirrorSelector.matchesLayout( "default", "!default,legacy" ) ); - - assertFalse( DefaultMirrorSelector.matchesLayout( "default", "*,!default" ) ); - assertFalse( DefaultMirrorSelector.matchesLayout( "default", "!default,*" ) ); - } - - @Test - public void testMirrorLayoutConsideredForMatching() - { - ArtifactRepository repo = getRepo( "a" ); - - Mirror mirrorA = newMirror( "a", "a", null, "http://a" ); - Mirror mirrorB = newMirror( "b", "a", "p2", "http://b" ); - - Mirror mirrorC = newMirror( "c", "*", null, "http://c" ); - Mirror mirrorD = newMirror( "d", "*", "p2", "http://d" ); - - assertSame( mirrorA, mirrorSelector.getMirror( repo, Arrays.asList( mirrorA ) ) ); - assertNull( mirrorSelector.getMirror( repo, Arrays.asList( mirrorB ) ) ); - - assertSame( mirrorC, mirrorSelector.getMirror( repo, Arrays.asList( mirrorC ) ) ); - assertNull( mirrorSelector.getMirror( repo, Arrays.asList( mirrorD ) ) ); - } - - /** - * Build an ArtifactRepository object. - * - * @param id - * @param url - * @return - */ - private ArtifactRepository getRepo( String id, String url ) - { - return repositorySystem.createArtifactRepository( id, url, new DefaultRepositoryLayout(), null, null ); - } - - /** - * Build an ArtifactRepository object. - * - * @param id - * @return - */ - private ArtifactRepository getRepo( String id ) - { - return getRepo( id, "http://something" ); - } - - private Mirror newMirror( String id, String mirrorOf, String url ) - { - return newMirror( id, mirrorOf, null, url ); - } - - private Mirror newMirror( String id, String mirrorOf, String layouts, String url ) - { - Mirror mirror = new Mirror(); - - mirror.setId( id ); - mirror.setMirrorOf( mirrorOf ); - mirror.setMirrorOfLayouts( layouts ); - mirror.setUrl( url ); - - return mirror; - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManagerTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManagerTest.java deleted file mode 100644 index e8265051242f..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManagerTest.java +++ /dev/null @@ -1,258 +0,0 @@ -package org.apache.maven.repository.legacy; - -/* - * 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 javax.inject.Inject; - -import org.apache.maven.artifact.AbstractArtifactComponentTestCase; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; -import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.logging.console.ConsoleLogger; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class DefaultUpdateCheckManagerTest - extends AbstractArtifactComponentTestCase -{ - - @Inject - private ArtifactFactory artifactFactory; - - DefaultUpdateCheckManager updateCheckManager; - - @Override - protected String component() - { - return "updateCheckManager"; - } - - @BeforeEach - @Override - public void setUp() - throws Exception - { - super.setUp(); - - updateCheckManager = new DefaultUpdateCheckManager( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ) ); - } - - @Test - public void testArtifact() throws Exception - { - ArtifactRepository remoteRepository = remoteRepository(); - - ArtifactRepository localRepository = localRepository(); - - Artifact a = createArtifact( "a", "0.0.1-SNAPSHOT" ); - File file = new File( localRepository.getBasedir(), - localRepository.pathOf( a ) ); - file.delete(); - a.setFile( file ); - - File touchFile = updateCheckManager.getTouchfile( a ); - touchFile.delete(); - - assertTrue( updateCheckManager.isUpdateRequired( a, remoteRepository ) ); - - file.getParentFile().mkdirs(); - file.createNewFile(); - updateCheckManager.touch( a, remoteRepository, null ); - - assertFalse( updateCheckManager.isUpdateRequired( a, remoteRepository ) ); - - assertNull( updateCheckManager.readLastUpdated( touchFile, - updateCheckManager.getRepositoryKey( remoteRepository ) ) ); - - assertFalse( updateCheckManager.getTouchfile( a ).exists() ); - } - - @Test - public void testMissingArtifact() - throws Exception - { - ArtifactRepository remoteRepository = remoteRepository(); - - ArtifactRepository localRepository = localRepository(); - - Artifact a = createArtifact( "a", "0.0.1-SNAPSHOT" ); - File file = new File( localRepository.getBasedir(), - localRepository.pathOf( a ) ); - file.delete(); - a.setFile( file ); - - File touchFile = updateCheckManager.getTouchfile( a ); - touchFile.delete(); - - assertTrue( updateCheckManager.isUpdateRequired( a, remoteRepository ) ); - - updateCheckManager.touch( a, remoteRepository, null ); - - assertFalse( updateCheckManager.isUpdateRequired( a, remoteRepository ) ); - - assertFalse( file.exists() ); - assertNotNull( updateCheckManager.readLastUpdated( touchFile, - updateCheckManager.getRepositoryKey( remoteRepository ) ) ); - } - - @Test - public void testPom() throws Exception - { - ArtifactRepository remoteRepository = remoteRepository(); - - ArtifactRepository localRepository = localRepository(); - - Artifact a = createArtifact( "a", "0.0.1", "pom" ); - File file = new File( localRepository.getBasedir(), - localRepository.pathOf( a ) ); - file.delete(); - a.setFile( file ); - - File touchFile = updateCheckManager.getTouchfile( a ); - touchFile.delete(); - - assertTrue( updateCheckManager.isUpdateRequired( a, remoteRepository ) ); - - file.getParentFile().mkdirs(); - file.createNewFile(); - updateCheckManager.touch( a, remoteRepository, null ); - - assertFalse( updateCheckManager.isUpdateRequired( a, remoteRepository ) ); - - assertNull( updateCheckManager.readLastUpdated( touchFile, - updateCheckManager.getRepositoryKey( remoteRepository ) ) ); - - assertFalse( updateCheckManager.getTouchfile( a ).exists() ); - } - - @Test - public void testMissingPom() - throws Exception - { - ArtifactRepository remoteRepository = remoteRepository(); - - ArtifactRepository localRepository = localRepository(); - - Artifact a = createArtifact( "a", "0.0.1", "pom" ); - File file = new File( localRepository.getBasedir(), - localRepository.pathOf( a ) ); - file.delete(); - a.setFile( file ); - - File touchFile = updateCheckManager.getTouchfile( a ); - touchFile.delete(); - - assertTrue( updateCheckManager.isUpdateRequired( a, remoteRepository ) ); - - updateCheckManager.touch( a, remoteRepository, null ); - - assertFalse( updateCheckManager.isUpdateRequired( a, remoteRepository ) ); - - assertFalse( file.exists() ); - assertNotNull( updateCheckManager.readLastUpdated( touchFile, - updateCheckManager.getRepositoryKey( remoteRepository ) ) ); - } - - @Test - public void testMetadata() throws Exception - { - ArtifactRepository remoteRepository = remoteRepository(); - - ArtifactRepository localRepository = localRepository(); - - Artifact a = createRemoteArtifact( "a", "0.0.1-SNAPSHOT" ); - RepositoryMetadata metadata = new ArtifactRepositoryMetadata( a ); - - File file = new File( localRepository.getBasedir(), - localRepository.pathOfLocalRepositoryMetadata( metadata, localRepository ) ); - file.delete(); - - File touchFile = updateCheckManager.getTouchfile( metadata, file ); - touchFile.delete(); - - assertTrue( updateCheckManager.isUpdateRequired( metadata, remoteRepository, file ) ); - - file.getParentFile().mkdirs(); - file.createNewFile(); - updateCheckManager.touch( metadata, remoteRepository, file ); - - assertFalse( updateCheckManager.isUpdateRequired( metadata, remoteRepository, file ) ); - - assertNotNull( updateCheckManager.readLastUpdated( touchFile, updateCheckManager.getMetadataKey( remoteRepository, file ) ) ); - } - - @Test - public void testMissingMetadata() throws Exception - { - ArtifactRepository remoteRepository = remoteRepository(); - - ArtifactRepository localRepository = localRepository(); - - Artifact a = createRemoteArtifact( "a", "0.0.1-SNAPSHOT" ); - RepositoryMetadata metadata = new ArtifactRepositoryMetadata( a ); - - File file = new File( localRepository.getBasedir(), - localRepository.pathOfLocalRepositoryMetadata( metadata, localRepository ) ); - file.delete(); - - File touchFile = updateCheckManager.getTouchfile( metadata, file ); - touchFile.delete(); - - assertTrue( updateCheckManager.isUpdateRequired( metadata, remoteRepository, file ) ); - - updateCheckManager.touch( metadata, remoteRepository, file ); - - assertFalse( updateCheckManager.isUpdateRequired( metadata, remoteRepository, file ) ); - - assertNotNull( updateCheckManager.readLastUpdated( touchFile, updateCheckManager.getMetadataKey( remoteRepository, file ) ) ); - } - - @Test - public void testArtifactTouchFileName() throws Exception - { - ArtifactRepository localRepository = localRepository(); - - Artifact a = artifactFactory.createArtifactWithClassifier( "groupdId", "a", "0.0.1-SNAPSHOT", "jar", null ); - File file = new File( localRepository.getBasedir(), - localRepository.pathOf( a ) ); - a.setFile( file ); - - assertEquals( "a-0.0.1-SNAPSHOT.jar.lastUpdated", updateCheckManager.getTouchfile( a ).getName() ); - - a = artifactFactory.createArtifactWithClassifier( "groupdId", "a", "0.0.1-SNAPSHOT", "jar", "classifier" ); - file = new File( localRepository.getBasedir(), - localRepository.pathOf( a ) ); - a.setFile( file ); - - assertEquals( "a-0.0.1-SNAPSHOT-classifier.jar.lastUpdated", updateCheckManager.getTouchfile( a ).getName() ); - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java deleted file mode 100644 index 14961c10d2d8..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java +++ /dev/null @@ -1,363 +0,0 @@ -package org.apache.maven.repository.legacy; - -/* - * 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.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.metadata.ArtifactMetadata; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; -import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory; -import org.codehaus.plexus.testing.PlexusTest; -import org.apache.maven.wagon.ResourceDoesNotExistException; -import org.apache.maven.wagon.TransferFailedException; -import org.apache.maven.wagon.UnsupportedProtocolException; -import org.apache.maven.wagon.Wagon; -import org.apache.maven.wagon.events.TransferEvent; -import org.apache.maven.wagon.events.TransferListener; -import org.apache.maven.wagon.observers.AbstractTransferListener; -import org.apache.maven.wagon.observers.Debug; -import org.codehaus.plexus.util.FileUtils; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import static org.codehaus.plexus.testing.PlexusExtension.getTestFile; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNotSame; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import javax.inject.Inject; - -/** - * @author Michal Maczka - */ -@PlexusTest -public class DefaultWagonManagerTest -{ - @Inject - private WagonManager wagonManager; - - private final TransferListener transferListener = new Debug(); - - @Inject - private ArtifactFactory artifactFactory; - - @Inject - private ArtifactRepositoryFactory artifactRepositoryFactory; - - @Test - public void testUnnecessaryRepositoryLookup() - throws Exception - { - Artifact artifact = createTestPomArtifact( "target/test-data/get-missing-pom" ); - - List repos = new ArrayList<>(); - repos.add( artifactRepositoryFactory.createArtifactRepository( "repo1", "string://url1", - new ArtifactRepositoryLayoutStub(), null, null ) ); - repos.add( artifactRepositoryFactory.createArtifactRepository( "repo2", "string://url2", - new ArtifactRepositoryLayoutStub(), null, null ) ); - - StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" ); - wagon.addExpectedContent( repos.get( 0 ).getLayout().pathOf( artifact ), "expected" ); - wagon.addExpectedContent( repos.get( 0 ).getLayout().pathOf( artifact ) + ".md5", "cd26d9e10ce691cc69aa2b90dcebbdac" ); - wagon.addExpectedContent( repos.get( 1 ).getLayout().pathOf( artifact ), "expected" ); - wagon.addExpectedContent( repos.get( 1 ).getLayout().pathOf( artifact ) + ".md5", "cd26d9e10ce691cc69aa2b90dcebbdac" ); - - - class TransferListener - extends AbstractTransferListener - { - public List events = new ArrayList<>(); - - @Override - public void transferInitiated( TransferEvent transferEvent ) - { - events.add( transferEvent ); - } - } - - TransferListener listener = new TransferListener(); - wagonManager.getArtifact( artifact, repos, listener, false ); - assertEquals( 1, listener.events.size() ); - } - - @Test - public void testGetMissingJar() throws TransferFailedException, UnsupportedProtocolException, IOException - { - Artifact artifact = createTestArtifact( "target/test-data/get-missing-jar", "jar" ); - - ArtifactRepository repo = createStringRepo(); - - assertThrows( ResourceDoesNotExistException.class, - () -> wagonManager.getArtifact( artifact, repo, null, false ) ); - - assertFalse( artifact.getFile().exists() ); - } - - @Test - public void testGetMissingJarForced() throws TransferFailedException, UnsupportedProtocolException, IOException - { - Artifact artifact = createTestArtifact( "target/test-data/get-missing-jar", "jar" ); - - ArtifactRepository repo = createStringRepo(); - - assertThrows( ResourceDoesNotExistException.class, - () -> wagonManager.getArtifact( artifact, repo, null, true ) ); - - assertFalse( artifact.getFile().exists() ); - } - - @Test - public void testGetRemoteJar() - throws TransferFailedException, ResourceDoesNotExistException, UnsupportedProtocolException, IOException - { - Artifact artifact = createTestArtifact( "target/test-data/get-remote-jar", "jar" ); - - ArtifactRepository repo = createStringRepo(); - - StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" ); - wagon.addExpectedContent( repo.getLayout().pathOf( artifact ), "expected" ); - wagon.addExpectedContent( repo.getLayout().pathOf( artifact ) + ".md5", "cd26d9e10ce691cc69aa2b90dcebbdac" ); - - wagonManager.getArtifact( artifact, repo, null, false ); - - assertTrue( artifact.getFile().exists() ); - assertEquals( "expected", FileUtils.fileRead( artifact.getFile(), "UTF-8" ) ); - } - - private Artifact createTestPomArtifact( String directory ) - throws IOException - { - File testData = getTestFile( directory ); - FileUtils.deleteDirectory( testData ); - testData.mkdirs(); - - Artifact artifact = artifactFactory.createProjectArtifact( "test", "test", "1.0" ); - artifact.setFile( new File( testData, "test-1.0.pom" ) ); - assertFalse( artifact.getFile().exists() ); - return artifact; - } - - private Artifact createTestArtifact( String directory, String type ) - throws IOException - { - return createTestArtifact( directory, "1.0", type ); - } - - private Artifact createTestArtifact( String directory, String version, String type ) - throws IOException - { - File testData = getTestFile( directory ); - FileUtils.deleteDirectory( testData ); - testData.mkdirs(); - - Artifact artifact = artifactFactory.createBuildArtifact( "test", "test", version, type ); - artifact.setFile( new File( testData, "test-" + version + "." + artifact.getArtifactHandler().getExtension() ) ); - assertFalse( artifact.getFile().exists() ); - return artifact; - } - - private ArtifactRepository createStringRepo() - { - return artifactRepositoryFactory.createArtifactRepository( "id", "string://url", new ArtifactRepositoryLayoutStub(), null, null ); - } - - /** - * Build an ArtifactRepository object. - * - * @param id - * @param url - * @return - */ - private ArtifactRepository getRepo( String id, String url ) - { - return artifactRepositoryFactory.createArtifactRepository( id, url, new DefaultRepositoryLayout(), null, null ); - } - - /** - * Build an ArtifactRepository object. - * - * @param id - * @return - */ - private ArtifactRepository getRepo( String id ) - { - return getRepo( id, "http://something" ); - } - - @Test - public void testDefaultWagonManager() - throws Exception - { - assertWagon( "a" ); - - assertWagon( "b" ); - - assertWagon( "c" ); - - assertWagon( "string" ); - - assertThrows( UnsupportedProtocolException.class, () -> assertWagon( "d" ) ); - } - - /** - * Check that transfer listeners are properly removed after getArtifact and putArtifact - */ - @Test - public void testWagonTransferListenerRemovedAfterGetArtifactAndPutArtifact() - throws Exception - { - Artifact artifact = createTestArtifact( "target/test-data/transfer-listener", "jar" ); - ArtifactRepository repo = createStringRepo(); - StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" ); - wagon.addExpectedContent( repo.getLayout().pathOf( artifact ), "expected" ); - wagon.addExpectedContent( repo.getLayout().pathOf( artifact ) + ".md5", "cd26d9e10ce691cc69aa2b90dcebbdac" ); - - /* getArtifact */ - assertFalse( wagon.getTransferEventSupport().hasTransferListener( transferListener ), - "Transfer listener is registered before test" ); - wagonManager.getArtifact( artifact, repo, transferListener, false ); - assertFalse( wagon.getTransferEventSupport().hasTransferListener( transferListener ), - "Transfer listener still registered after getArtifact" ); - - /* putArtifact */ - File sampleFile = getTestFile( "target/test-file" ); - FileUtils.fileWrite( sampleFile.getAbsolutePath(), "sample file" ); - - assertFalse( wagon.getTransferEventSupport().hasTransferListener( transferListener ), - "Transfer listener is registered before test" ); - wagonManager.putArtifact( sampleFile, artifact, repo, transferListener ); - assertFalse( wagon.getTransferEventSupport().hasTransferListener( transferListener ), - "Transfer listener still registered after putArtifact" ); - } - - /** - * Checks the verification of checksums. - */ - @Disabled - @Test - public void testChecksumVerification() - throws Exception - { - ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL ); - - ArtifactRepository repo = artifactRepositoryFactory.createArtifactRepository( "id", "string://url", new ArtifactRepositoryLayoutStub(), policy, policy ); - - Artifact artifact = - new DefaultArtifact( "sample.group", "sample-art", VersionRange.createFromVersion( "1.0" ), "scope", - "jar", "classifier", null ); - artifact.setFile( getTestFile( "target/sample-art" ) ); - - StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" ); - - wagon.clearExpectedContent(); - wagon.addExpectedContent( "path", "lower-case-checksum" ); - wagon.addExpectedContent( "path.sha1", "2a25dc564a3b34f68237fc849066cbc7bb7a36a1" ); - wagonManager.getArtifact( artifact, repo, null, false ); - - wagon.clearExpectedContent(); - wagon.addExpectedContent( "path", "upper-case-checksum" ); - wagon.addExpectedContent( "path.sha1", "B7BB97D7D0B9244398D9B47296907F73313663E6" ); - wagonManager.getArtifact( artifact, repo, null, false ); - - wagon.clearExpectedContent(); - wagon.addExpectedContent( "path", "expected-failure" ); - wagon.addExpectedContent( "path.sha1", "b7bb97d7d0b9244398d9b47296907f73313663e6" ); - assertThrows( - ChecksumFailedException.class, () -> - wagonManager.getArtifact( artifact, repo, null, false ), - "Checksum verification did not fail" ); - - wagon.clearExpectedContent(); - wagon.addExpectedContent( "path", "lower-case-checksum" ); - wagon.addExpectedContent( "path.md5", "50b2cf50a103a965efac62b983035cac" ); - wagonManager.getArtifact( artifact, repo, null, false ); - - wagon.clearExpectedContent(); - wagon.addExpectedContent( "path", "upper-case-checksum" ); - wagon.addExpectedContent( "path.md5", "842F568FCCFEB7E534DC72133D42FFDC" ); - wagonManager.getArtifact( artifact, repo, null, false ); - - wagon.clearExpectedContent(); - wagon.addExpectedContent( "path", "expected-failure" ); - wagon.addExpectedContent( "path.md5", "b7bb97d7d0b9244398d9b47296907f73313663e6" ); - assertThrows( - ChecksumFailedException.class, - () -> wagonManager.getArtifact( artifact, repo, null, false ), - "Checksum verification did not fail" ); - } - - @Test - public void testPerLookupInstantiation() - throws Exception - { - String protocol = "perlookup"; - - Wagon one = wagonManager.getWagon( protocol ); - Wagon two = wagonManager.getWagon( protocol ); - - assertNotSame( one, two ); - } - - private void assertWagon( String protocol ) - throws Exception - { - Wagon wagon = wagonManager.getWagon( protocol ); - - assertNotNull( wagon, "Check wagon, protocol=" + protocol ); - } - - private final class ArtifactRepositoryLayoutStub - implements ArtifactRepositoryLayout - { - public String getId() - { - return "test"; - } - - public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata ) - { - return "path"; - } - - public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) - { - return "path"; - } - - public String pathOf( Artifact artifact ) - { - return "path"; - } - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java deleted file mode 100644 index ab9399504309..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.apache.maven.repository.legacy; - -/* - * 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 org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.Authentication; -import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.settings.Server; -import org.codehaus.plexus.testing.PlexusTest; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import javax.inject.Inject; - -/** - * Tests {@link LegacyRepositorySystem}. - * - * @author Benjamin Bentmann - */ -@PlexusTest -public class LegacyRepositorySystemTest -{ - @Inject - private RepositorySystem repositorySystem; - - @Test - public void testThatLocalRepositoryWithSpacesIsProperlyHandled() - throws Exception - { - File basedir = new File( "target/spacy path" ).getAbsoluteFile(); - ArtifactRepository repo = repositorySystem.createLocalRepository( basedir ); - assertEquals( basedir, new File( repo.getBasedir() ) ); - } - - @Test - public void testAuthenticationHandling() - { - Server server = new Server(); - server.setId( "repository" ); - server.setUsername( "jason" ); - server.setPassword( "abc123" ); - - ArtifactRepository repository = - repositorySystem.createArtifactRepository( "repository", "http://foo", null, null, null ); - repositorySystem.injectAuthentication( Arrays.asList( repository ), Arrays.asList( server ) ); - Authentication authentication = repository.getAuthentication(); - assertNotNull( authentication ); - assertEquals( "jason", authentication.getUsername() ); - assertEquals( "abc123", authentication.getPassword() ); - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/PerLookupWagon.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/PerLookupWagon.java deleted file mode 100644 index edf43aad9081..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/PerLookupWagon.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.maven.repository.legacy; - -/* - * 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.wagon.Wagon; - -import javax.inject.Named; -import javax.inject.Singleton; - -/** - * Wagon with per-lookup instantiation strategy. - */ -@Named( "perlookup" ) -public class PerLookupWagon - extends WagonMock -{ - - public String[] getSupportedProtocols() - { - return new String[] { "perlookup" }; - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java deleted file mode 100644 index 00be1626dc50..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.apache.maven.repository.legacy; - -/* - * 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.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Map; - -import org.apache.maven.wagon.ConnectionException; -import org.apache.maven.wagon.InputData; -import org.apache.maven.wagon.OutputData; -import org.apache.maven.wagon.ResourceDoesNotExistException; -import org.apache.maven.wagon.StreamWagon; -import org.apache.maven.wagon.TransferFailedException; -import org.apache.maven.wagon.authentication.AuthenticationException; -import org.apache.maven.wagon.authorization.AuthorizationException; -import org.apache.maven.wagon.resource.Resource; - -import javax.inject.Named; -import javax.inject.Singleton; - -@Named( "string" ) -@Singleton -public class StringWagon - extends StreamWagon -{ - private Map expectedContent = new HashMap<>(); - - public void addExpectedContent( String resourceName, String expectedContent ) - { - this.expectedContent.put( resourceName, expectedContent ); - } - - public String[] getSupportedProtocols() - { - return new String[] { "string" }; - } - - @Override - public void closeConnection() - throws ConnectionException - { - } - - @Override - public void fillInputData( InputData inputData ) - throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException - { - Resource resource = inputData.getResource(); - - String content = expectedContent.get( resource.getName() ); - - if ( content != null ) - { - resource.setContentLength( content.length() ); - resource.setLastModified( System.currentTimeMillis() ); - - inputData.setInputStream( new ByteArrayInputStream( content.getBytes( StandardCharsets.UTF_8 ) ) ); - } - else - { - throw new ResourceDoesNotExistException( "No content provided for " + resource.getName() ); - } - } - - @Override - public void fillOutputData( OutputData outputData ) - throws TransferFailedException - { - outputData.setOutputStream( new ByteArrayOutputStream() ); - } - - @Override - protected void openConnectionInternal() - throws ConnectionException, AuthenticationException - { - } - - public void clearExpectedContent() - { - expectedContent.clear(); - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonA.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonA.java deleted file mode 100644 index dbab864767e5..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonA.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.apache.maven.repository.legacy; -/* - * 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 javax.inject.Named; -import javax.inject.Singleton; - -/** - * Wagon for testing, for protocol a - * - * @author Carlos Sanchez - * @author Jason van Zyl - */ -@Named( "a" ) -@Singleton -public class WagonA - extends WagonMock -{ - public String[] getSupportedProtocols() - { - return new String[]{ "a" }; - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonB.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonB.java deleted file mode 100644 index c08381113c06..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonB.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.maven.repository.legacy; - -/* - * 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 javax.inject.Named; -import javax.inject.Singleton; - -/** - * Wagon for testing, for protocols b1 and b2 - * - * @author Carlos Sanchez - * @author Jason van Zyl - */ -@Named( "b" ) -@Singleton -public class WagonB - extends WagonMock -{ - public String[] getSupportedProtocols() - { - return new String[]{ "b1", "b2" }; - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonC.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonC.java deleted file mode 100644 index 29aa1de0164f..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonC.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.maven.repository.legacy; - -/* - * 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 javax.inject.Named; -import javax.inject.Singleton; - -/** - * Wagon for testing, for protocol c - * - * @author Carlos Sanchez - * @author Jason van Zyl - */ -@Named( "c" ) -@Singleton -public class WagonC - extends WagonMock -{ - public String[] getSupportedProtocols() - { - return new String[]{ "c" }; - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonMock.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonMock.java deleted file mode 100644 index c5163609b015..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonMock.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.apache.maven.repository.legacy; - -/* - * 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.wagon.providers.file.FileWagon; - -/** - * Mock of a Wagon for testing - * - * @author Carlos Sanchez - */ -public class WagonMock - extends FileWagon -{ - - /** - * A field that can be configured in the Wagon - * - * @component.configuration default="configurableField" - */ - private String configurableField = null; - - public void setConfigurableField( String configurableField ) - { - this.configurableField = configurableField; - } - - public String getConfigurableField() - { - return configurableField; - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java deleted file mode 100644 index 56018d39b2f3..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java +++ /dev/null @@ -1,992 +0,0 @@ -package org.apache.maven.repository.legacy.resolver; - -/* - * 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.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.inject.Inject; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.metadata.ResolutionGroup; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.apache.maven.artifact.resolver.ArtifactResolutionResult; -import org.apache.maven.artifact.resolver.CyclicDependencyException; -import org.apache.maven.artifact.resolver.filter.ArtifactFilter; -import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter; -import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.artifact.versioning.OverConstrainedVersionException; -import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; -import org.codehaus.plexus.testing.PlexusTest; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Test the default artifact collector. - * - * @author Brett Porter - */ -@PlexusTest -public class DefaultArtifactCollectorTest -{ - @Inject - private LegacyArtifactCollector artifactCollector; - - @Inject - private ArtifactFactory artifactFactory; - - private ArtifactSpec projectArtifact; - - private Source source; - - private static final String GROUP_ID = "test"; - - @BeforeEach - public void setUp() - throws Exception - { - source = new Source(); - - projectArtifact = createArtifactSpec( "project", "1.0", null ); - } - - @Test - @Disabled("works, but we don't fail on cycles presently") - public void testCircularDependencyNotIncludingCurrentProject() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec b = a.addDependency( "b", "1.0" ); - b.addDependency( "a", "1.0" ); - assertThrows( - CyclicDependencyException.class, - () -> collect( a ), - "Should have failed on cyclic dependency not involving project" ); - } - - @Test - @Disabled("works, but we don't fail on cycles presently") - public void testCircularDependencyIncludingCurrentProject() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec b = a.addDependency( "b", "1.0" ); - b.addDependency( "project", "1.0" ); - assertThrows( - CyclicDependencyException.class, - () -> collect( a ), - "Should have failed on cyclic dependency not involving project" ); - } - - @Test - public void testResolveWithFilter() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec b = a.addDependency( "b", "1.0" ); - ArtifactSpec c = a.addDependency( "c", "3.0" ); - - b.addDependency( "c", "2.0" ); - ArtifactSpec d = b.addDependency( "d", "4.0" ); - - ArtifactResolutionResult res = collect( a ); - assertEquals( createSet( new Object[] { a.artifact, b.artifact, c.artifact, d.artifact } ), res.getArtifacts(), - "Check artifact list" ); - - ArtifactFilter filter = new ExclusionSetFilter( new String[] { "b" } ); - res = collect( a, filter ); - assertEquals( createSet( new Object[] { a.artifact, c.artifact } ), res.getArtifacts(), "Check artifact list" ); - } - - @Test - public void testResolveCorrectDependenciesWhenDifferentDependenciesOnNearest() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec b = a.addDependency( "b", "1.0" ); - ArtifactSpec c2 = b.addDependency( "c", "2.0" ); - c2.addDependency( "d", "1.0" ); - - ArtifactSpec e = createArtifactSpec( "e", "1.0" ); - ArtifactSpec c1 = e.addDependency( "c", "1.0" ); - ArtifactSpec f = c1.addDependency( "f", "1.0" ); - - ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, e.artifact } ) ); - assertEquals( createSet( new Object[] { a.artifact, b.artifact, e.artifact, c1.artifact, f.artifact } ), - res.getArtifacts(), "Check artifact list" ); - assertEquals( "1.0", getArtifact( "c", res.getArtifacts() ).getVersion(), "Check version" ); - } - - @Test - @Disabled - public void testResolveCorrectDependenciesWhenDifferentDependenciesOnNewest() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - // TODO use newest conflict resolver - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec b = a.addDependency( "b", "1.0" ); - ArtifactSpec c2 = b.addDependency( "c", "2.0" ); - ArtifactSpec d = c2.addDependency( "d", "1.0" ); - - ArtifactSpec e = createArtifactSpec( "e", "1.0" ); - ArtifactSpec c1 = e.addDependency( "c", "1.0" ); - c1.addDependency( "f", "1.0" ); - - ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, e.artifact } ) ); - assertEquals( createSet( new Object[] { a.artifact, b.artifact, e.artifact, c2.artifact, d.artifact } ), res.getArtifacts(), "Check artifact list" ); - assertEquals( "2.0", getArtifact( "c", res.getArtifacts() ).getVersion(), "Check version" ); - } - - @Test - @Disabled - public void testResolveCorrectDependenciesWhenDifferentDependenciesOnNewestVersionReplaced() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - // TODO use newest conflict resolver - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec b1 = a.addDependency( "b", "1.0" ); - ArtifactSpec c = a.addDependency( "c", "1.0" ); - ArtifactSpec d2 = b1.addDependency( "d", "2.0" ); - d2.addDependency( "h", "1.0" ); - ArtifactSpec d1 = c.addDependency( "d", "1.0" ); - ArtifactSpec b2 = c.addDependency( "b", "2.0" ); - ArtifactSpec e = b2.addDependency( "e", "1.0" ); - ArtifactSpec g = d1.addDependency( "g", "1.0" ); - - ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact } ) ); - Object[] artifacts = new Object[] { a.artifact, c.artifact, d1.artifact, b2.artifact, e.artifact, g.artifact }; - assertEquals( createSet( artifacts ), res.getArtifacts(), "Check artifact list" ); - assertEquals( "1.0", getArtifact( "d", res.getArtifacts() ).getVersion(), "Check version" ); - assertEquals( "2.0", getArtifact( "b", res.getArtifacts() ).getVersion(), "Check version" ); - } - - @Test - public void testResolveNearestNewestIsNearest() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec b = a.addDependency( "b", "1.0" ); - ArtifactSpec c = a.addDependency( "c", "3.0" ); - - b.addDependency( "c", "2.0" ); - - ArtifactResolutionResult res = collect( a ); - assertEquals( createSet( new Object[] { a.artifact, b.artifact, c.artifact } ), res.getArtifacts(), "Check artifact list" ); - assertEquals( "3.0", getArtifact( "c", res.getArtifacts() ).getVersion(), "Check version" ); - } - - @Test - public void testResolveNearestOldestIsNearest() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec b = a.addDependency( "b", "1.0" ); - ArtifactSpec c = a.addDependency( "c", "2.0" ); - - b.addDependency( "c", "3.0" ); - - ArtifactResolutionResult res = collect( a ); - assertEquals( createSet( new Object[] { a.artifact, b.artifact, c.artifact } ), res.getArtifacts(), "Check artifact list" ); - assertEquals( "2.0", getArtifact( "c", res.getArtifacts() ).getVersion(), "Check version" ); - } - - @Test - public void testResolveLocalNewestIsLocal() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - a.addDependency( "b", "2.0" ); - ArtifactSpec b = createArtifactSpec( "b", "3.0" ); - - ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) ); - assertEquals( createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts(), "Check artifact list" ); - assertEquals( "3.0", getArtifact( "b", res.getArtifacts() ).getVersion(), "Check version" ); - } - - @Test - public void testResolveLocalOldestIsLocal() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - a.addDependency( "b", "3.0" ); - ArtifactSpec b = createArtifactSpec( "b", "2.0" ); - - ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) ); - assertEquals( createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts(), "Check artifact list" ); - assertEquals( "2.0", getArtifact( "b", res.getArtifacts() ).getVersion(), "Check version" ); - } - - @Test - public void testResolveLocalWithNewerVersionButLesserScope() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "commons-logging", "1.0" ); - a.addDependency( "junit", "3.7" ); - ArtifactSpec b = createArtifactSpec( "junit", "3.8.1", Artifact.SCOPE_TEST ); - - ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) ); - assertEquals( createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts(), "Check artifact list" ); - assertEquals( "3.8.1", getArtifact( "junit", res.getArtifacts() ).getVersion(), "Check version" ); - assertEquals( Artifact.SCOPE_TEST, getArtifact( "junit", res.getArtifacts() ).getScope(), "Check artifactScope" ); - } - - @Test - public void testResolveLocalWithNewerVersionButLesserScopeResolvedFirst() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec b = createArtifactSpec( "junit", "3.8.1", Artifact.SCOPE_TEST ); - ArtifactSpec a = createArtifactSpec( "commons-logging", "1.0" ); - a.addDependency( "junit", "3.7" ); - - ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) ); - assertEquals( createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts(), "Check artifact list" ); - assertEquals( "3.8.1", getArtifact( "junit", res.getArtifacts() ).getVersion(), "Check version" ); - assertEquals( Artifact.SCOPE_TEST, getArtifact( "junit", res.getArtifacts() ).getScope(), "Check artifactScope" ); - } - - @Test - public void testResolveNearestWithRanges() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec b = a.addDependency( "b", "1.0" ); - ArtifactSpec c = a.addDependency( "c", "2.0" ); - - b.addDependency( "c", "[1.0,3.0]" ); - - ArtifactResolutionResult res = collect( a ); - assertEquals( createSet( new Object[] { a.artifact, b.artifact, c.artifact } ), res.getArtifacts(), "Check artifact list" ); - assertEquals( "2.0", getArtifact( "c", res.getArtifacts() ).getVersion(), "Check version" ); - } - - @Test - public void testResolveRangeWithManagedVersion() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec b = a.addDependency( "b", "[1.0,3.0]" ); - - ArtifactSpec managedB = createArtifactSpec( "b", "5.0" ); - - ArtifactResolutionResult res = collect( a, managedB.artifact ); - assertEquals( createSet( new Object[] { a.artifact, managedB.artifact } ), res.getArtifacts(), "Check artifact list" ); - assertEquals( "5.0", getArtifact( "b", res.getArtifacts() ).getVersion(), "Check version" ); - } - - @Test - public void testCompatibleRanges() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec b = a.addDependency( "b", "1.0" ); - a.addDependency( "c", "[2.0,2.5]" ); - b.addDependency( "c", "[1.0,3.0]" ); - ArtifactSpec c = createArtifactSpec( "c", "2.5" ); - - ArtifactResolutionResult res = collect( a ); - - assertEquals( createSet( new Object[] { a.artifact, b.artifact, c.artifact } ), res.getArtifacts(), "Check artifact list" ); - assertEquals( "2.5", getArtifact( "c", res.getArtifacts() ).getVersion(), "Check version" ); - } - - @Test - public void testIncompatibleRanges() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec b = a.addDependency( "b", "1.0" ); - a.addDependency( "c", "[2.4,3.0]" ); - - b.addDependency( "c", "[1.0,2.0]" ); - - ArtifactResolutionResult res = collect( a ); - - assertTrue( res.hasVersionRangeViolations() ); - } - - @Test - public void testUnboundedRangeWhenVersionUnavailable() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec b = a.addDependency( "b", "1.0" ); - a.addDependency( "c", "[2.0,]" ); - b.addDependency( "c", "[1.0,]" ); - - ArtifactResolutionResult res = collect( a ); - - assertTrue( res.hasVersionRangeViolations() ); - } - - @Test - public void testUnboundedRangeBelowLastRelease() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - createArtifactSpec( "c", "1.5" ); - ArtifactSpec c = createArtifactSpec( "c", "2.0" ); - createArtifactSpec( "c", "1.1" ); - a.addDependency( "c", "[1.0,)" ); - - ArtifactResolutionResult res = collect( a ); - - assertEquals( createSet( new Object[] { a.artifact, c.artifact } ), res.getArtifacts(), "Check artifact list" ); - assertEquals( "2.0", getArtifact( "c", res.getArtifacts() ).getVersion(), "Check version" ); - } - - @Test - public void testUnboundedRangeAboveLastRelease() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - createArtifactSpec( "c", "2.0" ); - a.addDependency( "c", "[10.0,)" ); - - ArtifactResolutionResult res = collect( a ); - - assertTrue( res.hasVersionRangeViolations() ); - } - - @Test - public void testResolveManagedVersion() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - a.addDependency( "b", "3.0", Artifact.SCOPE_RUNTIME ); - - Artifact managedVersion = createArtifactSpec( "b", "5.0" ).artifact; - Artifact modifiedB = createArtifactSpec( "b", "5.0", Artifact.SCOPE_RUNTIME ).artifact; - - ArtifactResolutionResult res = collect( a, managedVersion ); - assertEquals( createSet( new Object[] { a.artifact, modifiedB } ), res.getArtifacts(), "Check artifact list" ); - } - - @Test - public void testCollectChangesVersionOfOriginatingArtifactIfInDependencyManagementHasDifferentVersion() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - - Artifact artifact = projectArtifact.artifact; - Artifact managedVersion = createArtifactSpec( artifact.getArtifactId(), "2.0" ).artifact; - - ArtifactResolutionResult result = collect( a, managedVersion ); - - assertEquals( "1.0", artifact.getVersion(), "collect has modified version in originating artifact" ); - - Artifact resolvedArtifact = result.getArtifacts().iterator().next(); - - assertEquals( "1.0", resolvedArtifact.getVersion(), "Resolved version don't match original artifact version" ); - } - - @Test - public void testResolveCompileScopeOverTestScope() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec c = createArtifactSpec( "c", "3.0", Artifact.SCOPE_TEST ); - - a.addDependency( "c", "2.0", Artifact.SCOPE_COMPILE ); - - Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact; - - ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) ); - assertEquals( createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts(), "Check artifact list" ); - Artifact artifact = getArtifact( "c", res.getArtifacts() ); - // local wins now, and irrelevant if not local as test/provided aren't transitive - // assertEquals( Artifact.SCOPE_COMPILE, artifact.getArtifactScope(), "Check artifactScope" ); - assertEquals( Artifact.SCOPE_TEST, artifact.getScope(), "Check artifactScope" ); - } - - @Test - public void testResolveRuntimeScopeOverTestScope() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec c = createArtifactSpec( "c", "3.0", Artifact.SCOPE_TEST ); - - a.addDependency( "c", "2.0", Artifact.SCOPE_RUNTIME ); - - Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_RUNTIME ).artifact; - - ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) ); - assertEquals( createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts(), "Check artifact list" ); - Artifact artifact = getArtifact( "c", res.getArtifacts() ); - // local wins now, and irrelevant if not local as test/provided aren't transitive - // assertEquals( Artifact.SCOPE_RUNTIME, artifact.getArtifactScope(), "Check artifactScope" ); - assertEquals( Artifact.SCOPE_TEST, artifact.getScope(), "Check artifactScope" ); - } - - @Test - public void testResolveCompileScopeOverRuntimeScope() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec root = createArtifactSpec( "root", "1.0" ); - ArtifactSpec a = root.addDependency( "a", "1.0" ); - root.addDependency( "c", "3.0", Artifact.SCOPE_RUNTIME ); - - a.addDependency( "c", "2.0", Artifact.SCOPE_COMPILE ); - - Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact; - - ArtifactResolutionResult res = collect( createSet( new Object[] { root.artifact } ) ); - assertEquals( createSet( new Object[] { a.artifact, root.artifact, modifiedC } ), res.getArtifacts(), "Check artifact list" ); - Artifact artifact = getArtifact( "c", res.getArtifacts() ); - assertEquals( Artifact.SCOPE_COMPILE, artifact.getScope(), "Check artifactScope" ); - } - - @Test - public void testResolveCompileScopeOverProvidedScope() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec c = createArtifactSpec( "c", "3.0", Artifact.SCOPE_PROVIDED ); - - a.addDependency( "c", "2.0", Artifact.SCOPE_COMPILE ); - - Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact; - - ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) ); - assertEquals( createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts(), "Check artifact list" ); - Artifact artifact = getArtifact( "c", res.getArtifacts() ); - // local wins now, and irrelevant if not local as test/provided aren't transitive - // assertEquals( Artifact.SCOPE_COMPILE, artifact.getArtifactScope(), "Check artifactScope" ); - assertEquals( Artifact.SCOPE_PROVIDED, artifact.getScope(), "Check artifactScope" ); - } - - @Test - public void testResolveRuntimeScopeOverProvidedScope() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec c = createArtifactSpec( "c", "3.0", Artifact.SCOPE_PROVIDED ); - - a.addDependency( "c", "2.0", Artifact.SCOPE_RUNTIME ); - - Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_RUNTIME ).artifact; - - ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) ); - assertEquals( createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts(), "Check artifact list" ); - Artifact artifact = getArtifact( "c", res.getArtifacts() ); - // local wins now, and irrelevant if not local as test/provided aren't transitive - // assertEquals( Artifact.SCOPE_RUNTIME, artifact.getArtifactScope(), "Check artifactScope" ); - assertEquals( Artifact.SCOPE_PROVIDED, artifact.getScope(), "Check artifactScope" ); - } - - @Test - public void testProvidedScopeNotTransitive() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0", Artifact.SCOPE_PROVIDED ); - ArtifactSpec b = createArtifactSpec( "b", "1.0" ); - b.addDependency( "c", "3.0", Artifact.SCOPE_PROVIDED ); - - ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) ); - assertEquals( createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts(), "Check artifact list" ); - } - - @Test - public void testOptionalNotTransitive() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec b = createArtifactSpec( "b", "1.0" ); - b.addDependency( "c", "3.0", true ); - - ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) ); - assertEquals( createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts(), "Check artifact list" ); - } - - @Test - public void testOptionalIncludedAtRoot() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - - ArtifactSpec b = createArtifactSpec( "b", "1.0", true ); - - ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) ); - assertEquals( createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts(), "Check artifact list" ); - } - - @Test - public void testScopeUpdate() - throws InvalidVersionSpecificationException, ArtifactResolutionException - { - /* farthest = compile */ - checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE ); - checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_COMPILE ); - checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_COMPILE ); - checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_COMPILE ); - checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_TEST, Artifact.SCOPE_COMPILE ); - - /* farthest = provided */ - checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE ); - checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED ); - checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME ); - checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM ); - checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_TEST, Artifact.SCOPE_TEST ); - - /* farthest = runtime */ - checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE ); - checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_RUNTIME ); - checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME ); - checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM ); - checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_TEST, Artifact.SCOPE_RUNTIME ); - - /* farthest = system */ - checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE ); - checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED ); - checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME ); - checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM ); - checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_TEST, Artifact.SCOPE_TEST ); - - /* farthest = test */ - checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE ); - checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED ); - checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME ); - checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM ); - checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_TEST, Artifact.SCOPE_TEST ); - } - - private void checkScopeUpdate( String farthestScope, String nearestScope, String expectedScope ) - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - checkScopeUpdateDirect( farthestScope, nearestScope, expectedScope ); - checkScopeUpdateTransitively( farthestScope, nearestScope, expectedScope ); - } - - private void checkScopeUpdateTransitively( String farthestScope, String nearestScope, String expectedScope ) - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec b = createArtifactSpec( "b", "1.0", nearestScope ); - ArtifactSpec c = createArtifactSpec( "c", "1.0" ); - a.addDependency( c ); - ArtifactSpec dNearest = createArtifactSpec( "d", "2.0" ); - b.addDependency( dNearest ); - ArtifactSpec dFarthest = createArtifactSpec( "d", "3.0", farthestScope ); - c.addDependency( dFarthest ); - - /* system and provided dependencies are not transitive */ - if ( !Artifact.SCOPE_SYSTEM.equals( nearestScope ) && !Artifact.SCOPE_PROVIDED.equals( nearestScope ) ) - { - checkScopeUpdate( a, b, expectedScope, "2.0" ); - } - } - - private void checkScopeUpdateDirect( String farthestScope, String nearestScope, String expectedScope ) - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec b = createArtifactSpec( "b", "1.0" ); - ArtifactSpec c = createArtifactSpec( "c", "1.0" ); - a.addDependency( c ); - ArtifactSpec dNearest = createArtifactSpec( "d", "2.0", nearestScope ); - b.addDependency( dNearest ); - ArtifactSpec dFarthest = createArtifactSpec( "d", "3.0", farthestScope ); - c.addDependency( dFarthest ); - - checkScopeUpdate( a, b, expectedScope, "2.0" ); - } - - private void checkScopeUpdate( ArtifactSpec a, ArtifactSpec b, String expectedScope, String expectedVersion ) - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ScopeArtifactFilter filter; - if ( Artifact.SCOPE_PROVIDED.equals( expectedScope ) ) - { - filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE ); - } - else if ( Artifact.SCOPE_SYSTEM.equals( expectedScope ) ) - { - filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE ); - } - else - { - filter = new ScopeArtifactFilter( expectedScope ); - } - - ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ), filter ); - Artifact artifact = getArtifact( "d", res.getArtifacts() ); - assertNotNull( artifact, "MNG-1895 Dependency was not added to resolution" ); - assertEquals( expectedScope, artifact.getScope(), "Check artifactScope" ); - assertEquals( expectedVersion, artifact.getVersion(), "Check version" ); - - ArtifactSpec d = createArtifactSpec( "d", "1.0" ); - res = collect( createSet( new Object[] { a.artifact, b.artifact, d.artifact } ), filter ); - artifact = getArtifact( "d", res.getArtifacts() ); - assertNotNull( artifact, "MNG-1895 Dependency was not added to resolution" ); - assertEquals( d.artifact.getScope(), artifact.getScope(), "Check artifactScope" ); - assertEquals( "1.0", artifact.getVersion(), "Check version" ); - } - - @Test - @Disabled - public void testOptionalNotTransitiveButVersionIsInfluential() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - ArtifactSpec b = createArtifactSpec( "b", "1.0" ); - b.addDependency( "c", "3.0", true ); - ArtifactSpec d = a.addDependency( "d", "1.0" ); - ArtifactSpec e = d.addDependency( "e", "1.0" ); - e.addDependency( "c", "2.0" ); - - ArtifactSpec c = createArtifactSpec( "c", "3.0" ); - - ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) ); - assertEquals( createSet( new Object[] { a.artifact, b.artifact, c.artifact, d.artifact, e.artifact } ), res.getArtifacts(), "Check artifact list" ); - Artifact artifact = getArtifact( "c", res.getArtifacts() ); - assertEquals( "3.0", artifact.getVersion(), "Check version" ); - } - - @Test - public void testTestScopeNotTransitive() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0", Artifact.SCOPE_TEST ); - ArtifactSpec b = createArtifactSpec( "b", "1.0" ); - b.addDependency( "c", "3.0", Artifact.SCOPE_TEST ); - - ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) ); - assertEquals( createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts(), "Check artifact list" ); - } - - @Test - public void testSnapshotNotIncluded() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - a.addDependency( "b", "[1.0,)" ); - createArtifactSpec( "b", "1.0-SNAPSHOT" ); - - ArtifactResolutionResult res = collect( a ); - - assertTrue( res.hasVersionRangeViolations() ); - - /* - * try { ArtifactResolutionResult res = collect( a ); fail( "Expected b not to resolve: " + res ); } catch ( - * OverConstrainedVersionException e ) { assertTrue( e.getMessage().indexOf( "[1.0-SNAPSHOT]" ) < - * e.getMessage().indexOf( "[1.0,)" ) ); } - */ - } - - @Test - @Disabled("that one does not work") - public void testOverConstrainedVersionException() - throws ArtifactResolutionException, InvalidVersionSpecificationException - { - ArtifactSpec a = createArtifactSpec( "a", "1.0" ); - a.addDependency( "b", "[1.0, 2.0)" ); - a.addDependency( "c", "[3.3.0,4.0.0)" ); - - ArtifactSpec b = createArtifactSpec( "b", "1.0.0" ); - b.addDependency( "c", "3.3.0-v3346" ); - - ArtifactSpec c = createArtifactSpec( "c", "3.2.1-v3235e" ); - - OverConstrainedVersionException e = assertThrows( - OverConstrainedVersionException.class, - () -> collect( createSet( new Object[] { a.artifact } ) ) ); - assertTrue( e.getMessage().contains( "[3.2.1-v3235e, 3.3.0-v3346]" ), "Versions unordered" ); - assertTrue( e.getMessage().contains( "Path to dependency:" ), "DependencyTrail unresolved" ); - } - - private Artifact getArtifact( String id, Set artifacts ) - { - for ( Object artifact : artifacts ) - { - Artifact a = (Artifact) artifact; - if ( a.getArtifactId().equals( id ) && a.getGroupId().equals( GROUP_ID ) ) - { - return a; - } - } - return null; - } - - private ArtifactResolutionResult collect( Set artifacts ) - throws ArtifactResolutionException - { - return collect( artifacts, null ); - } - - private ArtifactResolutionResult collect( Set artifacts, ArtifactFilter filter ) - throws ArtifactResolutionException - { - return artifactCollector.collect( artifacts, projectArtifact.artifact, null, null, null, source, filter, - Collections.emptyList(), null ); - } - - private ArtifactResolutionResult collect( ArtifactSpec a ) - throws ArtifactResolutionException - { - return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, null, null, - null, source, null, Collections.emptyList(), null ); - } - - private ArtifactResolutionResult collect( ArtifactSpec a, ArtifactFilter filter ) - throws ArtifactResolutionException - { - return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, null, null, - null, source, filter, Collections.emptyList(), null ); - } - - private ArtifactResolutionResult collect( ArtifactSpec a, Artifact managedVersion ) - throws ArtifactResolutionException - { - Map managedVersions = Collections.singletonMap( managedVersion.getDependencyConflictId(), managedVersion ); - return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, - managedVersions, null, null, source, null, Collections.emptyList(), null ); - } - - private ArtifactSpec createArtifactSpec( String id, String version ) - throws InvalidVersionSpecificationException - { - return createArtifactSpec( id, version, Artifact.SCOPE_COMPILE ); - } - - private ArtifactSpec createArtifactSpec( String id, String version, boolean optional ) - throws InvalidVersionSpecificationException - { - return createArtifactSpec( id, version, Artifact.SCOPE_COMPILE, null, optional ); - } - - private ArtifactSpec createArtifactSpec( String id, String version, String scope ) - throws InvalidVersionSpecificationException - { - return createArtifactSpec( id, version, scope, null, false ); - } - - private ArtifactSpec createArtifactSpec( String id, String version, String scope, String inheritedScope, - boolean optional ) - throws InvalidVersionSpecificationException - { - VersionRange versionRange = VersionRange.createFromVersionSpec( version ); - Artifact artifact = - artifactFactory.createDependencyArtifact( GROUP_ID, id, versionRange, "jar", null, scope, inheritedScope, - optional ); - ArtifactSpec spec = null; - if ( artifact != null ) - { - spec = new ArtifactSpec(); - spec.artifact = artifact; - source.addArtifact( spec ); - } - return spec; - } - - @SuppressWarnings( "unchecked" ) - private static Set createSet( Object[] x ) - { - return new LinkedHashSet( Arrays.asList( x ) ); - } - - private class ArtifactSpec - { - private Artifact artifact; - - private Set dependencies = new HashSet<>(); - - public ArtifactSpec addDependency( String id, String version ) - throws InvalidVersionSpecificationException - { - return addDependency( id, version, Artifact.SCOPE_COMPILE ); - } - - public ArtifactSpec addDependency( String id, String version, String scope ) - throws InvalidVersionSpecificationException - { - return addDependency( id, version, scope, false ); - } - - private ArtifactSpec addDependency( ArtifactSpec dep ) - throws InvalidVersionSpecificationException - { - if ( dep != null ) - { - dependencies.add( dep.artifact ); - } - return dep; - } - - private ArtifactSpec addDependency( String id, String version, String scope, boolean optional ) - throws InvalidVersionSpecificationException - { - ArtifactSpec dep = createArtifactSpec( id, version, scope, artifact.getScope(), optional ); - return addDependency( dep ); - } - - public ArtifactSpec addDependency( String id, String version, boolean optional ) - throws InvalidVersionSpecificationException - { - return addDependency( id, version, Artifact.SCOPE_COMPILE, optional ); - } - } - - private class Source - implements ArtifactMetadataSource - { - private Map artifacts = new HashMap<>(); - - private Map> versions = new HashMap<>(); - - public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, - List remoteRepositories ) - throws ArtifactMetadataRetrievalException - { - String key = getKey( artifact ); - - ArtifactSpec a = (ArtifactSpec) artifacts.get( key ); - try - { - return new ResolutionGroup( artifact, createArtifacts( artifactFactory, a.dependencies, - artifact.getScope(), - artifact.getDependencyFilter() ), - Collections.emptyList() ); - } - catch ( InvalidVersionSpecificationException e ) - { - throw new ArtifactMetadataRetrievalException( "Invalid version creating artifacts", e, artifact ); - } - } - - private String getKey( Artifact artifact ) - { - return artifact.getDependencyConflictId(); - } - - private Set createArtifacts( ArtifactFactory artifactFactory, Set dependencies, String inheritedScope, - ArtifactFilter dependencyFilter ) - throws InvalidVersionSpecificationException - { - Set projectArtifacts = new HashSet<>(); - - for ( Artifact d : dependencies ) - { - VersionRange versionRange; - if ( d.getVersionRange() != null ) - { - versionRange = d.getVersionRange(); - } - else - { - versionRange = VersionRange.createFromVersionSpec( d.getVersion() ); - } - Artifact artifact; - if ( d.getScope().equals( Artifact.SCOPE_TEST ) || d.getScope().equals( Artifact.SCOPE_PROVIDED ) ) - { - /* don't call createDependencyArtifact as it'll ignore test and provided scopes */ - artifact = - artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(), d.getScope(), - d.getType() ); - } - else - { - artifact = - artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), versionRange, - d.getType(), d.getClassifier(), d.getScope(), - inheritedScope, d.isOptional() ); - } - - if ( artifact != null && ( dependencyFilter == null || dependencyFilter.include( artifact ) ) ) - { - artifact.setDependencyFilter( dependencyFilter ); - - projectArtifacts.add( artifact ); - } - } - - return projectArtifacts; - } - - public void addArtifact( ArtifactSpec spec ) - { - artifacts.put( getKey( spec.artifact ), spec ); - - String key = spec.artifact.getDependencyConflictId(); - List artifactVersions = versions.computeIfAbsent( key, k -> new ArrayList<>() ); - if ( spec.artifact.getVersion() != null ) - { - artifactVersions.add( new DefaultArtifactVersion( spec.artifact.getVersion() ) ); - } - } - - public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, - List remoteRepositories ) - throws ArtifactMetadataRetrievalException - { - return retrieveAvailableVersions( artifact ); - } - - public List retrieveAvailableVersionsFromDeploymentRepository( - Artifact artifact, - ArtifactRepository localRepository, - ArtifactRepository remoteRepository ) - throws ArtifactMetadataRetrievalException - { - return retrieveAvailableVersions( artifact ); - } - - private List retrieveAvailableVersions( Artifact artifact ) - { - List artifactVersions = versions.get( artifact.getDependencyConflictId() ); - if ( artifactVersions == null ) - { - artifactVersions = Collections.emptyList(); - } - return artifactVersions; - } - - public ResolutionGroup retrieve( MetadataResolutionRequest request ) - throws ArtifactMetadataRetrievalException - { - return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); - } - - public List retrieveAvailableVersions( MetadataResolutionRequest request ) - throws ArtifactMetadataRetrievalException - { - return retrieveAvailableVersions( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); - } - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java deleted file mode 100644 index 178933996eea..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java +++ /dev/null @@ -1,137 +0,0 @@ -package org.apache.maven.repository.legacy.resolver.conflict; - -/* - * 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 org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ResolutionNode; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.artifact.versioning.VersionRange; -import org.codehaus.plexus.testing.PlexusTest; -import org.codehaus.plexus.PlexusContainer; -import org.junit.jupiter.api.BeforeEach; - -import javax.inject.Inject; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -/** - * Provides a basis for testing conflict resolvers. - * - * @author Mark Hobson - */ -@PlexusTest -public abstract class AbstractConflictResolverTest -{ - // constants -------------------------------------------------------------- - - private static final String GROUP_ID = "test"; - - // fields ----------------------------------------------------------------- - - protected Artifact a1; - - protected Artifact a2; - - protected Artifact b1; - - private final String roleHint; - - @Inject - private ArtifactFactory artifactFactory; - - private ConflictResolver conflictResolver; - - @Inject - protected PlexusContainer container; - - // constructors ----------------------------------------------------------- - - public AbstractConflictResolverTest( String roleHint ) - throws Exception - { - this.roleHint = roleHint; - } - - // TestCase methods ------------------------------------------------------- - - /* - * @see junit.framework.TestCase#setUp() - */ - @BeforeEach - public void setUp() - throws Exception - { - conflictResolver = (ConflictResolver) container.lookup( ConflictResolver.ROLE, roleHint ); - - a1 = createArtifact( "a", "1.0" ); - a2 = createArtifact( "a", "2.0" ); - b1 = createArtifact( "b", "1.0" ); - } - - // protected methods ------------------------------------------------------ - - protected ConflictResolver getConflictResolver() - { - return conflictResolver; - } - - protected void assertResolveConflict( ResolutionNode expectedNode, ResolutionNode actualNode1, ResolutionNode actualNode2 ) - { - ResolutionNode resolvedNode = getConflictResolver().resolveConflict( actualNode1, actualNode2 ); - - assertNotNull( resolvedNode, "Expected resolvable" ); - assertEquals( expectedNode, resolvedNode, "Resolution node" ); - } - - protected Artifact createArtifact( String id, String version ) throws InvalidVersionSpecificationException - { - return createArtifact( id, version, Artifact.SCOPE_COMPILE ); - } - - protected Artifact createArtifact( String id, String version, String scope ) - throws InvalidVersionSpecificationException - { - return createArtifact( id, version, scope, null, false ); - } - - protected Artifact createArtifact( String id, String version, String scope, String inheritedScope, boolean optional ) - throws InvalidVersionSpecificationException - { - VersionRange versionRange = VersionRange.createFromVersionSpec( version ); - - return artifactFactory.createDependencyArtifact( GROUP_ID, id, versionRange, "jar", null, scope, - inheritedScope, optional ); - } - - protected ResolutionNode createResolutionNode( Artifact Artifact ) - { - return new ResolutionNode( Artifact, Collections.emptyList() ); - } - protected ResolutionNode createResolutionNode( Artifact Artifact, ResolutionNode parent ) - { - return new ResolutionNode( Artifact, Collections.emptyList(), parent ); - } - -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/FarthestConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/FarthestConflictResolverTest.java deleted file mode 100644 index 7b46ee342d6b..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/FarthestConflictResolverTest.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.apache.maven.repository.legacy.resolver.conflict; - -/* - * 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.artifact.resolver.ResolutionNode; -import org.junit.jupiter.api.Test; - -/** - * Tests FarthestConflictResolver. - * - * @author Mark Hobson - * @see FarthestConflictResolver - */ -public class FarthestConflictResolverTest - extends AbstractConflictResolverTest -{ - // constructors ----------------------------------------------------------- - - public FarthestConflictResolverTest() - throws Exception - { - super("farthest"); - } - - // tests ------------------------------------------------------------------ - - /** - * Tests that a:2.0 wins in the scenario: - *
-     * a:1.0
-     * b:1.0 -> a:2.0
-     * 
- */ - @Test - public void testDepth() - { - ResolutionNode a1n = createResolutionNode( a1); - ResolutionNode b1n = createResolutionNode( b1); - ResolutionNode a2n = createResolutionNode( a2, b1n ); - - assertResolveConflict( a2n, a1n, a2n ); - } - - /** - * Tests that a:2.0 wins in the scenario: - *
-     * b:1.0 -> a:2.0
-     * a:1.0
-     * 
- */ - @Test - public void testDepthReversed() - { - ResolutionNode b1n = createResolutionNode( b1 ); - ResolutionNode a2n = createResolutionNode( a2, b1n ); - ResolutionNode a1n = createResolutionNode( a1 ); - - assertResolveConflict( a2n, a2n, a1n ); - } - - /** - * Tests that a:1.0 wins in the scenario: - *
-     * a:1.0
-     * a:2.0
-     * 
- */ - @Test - public void testEqual() - { - ResolutionNode a1n = createResolutionNode( a1 ); - ResolutionNode a2n = createResolutionNode( a2 ); - - assertResolveConflict( a1n, a1n, a2n ); - } - - /** - * Tests that a:2.0 wins in the scenario: - *
-     * a:2.0
-     * a:1.0
-     * 
- */ - @Test - public void testEqualReversed() - { - ResolutionNode a2n = createResolutionNode( a2); - ResolutionNode a1n = createResolutionNode( a1); - - assertResolveConflict( a2n, a2n, a1n ); - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NearestConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NearestConflictResolverTest.java deleted file mode 100644 index 34026bc2893b..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NearestConflictResolverTest.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.apache.maven.repository.legacy.resolver.conflict; - -/* - * 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.artifact.resolver.ResolutionNode; -import org.junit.jupiter.api.Test; - -/** - * Tests NearestConflictResolver. - * - * @author Mark Hobson - * @see NearestConflictResolver - */ -public class NearestConflictResolverTest - extends AbstractConflictResolverTest -{ - // constructors ----------------------------------------------------------- - - public NearestConflictResolverTest() - throws Exception - { - super("nearest"); - } - - // tests ------------------------------------------------------------------ - - /** - * Tests that a:1.0 wins in the scenario: - *
-     * a:1.0
-     * b:1.0 -> a:2.0
-     * 
- */ - @Test - public void testDepth() - { - ResolutionNode a1n = createResolutionNode( a1); - ResolutionNode b1n = createResolutionNode( b1); - ResolutionNode a2n = createResolutionNode( a2, b1n ); - - assertResolveConflict( a1n, a1n, a2n ); - } - - /** - * Tests that a:1.0 wins in the scenario: - *
-     * b:1.0 -> a:2.0
-     * a:1.0
-     * 
- */ - @Test - public void testDepthReversed() - { - ResolutionNode b1n = createResolutionNode( b1 ); - ResolutionNode a2n = createResolutionNode( a2, b1n ); - ResolutionNode a1n = createResolutionNode( a1 ); - - assertResolveConflict( a1n, a2n, a1n ); - } - - /** - * Tests that a:1.0 wins in the scenario: - *
-     * a:1.0
-     * a:2.0
-     * 
- */ - @Test - public void testEqual() - { - ResolutionNode a1n = createResolutionNode( a1 ); - ResolutionNode a2n = createResolutionNode( a2 ); - - assertResolveConflict( a1n, a1n, a2n ); - } - - /** - * Tests that a:2.0 wins in the scenario: - *
-     * a:2.0
-     * a:1.0
-     * 
- */ - @Test - public void testEqualReversed() - { - ResolutionNode a2n = createResolutionNode( a2); - ResolutionNode a1n = createResolutionNode( a1 ); - - assertResolveConflict( a2n, a2n, a1n ); - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NewestConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NewestConflictResolverTest.java deleted file mode 100644 index 874644a9c07c..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NewestConflictResolverTest.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.apache.maven.repository.legacy.resolver.conflict; - -/* - * 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.artifact.resolver.ResolutionNode; -import org.junit.jupiter.api.Test; - -/** - * Tests NewestConflictResolver. - * - * @author Mark Hobson - * @see NewestConflictResolver - */ -public class NewestConflictResolverTest - extends AbstractConflictResolverTest -{ - // constructors ----------------------------------------------------------- - - public NewestConflictResolverTest() - throws Exception - { - super("newest"); - } - - // tests ------------------------------------------------------------------ - - /** - * Tests that a:2.0 wins in the scenario: - *
-     * a:1.0
-     * b:1.0 -> a:2.0
-     * 
- */ - @Test - public void testDepth() - { - ResolutionNode a1n = createResolutionNode( a1 ); - ResolutionNode b1n = createResolutionNode( b1 ); - ResolutionNode a2n = createResolutionNode( a2, b1n ); - - assertResolveConflict( a2n, a1n, a2n ); - } - - /** - * Tests that a:2.0 wins in the scenario: - *
-     * b:1.0 -> a:2.0
-     * a:1.0
-     * 
- */ - @Test - public void testDepthReversed() - { - ResolutionNode b1n = createResolutionNode( b1 ); - ResolutionNode a2n = createResolutionNode( a2, b1n ); - ResolutionNode a1n = createResolutionNode( a1 ); - - assertResolveConflict( a2n, a2n, a1n ); - } - - /** - * Tests that a:2.0 wins in the scenario: - *
-     * a:1.0
-     * a:2.0
-     * 
- */ - @Test - public void testEqual() - { - ResolutionNode a1n = createResolutionNode( a1 ); - ResolutionNode a2n = createResolutionNode( a2 ); - - assertResolveConflict( a2n, a1n, a2n ); - } - - /** - * Tests that a:2.0 wins in the scenario: - *
-     * a:2.0
-     * a:1.0
-     * 
- */ - @Test - public void testEqualReversed() - { - ResolutionNode a2n = createResolutionNode( a2 ); - ResolutionNode a1n = createResolutionNode( a1 ); - - assertResolveConflict( a2n, a2n, a1n ); - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/OldestConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/OldestConflictResolverTest.java deleted file mode 100644 index 76335f26afa6..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/OldestConflictResolverTest.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.apache.maven.repository.legacy.resolver.conflict; - -/* - * 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.artifact.resolver.ResolutionNode; -import org.junit.jupiter.api.Test; - -/** - * Tests OldestConflictResolver. - * - * @author Mark Hobson - * @see OldestConflictResolver - */ -public class OldestConflictResolverTest - extends AbstractConflictResolverTest -{ - // constructors ----------------------------------------------------------- - - public OldestConflictResolverTest() - throws Exception - { - super("oldest"); - } - - // tests ------------------------------------------------------------------ - - /** - * Tests that a:1.0 wins in the scenario: - *
-     * a:1.0
-     * b:1.0 -> a:2.0
-     * 
- */ - @Test - public void testDepth() - { - ResolutionNode a1n = createResolutionNode( a1 ); - ResolutionNode b1n = createResolutionNode( b1); - ResolutionNode a2n = createResolutionNode( a2, b1n ); - - assertResolveConflict( a1n, a1n, a2n ); - } - - - /** - * Tests that a:1.0 wins in the scenario: - *
-     * b:1.0 -> a:2.0
-     * a:1.0
-     * 
- */ - @Test - public void testDepthReversed() - { - ResolutionNode b1n = createResolutionNode( b1 ); - ResolutionNode a2n = createResolutionNode( a2, b1n ); - ResolutionNode a1n = createResolutionNode( a1 ); - - assertResolveConflict( a1n, a2n, a1n ); - } - - /** - * Tests that a:1.0 wins in the scenario: - *
-     * a:1.0
-     * a:2.0
-     * 
- */ - @Test - public void testEqual() - { - ResolutionNode a1n = createResolutionNode( a1 ); - ResolutionNode a2n = createResolutionNode( a2 ); - - assertResolveConflict( a1n, a1n, a2n ); - } - - /** - * Tests that a:1.0 wins in the scenario: - *
-     * a:2.0
-     * a:1.0
-     * 
- */ - @Test - public void testEqualReversed() - { - ResolutionNode a2n = createResolutionNode( a2); - ResolutionNode a1n = createResolutionNode( a1 ); - - assertResolveConflict( a1n, a2n, a1n ); - } -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultClasspathTransformationTest.java b/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultClasspathTransformationTest.java deleted file mode 100644 index 348dd978fd87..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultClasspathTransformationTest.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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 javax.inject.Inject; - -import org.apache.maven.artifact.ArtifactScopeEnum; -import org.codehaus.plexus.testing.PlexusTest; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.BeforeEach; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -/** - * - * @author Oleg Gusakov - * - */ -@PlexusTest -public class DefaultClasspathTransformationTest -{ - @Inject - ClasspathTransformation transform; - - MetadataGraph graph; - - MetadataGraphVertex v1; - MetadataGraphVertex v2; - MetadataGraphVertex v3; - MetadataGraphVertex v4; - //------------------------------------------------------------------------------------------ - @BeforeEach - public void setUp() throws Exception - { - graph = new MetadataGraph( 4, 3 ); - /* - * v2 - * v1< - * v3-v4 - * - */ - v1 = graph.addVertex(new ArtifactMetadata("g","a1","1.0")); - graph.setEntry(v1); - v2 = graph.addVertex(new ArtifactMetadata("g","a2","1.0")); - v3 = graph.addVertex(new ArtifactMetadata("g","a3","1.0")); - v4 = graph.addVertex(new ArtifactMetadata("g","a4","1.0")); - - // v1-->v2 - graph.addEdge(v1, v2, new MetadataGraphEdge( "1.1", true, null, null, 2, 1 ) ); - graph.addEdge(v1, v2, new MetadataGraphEdge( "1.2", true, null, null, 2, 2 ) ); - - // v1-->v3 - graph.addEdge(v1, v3, new MetadataGraphEdge( "1.1", true, null, null, 2, 1 ) ); - graph.addEdge(v1, v3, new MetadataGraphEdge( "1.2", true, null, null, 4, 2 ) ); - - // v3-->v4 - graph.addEdge(v3, v4, new MetadataGraphEdge( "1.1", true, ArtifactScopeEnum.runtime, null, 2, 2 ) ); - graph.addEdge(v3, v4, new MetadataGraphEdge( "1.2", true, ArtifactScopeEnum.test, null, 2, 2 ) ); - } - //------------------------------------------------------------------------------------------ - @Test - public void testCompileClasspathTransform() - throws Exception - { - ClasspathContainer res; - - res = transform.transform( graph, ArtifactScopeEnum.compile, false ); - - assertNotNull( res, "null classpath container after compile transform" ); - assertNotNull( res.getClasspath(), "null classpath after compile transform" ); - assertEquals( 3, res.getClasspath().size(), "compile classpath should have 3 entries" ); - } - //------------------------------------------------------------------------------------------ - @Test - public void testRuntimeClasspathTransform() - throws Exception - { - ClasspathContainer res; - - res = transform.transform( graph, ArtifactScopeEnum.runtime, false ); - - assertNotNull( res, "null classpath container after runtime transform" ); - assertNotNull( res.getClasspath(), "null classpath after runtime transform" ); - assertEquals( 4, res.getClasspath().size(), "runtime classpath should have 4 entries" ); - - ArtifactMetadata md = res.getClasspath().get(3); - assertEquals("1.1", md.getVersion(), "runtime artifact version should be 1.1" ); - } - //------------------------------------------------------------------------------------------ - @Test - public void testTestClasspathTransform() - throws Exception - { - ClasspathContainer res; - - res = transform.transform( graph, ArtifactScopeEnum.test, false ); - - assertNotNull( res, "null classpath container after test transform" ); - assertNotNull( res.getClasspath(), "null classpath after test transform" ); - assertEquals( 4, res.getClasspath().size(), "test classpath should have 4 entries" ); - - ArtifactMetadata md = res.getClasspath().get(3); - assertEquals("1.2", md.getVersion(), "test artifact version should be 1.2" ); - } - //------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------ -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolutionPolicyTest.java b/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolutionPolicyTest.java deleted file mode 100644 index ea4352e504ba..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolutionPolicyTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * - * @author Oleg Gusakov - * - */ - -public class DefaultGraphConflictResolutionPolicyTest -{ - GraphConflictResolutionPolicy policy; - MetadataGraphEdge e1; - MetadataGraphEdge e2; - MetadataGraphEdge e3; - //------------------------------------------------------------------------------------------ - @BeforeEach - public void setUp() throws Exception - { - policy = new DefaultGraphConflictResolutionPolicy(); - e1 = new MetadataGraphEdge( "1.1", true, null, null, 2, 1 ); - e2 = new MetadataGraphEdge( "1.2", true, null, null, 3, 2 ); - e3 = new MetadataGraphEdge( "1.2", true, null, null, 2, 3 ); - } - //------------------------------------------------------------------------------------------ - @Test - public void testDefaultPolicy() - throws Exception - { - MetadataGraphEdge res; - - res = policy.apply( e1, e2 ); - assertEquals( "1.1", res.getVersion(), "Wrong depth edge selected" ); - - res = policy.apply( e1, e3 ); - assertEquals( "1.2", res.getVersion(), "Wrong version edge selected" ); - } - //------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------ -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolverTest.java deleted file mode 100644 index 67a003ab171e..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolverTest.java +++ /dev/null @@ -1,152 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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 javax.inject.Inject; - -import org.apache.maven.artifact.ArtifactScopeEnum; -import org.codehaus.plexus.testing.PlexusTest; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -/** - * - * @author Oleg Gusakov - * - */ -@PlexusTest -public class DefaultGraphConflictResolverTest -{ - @Inject - GraphConflictResolver resolver; - - MetadataGraph graph; - - MetadataGraphVertex v1; - MetadataGraphVertex v2; - MetadataGraphVertex v3; - MetadataGraphVertex v4; - //------------------------------------------------------------------------------------------ - @BeforeEach - public void setUp() throws Exception - { - /* - * v2 - * v1< - * v3-v4 - * - */ - graph = new MetadataGraph( 4, 3 ); - v1 = graph.addVertex(new ArtifactMetadata("g","a1","1.0")); - graph.setEntry(v1); - v2 = graph.addVertex(new ArtifactMetadata("g","a2","1.0")); - v3 = graph.addVertex(new ArtifactMetadata("g","a3","1.0")); - v4 = graph.addVertex(new ArtifactMetadata("g","a4","1.0")); - - // v1-->v2 - graph.addEdge(v1, v2, new MetadataGraphEdge( "1.1", true, null, null, 2, 1 ) ); - graph.addEdge(v1, v2, new MetadataGraphEdge( "1.2", true, null, null, 2, 2 ) ); - - // v1-->v3 - graph.addEdge(v1, v3, new MetadataGraphEdge( "1.1", true, null, null, 2, 1 ) ); - graph.addEdge(v1, v3, new MetadataGraphEdge( "1.2", true, null, null, 4, 2 ) ); - - // v3-->v4 - graph.addEdge(v3, v4, new MetadataGraphEdge( "1.1", true, ArtifactScopeEnum.runtime, null, 2, 1 ) ); - graph.addEdge(v3, v4, new MetadataGraphEdge( "1.2", true, ArtifactScopeEnum.provided, null, 2, 2 ) ); - } - //------------------------------------------------------------------------------------------ - @Test - public void testCompileResolution() - throws Exception - { - MetadataGraph res; - - res = resolver.resolveConflicts( graph, ArtifactScopeEnum.compile ); - - assertNotNull( res, "null graph after resolver" ); - assertNotNull( res.getVertices(), "no vertices in the resulting graph after resolver" ); - - assertNotNull( res.getExcidentEdges(v1), "no edges in the resulting graph after resolver" ); - - assertEquals( 4, res.getVertices().size(), "wrong # of vertices in the resulting graph after resolver" ); - assertEquals( 2, res.getExcidentEdges(v1).size(), "wrong # of excident edges in the resulting graph entry after resolver" ); - - assertEquals( 1, res.getIncidentEdges(v2).size(), "wrong # of v2 incident edges in the resulting graph after resolver" ); - assertEquals( "1.2", res.getIncidentEdges(v2).get(0).getVersion(), "wrong edge v1-v2 in the resulting graph after resolver" ); - - assertEquals( 1, res.getIncidentEdges(v3).size(), "wrong # of edges v1-v3 in the resulting graph after resolver" ); - assertEquals( "1.1", res.getIncidentEdges(v3).get(0).getVersion(), "wrong edge v1-v3 in the resulting graph after resolver" ); - - assertEquals( 1, res.getIncidentEdges(v4).size(), "wrong # of edges v3-v4 in the resulting graph after resolver" ); - assertEquals( "1.2", res.getIncidentEdges(v4).get(0).getVersion(), "wrong edge v3-v4 in the resulting graph after resolver" ); - } - //------------------------------------------------------------------------------------------ - @Test - public void testRuntimeResolution() - throws Exception - { - MetadataGraph res; - - res = resolver.resolveConflicts( graph, ArtifactScopeEnum.runtime ); - - assertNotNull( res, "null graph after resolver" ); - assertNotNull( res.getVertices(), "no vertices in the resulting graph after resolver" ); - assertNotNull( res.getExcidentEdges(v1), "no edges in the resulting graph after resolver" ); - - assertEquals( 4, res.getVertices().size(), "wrong # of vertices in the resulting graph after resolver" ); - assertEquals( 2, res.getExcidentEdges(v1).size(), "wrong # of excident edges in the resulting graph entry after resolver" ); - - assertEquals( 1, res.getIncidentEdges(v2).size(), "wrong # of v2 incident edges in the resulting graph after resolver" ); - assertEquals( "1.2", res.getIncidentEdges(v2).get(0).getVersion(), "wrong edge v1-v2 in the resulting graph after resolver" ); - - assertEquals( 1, res.getIncidentEdges(v3).size(), "wrong # of edges v1-v3 in the resulting graph after resolver" ); - assertEquals( "1.1", res.getIncidentEdges(v3).get(0).getVersion(), "wrong edge v1-v3 in the resulting graph after resolver" ); - - assertEquals( 1, res.getIncidentEdges(v4).size(), "wrong # of edges v3-v4 in the resulting graph after resolver" ); - assertEquals( "1.1", res.getIncidentEdges(v4).get(0).getVersion(), "wrong edge v3-v4 in the resulting graph after resolver" ); - } - //------------------------------------------------------------------------------------------ - @Test - public void testTestResolution() - throws Exception - { - MetadataGraph res; - - res = resolver.resolveConflicts( graph, ArtifactScopeEnum.test ); - - assertNotNull( res, "null graph after resolver" ); - assertNotNull( res.getVertices(), "no vertices in the resulting graph after resolver" ); - assertNotNull( res.getExcidentEdges(v1), "no edges in the resulting graph after resolver" ); - - assertEquals( 4, res.getVertices().size(), "wrong # of vertices in the resulting graph after resolver" ); - assertEquals( 2, res.getExcidentEdges(v1).size(), "wrong # of excident edges in the resulting graph entry after resolver" ); - - assertEquals( 1, res.getIncidentEdges(v2).size(), "wrong # of v2 incident edges in the resulting graph after resolver" ); - assertEquals( "1.2", res.getIncidentEdges(v2).get(0).getVersion(), "wrong edge v1-v2 in the resulting graph after resolver" ); - - assertEquals( 1, res.getIncidentEdges(v3).size(), "wrong # of edges v1-v3 in the resulting graph after resolver" ); - assertEquals( "1.1", res.getIncidentEdges(v3).get(0).getVersion(), "wrong edge v1-v3 in the resulting graph after resolver" ); - - assertEquals( 1, res.getIncidentEdges(v4).size(), "wrong # of edges v3-v4 in the resulting graph after resolver" ); - assertEquals( "1.2", res.getIncidentEdges(v4).get(0).getVersion(), "wrong edge v3-v4 in the resulting graph after resolver" ); - } - //------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------ -} diff --git a/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java b/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java deleted file mode 100644 index efec2e6ea771..000000000000 --- a/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.apache.maven.repository.metadata; - -/* - * 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.HashSet; -import java.util.List; -import java.util.Set; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.repository.legacy.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.repository.legacy.metadata.ArtifactMetadataSource; -import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; -import org.apache.maven.repository.legacy.metadata.ResolutionGroup; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -@Named -@Singleton -public class TestMetadataSource - implements ArtifactMetadataSource -{ - @Inject - private ArtifactFactory factory; - - public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) - throws ArtifactMetadataRetrievalException - { - Set dependencies = new HashSet<>(); - - if ( "g".equals( artifact.getArtifactId() ) ) - { - Artifact a = null; - try - { - a = factory.createBuildArtifact( "org.apache.maven", "h", "1.0", "jar" ); - dependencies.add( a ); - } - catch ( Exception e ) - { - throw new ArtifactMetadataRetrievalException( "Error retrieving metadata", e, a ); - } - } - - if ( "i".equals( artifact.getArtifactId() ) ) - { - Artifact a = null; - try - { - a = factory.createBuildArtifact( "org.apache.maven", "j", "1.0-SNAPSHOT", "jar" ); - dependencies.add( a ); - } - catch ( Exception e ) - { - throw new ArtifactMetadataRetrievalException( "Error retrieving metadata", e, a ); - } - } - - - return new ResolutionGroup( artifact, dependencies, remoteRepositories ); - } - - public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) - throws ArtifactMetadataRetrievalException - { - throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); - } - - public List retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository ) - throws ArtifactMetadataRetrievalException - { - throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); - } - - public ResolutionGroup retrieve( MetadataResolutionRequest request ) - throws ArtifactMetadataRetrievalException - { - return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); - } - -} diff --git a/maven-compat/src/test/remote-repo/org/apache/maven/its/a/0.1/a-0.1.jar b/maven-compat/src/test/remote-repo/org/apache/maven/its/a/0.1/a-0.1.jar deleted file mode 100644 index 609ec21bcac4..000000000000 Binary files a/maven-compat/src/test/remote-repo/org/apache/maven/its/a/0.1/a-0.1.jar and /dev/null differ diff --git a/maven-compat/src/test/remote-repo/org/apache/maven/its/a/0.1/a-0.1.pom b/maven-compat/src/test/remote-repo/org/apache/maven/its/a/0.1/a-0.1.pom deleted file mode 100644 index 03caa12ee830..000000000000 --- a/maven-compat/src/test/remote-repo/org/apache/maven/its/a/0.1/a-0.1.pom +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - 4.0.0 - - org.apache.maven.its - a - 0.1 - jar - - Maven Integration Test :: Dummy Artifact - - - - - - - maven-core-it - file:///${basedir}/repo - - - diff --git a/maven-compat/src/test/remote-repo/org/apache/maven/its/a/maven-metadata.xml b/maven-compat/src/test/remote-repo/org/apache/maven/its/a/maven-metadata.xml deleted file mode 100644 index 8099175ec04b..000000000000 --- a/maven-compat/src/test/remote-repo/org/apache/maven/its/a/maven-metadata.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - org.apache.maven.its - a - 0.1 - - - 0.1 - - 20091023222756 - - diff --git a/maven-compat/src/test/remote-repo/org/apache/maven/its/b/0.1/b-0.1.jar b/maven-compat/src/test/remote-repo/org/apache/maven/its/b/0.1/b-0.1.jar deleted file mode 100644 index 19df0485a785..000000000000 Binary files a/maven-compat/src/test/remote-repo/org/apache/maven/its/b/0.1/b-0.1.jar and /dev/null differ diff --git a/maven-compat/src/test/remote-repo/org/apache/maven/its/b/0.1/b-0.1.pom b/maven-compat/src/test/remote-repo/org/apache/maven/its/b/0.1/b-0.1.pom deleted file mode 100644 index 149a2410888d..000000000000 --- a/maven-compat/src/test/remote-repo/org/apache/maven/its/b/0.1/b-0.1.pom +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - 4.0.0 - - org.apache.maven.its - b - 0.1 - jar - - Maven Integration Test :: Dummy Artifact - - - - - - - maven-core-it - file:///${basedir}/repo - - - - - - org.apache.maven.its - a - 0.1 - - - diff --git a/maven-compat/src/test/remote-repo/org/apache/maven/its/b/maven-metadata.xml b/maven-compat/src/test/remote-repo/org/apache/maven/its/b/maven-metadata.xml deleted file mode 100644 index e77af628fad2..000000000000 --- a/maven-compat/src/test/remote-repo/org/apache/maven/its/b/maven-metadata.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - org.apache.maven.its - b - 0.1 - - - 0.1 - - 20091023222817 - - diff --git a/maven-compat/src/test/repository-system/maven-core-2.1.0.jar b/maven-compat/src/test/repository-system/maven-core-2.1.0.jar deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/maven-compat/src/test/resources/artifact-install/artifact-1.0.jar b/maven-compat/src/test/resources/artifact-install/artifact-1.0.jar deleted file mode 100644 index 421376db9e8a..000000000000 --- a/maven-compat/src/test/resources/artifact-install/artifact-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -dummy diff --git a/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p0-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p0-1.0.pom deleted file mode 100644 index 92c9f41d22cb..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p0-1.0.pom +++ /dev/null @@ -1,11 +0,0 @@ - - 4.0.0 - maven - p0 - pom - p0 - 1.0 - - Codehaus - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p1-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p1-1.0.pom deleted file mode 100644 index 6038a806a410..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p1-1.0.pom +++ /dev/null @@ -1,16 +0,0 @@ - - - p0 - maven - 1.0 - - 4.0.0 - maven - p1 - pom - p1 - 1.0 - - scm-url - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p2-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p2-1.0.pom deleted file mode 100644 index 9ac112ac4615..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p2-1.0.pom +++ /dev/null @@ -1,18 +0,0 @@ - - - p1 - maven - 1.0 - - 4.0.0 - maven - p2 - pom - p2 - 1.0 - - - mailing-list - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p3-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p3-1.0.pom deleted file mode 100644 index d40684e9702c..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p3-1.0.pom +++ /dev/null @@ -1,14 +0,0 @@ - - - p2 - maven - 1.0 - - 4.0.0 - maven - p3 - pom - p3 - 1.0 - 2000 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p4-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p4-1.0.pom deleted file mode 100644 index dc9a2735297b..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p4-1.0.pom +++ /dev/null @@ -1,13 +0,0 @@ - - - p3 - maven - 1.0 - - 4.0.0 - maven - p4 - jar - p4 - 1.0 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p0-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p0-1.0.pom deleted file mode 100644 index 9df2582d6655..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p0-1.0.pom +++ /dev/null @@ -1,11 +0,0 @@ - - 4.0.0 - maven.t01 - p0 - pom - p0 - 1.0 - - p0-org - - diff --git a/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p1-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p1-1.0.pom deleted file mode 100644 index 4fc81d833878..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p1-1.0.pom +++ /dev/null @@ -1,16 +0,0 @@ - - - p0 - maven.t01 - 1.0 - - 4.0.0 - maven.t01 - p1 - pom - p1 - 1.0 - - p1-org - - diff --git a/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p2-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p2-1.0.pom deleted file mode 100644 index 8032cf2fb170..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p2-1.0.pom +++ /dev/null @@ -1,16 +0,0 @@ - - - p1 - maven.t01 - 1.0 - - 4.0.0 - maven.t01 - p2 - pom - p2 - 1.0 - - p2-org - - diff --git a/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p3-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p3-1.0.pom deleted file mode 100644 index 6ed58569fc4d..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p3-1.0.pom +++ /dev/null @@ -1,16 +0,0 @@ - - - p2 - maven.t01 - 1.0 - - 4.0.0 - maven.t01 - p3 - pom - p3 - 1.0 - - p3-org - - diff --git a/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p4-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p4-1.0.pom deleted file mode 100644 index 1739333a8206..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p4-1.0.pom +++ /dev/null @@ -1,16 +0,0 @@ - - - p3 - maven.t01 - 1.0 - - 4.0.0 - maven.t01 - p4 - jar - p4 - 1.0 - - p4-org - - diff --git a/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/p4/p5/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/p4/p5/pom.xml deleted file mode 100644 index 93d1d72f64d2..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/p4/p5/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - p4 - maven.t02 - 1.0 - - 4.0.0 - maven.t02 - p5 - jar - p5 - 1.0 - diff --git a/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/p4/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/p4/pom.xml deleted file mode 100644 index 77958f787afa..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/p4/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - p3 - maven.t02 - 1.0 - - 4.0.0 - maven.t02 - p4 - pom - p4 - 1.0 - diff --git a/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/pom.xml deleted file mode 100644 index d83de976d113..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - p2 - maven.t02 - 1.0 - - 4.0.0 - maven.t02 - p3 - pom - p3 - 1.0 - 2000 - diff --git a/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/pom.xml deleted file mode 100644 index c2b7d7153e3a..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - p1 - maven.t02 - 1.0 - - 4.0.0 - maven.t02 - p2 - pom - p2 - 1.0 - - - mailing-list - - - diff --git a/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/pom.xml deleted file mode 100644 index af2d92ede4c5..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - p0 - maven.t02 - 1.0 - - 4.0.0 - maven.t02 - p1 - pom - p1 - 1.0 - - scm-url - - - - - maven-compiler-plugin - - - test - package - - compile - - - - - - - diff --git a/maven-compat/src/test/resources/inheritance-repo/t02/p0/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t02/p0/pom.xml deleted file mode 100644 index 3643fe49f3eb..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t02/p0/pom.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - 4.0.0 - maven.t02 - p0 - pom - p0 - 1.0 - - Codehaus - - diff --git a/maven-compat/src/test/resources/inheritance-repo/t03/p0/p1/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t03/p0/p1/pom.xml deleted file mode 100644 index 69fe6a1dce29..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t03/p0/p1/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - p0 - maven.t03 - 1.0 - - 4.0.0 - maven.t03 - p1 - pom - p1 - 1.0 - - scm-url - - - - - maven-antrun-plugin - - ${project.parent.basedir} - - - - - diff --git a/maven-compat/src/test/resources/inheritance-repo/t03/p0/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t03/p0/pom.xml deleted file mode 100644 index 476ffdfbdd17..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t03/p0/pom.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - 4.0.0 - maven.t03 - p0 - pom - p0 - 1.0 - - Codehaus - - diff --git a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/jars/t04-a-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/jars/t04-a-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/jars/t04-a-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/jars/t04-b-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/jars/t04-b-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/jars/t04-b-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/jars/t04-b-2.0.jar b/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/jars/t04-b-2.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/jars/t04-b-2.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/jars/t04-c-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/jars/t04-c-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/jars/t04-c-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/jars/t04-c-2.0.jar b/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/jars/t04-c-2.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/jars/t04-c-2.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-a-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-a-1.0.pom deleted file mode 100644 index 5ca34c3a2e8e..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-a-1.0.pom +++ /dev/null @@ -1,21 +0,0 @@ - - 4.0.0 - maven-test - t04-a - jar - 1.0 - - - central - Fake Maven Central Repository - file://dummy - - - - - maven-test - t04-b - 2.0 - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-b-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-b-1.0.pom deleted file mode 100644 index 4c311ab133d4..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-b-1.0.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - t04-b - jar - 1.0 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-b-2.0.pom b/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-b-2.0.pom deleted file mode 100644 index d24e3bc1f571..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-b-2.0.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - t04-b - jar - 2.0 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-c-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-c-1.0.pom deleted file mode 100644 index bef2488ba440..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-c-1.0.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - t04-c - jar - 1.0 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-c-2.0.pom b/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-c-2.0.pom deleted file mode 100644 index d24e3bc1f571..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-c-2.0.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - t04-b - jar - 2.0 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t04/p0/p1/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t04/p0/p1/pom.xml deleted file mode 100644 index c25fc3e7388d..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t04/p0/p1/pom.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - p0 - maven-t04 - 1.0 - - 4.0.0 - maven-t04 - p1 - pom - p1 - 1.0 - - scm-url - - - - - - maven-test - t04-a - - - - maven-test - t04-c - 1.0 - - - - - - - maven-antrun-plugin - - ${project.parent.basedir} - - - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t04/p0/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t04/p0/pom.xml deleted file mode 100644 index b7eb670ec6aa..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t04/p0/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - 4.0.0 - maven-t04 - p0 - pom - p0 - 1.0 - - Codehaus - - - - - - - - maven-test - t04-a - 1.0 - - - - maven-test - t04-b - 1.0 - - - - maven-test - t04-c - 2.0 - - - - - - diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-a-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-a-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-a-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-a-2.0.jar b/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-a-2.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-a-2.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-b-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-b-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-b-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-b-1.1.jar b/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-b-1.1.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-b-1.1.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-b-2.0.jar b/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-b-2.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-b-2.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-c-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-c-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-c-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-d-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-d-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-d-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-d-1.1.jar b/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-d-1.1.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-d-1.1.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-d-1.2.jar b/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-d-1.2.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/t05-d-1.2.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-a-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-a-1.0.pom deleted file mode 100644 index a1b8cb9b1137..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-a-1.0.pom +++ /dev/null @@ -1,23 +0,0 @@ - - 4.0.0 - maven-test - t05-a - jar - 1.0 - - - central - Fake Maven Central Repository - file://dummy - - - - - maven-test - t05-b - 1.0 - jar - compile - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-a-2.0.pom b/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-a-2.0.pom deleted file mode 100644 index 097101e81f3c..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-a-2.0.pom +++ /dev/null @@ -1,23 +0,0 @@ - - 4.0.0 - maven-test - t05-a - jar - 2.0 - - - central - Fake Maven Central Repository - file://dummy - - - - - maven-test - t05-b - 1.0 - jar - compile - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-b-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-b-1.0.pom deleted file mode 100644 index e0490ff73be0..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-b-1.0.pom +++ /dev/null @@ -1,24 +0,0 @@ - - 4.0.0 - maven-test - t05-b - jar - 1.0 - - - maven-test - t05-c - 1.0 - jar - compile - - - maven-test - t05-d - 1.1 - jar - compile - false - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-b-1.1.pom b/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-b-1.1.pom deleted file mode 100644 index ff59f5d2b7a2..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-b-1.1.pom +++ /dev/null @@ -1,24 +0,0 @@ - - 4.0.0 - maven-test - t05-b - jar - 1.1 - - - maven-test - t05-c - 1.0 - jar - compile - - - maven-test - t05-d - 1.1 - jar - compile - false - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-b-2.0.pom b/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-b-2.0.pom deleted file mode 100644 index 79370ec4f01c..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-b-2.0.pom +++ /dev/null @@ -1,24 +0,0 @@ - - 4.0.0 - maven-test - t05-b - jar - 2.0 - - - maven-test - t05-c - 1.0 - jar - compile - - - maven-test - t05-d - 1.1 - jar - compile - false - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-c-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-c-1.0.pom deleted file mode 100644 index 0edc3ddd6f50..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-c-1.0.pom +++ /dev/null @@ -1,17 +0,0 @@ - - 4.0.0 - maven-test - t05-c - jar - 1.0 - - - maven-test - t05-d - 1.1 - jar - compile - true - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-d-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-d-1.0.pom deleted file mode 100644 index 9290b033d5e0..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-d-1.0.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - t05-d - jar - 1.0 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-d-1.1.pom b/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-d-1.1.pom deleted file mode 100644 index b4af4b2cdb89..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-d-1.1.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - t05-d - jar - 1.1 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-d-1.2.pom b/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-d-1.2.pom deleted file mode 100644 index 09e1d9470c89..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-d-1.2.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - t05-d - jar - 1.2 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/p0/p1/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t05/p0/p1/pom.xml deleted file mode 100644 index d9c2d52bba32..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/p0/p1/pom.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - p0 - maven-t05 - 1.0 - - 4.0.0 - maven-t05 - p1 - pom - p1 - 1.0 - - scm-url - - - - - maven-test - t05-b - 1.0 - - - maven-test - t05-d - 1.0 - - - - - - maven-test - t05-a - 1.0 - runtime - - - maven-test - t05-c - 1.0 - runtime - - - - - - maven-antrun-plugin - - ${project.parent.basedir} - - - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t05/p0/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t05/p0/pom.xml deleted file mode 100644 index 6c93838b93a8..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t05/p0/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - 4.0.0 - maven-t05 - p0 - pom - p0 - 1.0 - - Codehaus - - - - - maven-test - t05-a - 1.0 - - - maven-test - t05-b - 1.1 - - - maven-test - t05-c - 1.0 - compile - - - maven-test - t05-d - 1.2 - - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-a-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-a-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-a-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-b-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-b-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-b-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-b-1.1.jar b/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-b-1.1.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-b-1.1.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-c-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-c-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-c-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-d-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-d-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-d-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-d-1.1.jar b/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-d-1.1.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-d-1.1.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-d-1.2.jar b/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-d-1.2.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/t06-d-1.2.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-a-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-a-1.0.pom deleted file mode 100644 index 21aa5f556be0..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-a-1.0.pom +++ /dev/null @@ -1,23 +0,0 @@ - - 4.0.0 - maven-test - t06-a - jar - 1.0 - - - central - Fake Maven Central Repository - file://dummy - - - - - maven-test - t06-b - 1.0 - jar - compile - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-b-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-b-1.0.pom deleted file mode 100644 index a9af131cba8a..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-b-1.0.pom +++ /dev/null @@ -1,24 +0,0 @@ - - 4.0.0 - maven-test - t06-b - jar - 1.0 - - - maven-test - t06-c - 1.0 - jar - compile - - - maven-test - t06-d - 1.1 - jar - compile - false - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-b-1.1.pom b/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-b-1.1.pom deleted file mode 100644 index a9af131cba8a..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-b-1.1.pom +++ /dev/null @@ -1,24 +0,0 @@ - - 4.0.0 - maven-test - t06-b - jar - 1.0 - - - maven-test - t06-c - 1.0 - jar - compile - - - maven-test - t06-d - 1.1 - jar - compile - false - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-c-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-c-1.0.pom deleted file mode 100644 index 80272114a8c2..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-c-1.0.pom +++ /dev/null @@ -1,17 +0,0 @@ - - 4.0.0 - maven-test - t06-c - jar - 1.0 - - - maven-test - t06-d - 1.1 - jar - compile - true - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-d-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-d-1.0.pom deleted file mode 100644 index e4531ab4a7ca..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-d-1.0.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - t06-d - jar - 1.0 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-d-1.1.pom b/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-d-1.1.pom deleted file mode 100644 index c146cb89a6a5..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-d-1.1.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - t06-d - jar - 1.1 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-d-1.2.pom b/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-d-1.2.pom deleted file mode 100644 index ff91f975ae2d..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-d-1.2.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - t06-d - jar - 1.2 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t06/p0/p1/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t06/p0/p1/pom.xml deleted file mode 100644 index 468621901e57..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t06/p0/p1/pom.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - p0 - maven-t06 - 1.0 - - 4.0.0 - maven-t06 - p1 - pom - p1 - 1.0 - - scm-url - - - - - maven-test - t06-b - 1.0 - - - maven-test - t06-d - 1.0 - test - false - - - - - - maven-test - t06-a - 1.0 - - - maven-test - t06-c - 1.0 - - - - - - maven-antrun-plugin - - ${project.parent.basedir} - - - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t06/p0/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t06/p0/pom.xml deleted file mode 100644 index 60c540ca1227..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t06/p0/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - 4.0.0 - maven-t06 - p0 - pom - p0 - 1.0 - - Codehaus - - - - - maven-test - t06-a - 1.0 - - - maven-test - t06-b - 1.1 - - - maven-test - t06-c - 1.0 - - - maven-test - t06-d - 1.2 - test - false - - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-a-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-a-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-a-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-b-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-b-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-b-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-b-1.1.jar b/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-b-1.1.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-b-1.1.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-c-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-c-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-c-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-d-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-d-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-d-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-d-1.1.jar b/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-d-1.1.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-d-1.1.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-d-1.2.jar b/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-d-1.2.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/t07-d-1.2.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-a-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-a-1.0.pom deleted file mode 100644 index 05665a9c27c9..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-a-1.0.pom +++ /dev/null @@ -1,23 +0,0 @@ - - 4.0.0 - maven-test - t07-a - jar - 1.0 - - - central - Fake Maven Central Repository - file://dummy - - - - - maven-test - t07-b - 1.0 - jar - compile - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-b-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-b-1.0.pom deleted file mode 100644 index 8ce6751c9320..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-b-1.0.pom +++ /dev/null @@ -1,24 +0,0 @@ - - 4.0.0 - maven-test - t07-b - jar - 1.0 - - - maven-test - t07-c - 1.0 - jar - compile - - - maven-test - t07-d - 1.1 - jar - compile - true - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-b-1.1.pom b/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-b-1.1.pom deleted file mode 100644 index 689ad055ed99..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-b-1.1.pom +++ /dev/null @@ -1,24 +0,0 @@ - - 4.0.0 - maven-test - t07-b - jar - 1.1 - - - maven-test - t07-c - 1.0 - jar - compile - - - maven-test - t07-d - 1.1 - jar - compile - true - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-c-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-c-1.0.pom deleted file mode 100644 index 494470c49ba5..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-c-1.0.pom +++ /dev/null @@ -1,17 +0,0 @@ - - 4.0.0 - maven-test - t07-c - jar - 1.0 - - - maven-test - t07-d - 1.1 - jar - compile - true - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-d-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-d-1.0.pom deleted file mode 100644 index 5761d515471b..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-d-1.0.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - t07-d - jar - 1.0 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-d-1.1.pom b/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-d-1.1.pom deleted file mode 100644 index 08fc179c17ad..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-d-1.1.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - t07-d - jar - 1.1 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-d-1.2.pom b/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-d-1.2.pom deleted file mode 100644 index 544ccc59a08c..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-d-1.2.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - t07-d - jar - 1.2 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t07/p0/p1/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t07/p0/p1/pom.xml deleted file mode 100644 index 6f700429a02a..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t07/p0/p1/pom.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - p0 - maven-t07 - 1.0 - - 4.0.0 - maven-t07 - p1 - pom - p1 - 1.0 - - scm-url - - - - - maven-test - t07-b - 1.0 - - - maven-test - t07-d - 1.0 - test - false - - - - - - maven-test - t07-a - 1.0 - - - maven-test - t07-c - 1.0 - - - - - - maven-antrun-plugin - - ${project.parent.basedir} - - - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t07/p0/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t07/p0/pom.xml deleted file mode 100644 index b500ee0e5867..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t07/p0/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - 4.0.0 - maven-t07 - p0 - pom - p0 - 1.0 - - Codehaus - - - - - maven-test - t07-a - 1.0 - - - maven-test - t07-b - 1.1 - - - maven-test - t07-c - 1.0 - - - maven-test - t07-d - 1.2 - test - false - - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-a-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-a-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-a-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-b-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-b-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-b-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-b-1.1.jar b/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-b-1.1.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-b-1.1.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-c-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-c-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-c-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-d-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-d-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-d-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-d-1.1.jar b/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-d-1.1.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-d-1.1.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-d-1.2.jar b/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-d-1.2.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/t08-d-1.2.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-a-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-a-1.0.pom deleted file mode 100644 index 186c2d89f159..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-a-1.0.pom +++ /dev/null @@ -1,23 +0,0 @@ - - 4.0.0 - maven-test - t08-a - jar - 1.0 - - - central - Fake Maven Central Repository - file://dummy - - - - - maven-test - t08-b - 1.0 - jar - compile - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-b-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-b-1.0.pom deleted file mode 100644 index d866ab355699..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-b-1.0.pom +++ /dev/null @@ -1,24 +0,0 @@ - - 4.0.0 - maven-test - t08-b - jar - 1.0 - - - maven-test - t08-c - 1.0 - jar - compile - - - maven-test - t08-d - 1.1 - jar - compile - false - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-b-1.1.pom b/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-b-1.1.pom deleted file mode 100644 index d402466e9f1b..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-b-1.1.pom +++ /dev/null @@ -1,24 +0,0 @@ - - 4.0.0 - maven-test - t08-b - jar - 1.1 - - - maven-test - t08-c - 1.0 - jar - compile - - - maven-test - t08-d - 1.1 - jar - compile - false - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-c-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-c-1.0.pom deleted file mode 100644 index d8250528e231..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-c-1.0.pom +++ /dev/null @@ -1,17 +0,0 @@ - - 4.0.0 - maven-test - t08-c - jar - 1.0 - - - maven-test - t08-d - 1.1 - jar - compile - true - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-d-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-d-1.0.pom deleted file mode 100644 index f4530458802c..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-d-1.0.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - t08-d - jar - 1.0 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-d-1.1.pom b/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-d-1.1.pom deleted file mode 100644 index c7703b02db43..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-d-1.1.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - t08-d - jar - 1.1 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-d-1.2.pom b/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-d-1.2.pom deleted file mode 100644 index e341be534df3..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-d-1.2.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - t08-d - jar - 1.2 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t08/p0/p1/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t08/p0/p1/pom.xml deleted file mode 100644 index 331996d87e93..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t08/p0/p1/pom.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - p0 - maven-t08 - 1.0 - - 4.0.0 - maven-t08 - p1 - pom - p1 - 1.0 - - scm-url - - - - - maven-test - t08-b - 1.0 - - - maven-test - t08-d - 1.0 - test - true - - - - - - maven-test - t08-a - 1.0 - - - maven-test - t08-c - 1.0 - - - maven-test - t08-d - 1.0 - - - - - - maven-antrun-plugin - - ${project.parent.basedir} - - - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t08/p0/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t08/p0/pom.xml deleted file mode 100644 index a18ab853d1b1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t08/p0/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - 4.0.0 - maven-t08 - p0 - pom - p0 - 1.0 - - Codehaus - - - - - maven-test - t08-a - 1.0 - - - maven-test - t08-b - 1.1 - - - maven-test - t08-c - 1.0 - - - maven-test - t08-d - 1.2 - test - false - - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/jars/t09-a-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/jars/t09-a-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/jars/t09-a-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/jars/t09-b-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/jars/t09-b-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/jars/t09-b-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/jars/t09-c-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/jars/t09-c-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/jars/t09-c-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/jars/t09-d-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/jars/t09-d-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/jars/t09-d-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/poms/t09-a-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/poms/t09-a-1.0.pom deleted file mode 100644 index 54cf647b2b1a..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/poms/t09-a-1.0.pom +++ /dev/null @@ -1,24 +0,0 @@ - - 4.0.0 - maven-test - t09-a - jar - 1.0 - - - central - Fake Maven Central Repository - file://dummy - - - - - - maven-test - t09-b - 1.0 - compile - - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/poms/t09-b-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/poms/t09-b-1.0.pom deleted file mode 100644 index ce001c2f30db..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/poms/t09-b-1.0.pom +++ /dev/null @@ -1,17 +0,0 @@ - - 4.0.0 - maven-test - t09-b - jar - 1.0 - - - - maven-test - t09-c - 1.0 - compile - - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/poms/t09-c-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/poms/t09-c-1.0.pom deleted file mode 100644 index da7bc3494673..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/poms/t09-c-1.0.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - t09-c - jar - 1.0 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/poms/t09-d-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/poms/t09-d-1.0.pom deleted file mode 100644 index 862274728a4a..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/poms/t09-d-1.0.pom +++ /dev/null @@ -1,17 +0,0 @@ - - 4.0.0 - maven-test - t09-d - jar - 1.0 - - - - maven-test - t09-c - 1.0 - compile - - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t09/p0/p1/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t09/p0/p1/pom.xml deleted file mode 100644 index ae4358436dc1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t09/p0/p1/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - p0 - maven-t09 - 1.0 - - 4.0.0 - maven-t09 - p1 - pom - p1 - 1.0 - - scm-url - - - - - - maven-test - t09-a - - - - - - - - maven-antrun-plugin - - ${project.parent.basedir} - - - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t09/p0/p2/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t09/p0/p2/pom.xml deleted file mode 100644 index 4681c2efe83a..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t09/p0/p2/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - p0 - maven-t09 - 1.0 - - 4.0.0 - maven-t09 - p2 - pom - p2 - 1.0 - - scm-url - - - - - - maven-test - t09-a - - - - maven-test - t09-d - 1.0 - - - - - - - - maven-antrun-plugin - - ${project.parent.basedir} - - - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t09/p0/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t09/p0/pom.xml deleted file mode 100644 index a93746d28194..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t09/p0/pom.xml +++ /dev/null @@ -1,38 +0,0 @@ - - 4.0.0 - maven-t09 - p0 - pom - p0 - 1.0 - - Codehaus - - - - - - - - maven-test - t09-a - 1.0 - - - - maven-test - t09-b - 1.0 - - - maven-test - t09-c - - - - - - - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/jars/t10-a-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/jars/t10-a-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/jars/t10-a-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/jars/t10-b-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/jars/t10-b-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/jars/t10-b-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/jars/t10-c-1.0.jar b/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/jars/t10-c-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/jars/t10-c-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/poms/t10-a-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/poms/t10-a-1.0.pom deleted file mode 100644 index 1fc2a2216a8a..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/poms/t10-a-1.0.pom +++ /dev/null @@ -1,24 +0,0 @@ - - 4.0.0 - maven-test - t10-a - jar - 1.0 - - - central - Fake Maven Central Repository - file://dummy - - - - - - maven-test - t10-b - 1.0 - compile - - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/poms/t10-b-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/poms/t10-b-1.0.pom deleted file mode 100644 index 64b5f97a0c39..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/poms/t10-b-1.0.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - t10-b - jar - 1.0 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/poms/t10-c-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/poms/t10-c-1.0.pom deleted file mode 100644 index 6548ab300680..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/poms/t10-c-1.0.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - t10-c - jar - 1.0 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t10/p0/p1/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t10/p0/p1/pom.xml deleted file mode 100644 index ed82ae1344cc..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t10/p0/p1/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - p0 - maven-t10 - 1.0 - - 4.0.0 - maven-t10 - p1 - pom - p1 - 1.0 - - scm-url - - - - - - maven-test - t10-a - - - - maven-test - t10-c - runtime - - - - - - - - maven-antrun-plugin - - ${project.parent.basedir} - - - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t10/p0/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t10/p0/pom.xml deleted file mode 100644 index 74b631756cea..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t10/p0/pom.xml +++ /dev/null @@ -1,41 +0,0 @@ - - 4.0.0 - maven-t10 - p0 - pom - p0 - 1.0 - - Codehaus - - - - - - - - maven-test - t10-a - 1.0 - test - - - - maven-test - t10-b - 1.0 - runtime - - - - maven-test - t10-c - 1.0 - test - - - - - - - diff --git a/maven-compat/src/test/resources/inheritance-repo/t11/p0/p1/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t11/p0/p1/pom.xml deleted file mode 100644 index e4c79be4576f..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t11/p0/p1/pom.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - p0 - maven - 1.0 - - 4.0.0 - maven - p1 - jar - p1 - 1.0 - - scm-url - - diff --git a/maven-compat/src/test/resources/inheritance-repo/t11/p0/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t11/p0/pom.xml deleted file mode 100644 index 23b07e2c0ad8..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t11/p0/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - 4.0.0 - maven - p0 - pom - p0 - 1.0 - - Codehaus - - - - - - - - maven - p1 - 1.0 - test - - - - - - - diff --git a/maven-compat/src/test/resources/inheritance-repo/t12/p0/p1/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t12/p0/p1/pom.xml deleted file mode 100644 index 15115cb85689..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t12/p0/p1/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - p0 - maven - 1.0 - - 4.0.0 - p1 - jar - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - normal - - - compile - - - - - - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t12/p0/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t12/p0/pom.xml deleted file mode 100644 index 4f2e64262d06..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t12/p0/pom.xml +++ /dev/null @@ -1,30 +0,0 @@ - - 4.0.0 - maven - p0 - pom - 1.0 - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - test - - - false - - - compile - - install - - - - - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p0/1.0/p0-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p0/1.0/p0-1.0.pom deleted file mode 100644 index a22df68eac12..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p0/1.0/p0-1.0.pom +++ /dev/null @@ -1,18 +0,0 @@ - - 4.0.0 - maven - p0 - pom - 1.0 - - - scm:svn:http://host/p0 - scm:svn:https://host/p0 - http://host/viewer?path=/p0 - - - - modules/p1 - - - diff --git a/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p1/1.0/p1-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p1/1.0/p1-1.0.pom deleted file mode 100644 index 736b51539b45..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p1/1.0/p1-1.0.pom +++ /dev/null @@ -1,11 +0,0 @@ - - - p0 - maven - 1.0 - ../../pom.xml - - 4.0.0 - p1 - - diff --git a/maven-compat/src/test/resources/inheritance-repo/t12scm/p0/modules/p1/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t12scm/p0/modules/p1/pom.xml deleted file mode 100644 index 736b51539b45..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t12scm/p0/modules/p1/pom.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - p0 - maven - 1.0 - ../../pom.xml - - 4.0.0 - p1 - - diff --git a/maven-compat/src/test/resources/inheritance-repo/t12scm/p0/pom.xml b/maven-compat/src/test/resources/inheritance-repo/t12scm/p0/pom.xml deleted file mode 100644 index a22df68eac12..000000000000 --- a/maven-compat/src/test/resources/inheritance-repo/t12scm/p0/pom.xml +++ /dev/null @@ -1,18 +0,0 @@ - - 4.0.0 - maven - p0 - pom - 1.0 - - - scm:svn:http://host/p0 - scm:svn:https://host/p0 - http://host/viewer?path=/p0 - - - - modules/p1 - - - diff --git a/maven-compat/src/test/resources/local-repo/marker.txt b/maven-compat/src/test/resources/local-repo/marker.txt deleted file mode 100644 index d9bab060dde5..000000000000 --- a/maven-compat/src/test/resources/local-repo/marker.txt +++ /dev/null @@ -1 +0,0 @@ -this is just a marker file. \ No newline at end of file diff --git a/maven-compat/src/test/resources/local-repo/maven-test/jars/maven-test-a-1.0.jar b/maven-compat/src/test/resources/local-repo/maven-test/jars/maven-test-a-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/local-repo/maven-test/jars/maven-test-a-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/local-repo/maven-test/jars/maven-test-b-1.0.jar b/maven-compat/src/test/resources/local-repo/maven-test/jars/maven-test-b-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/local-repo/maven-test/jars/maven-test-b-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/local-repo/maven-test/jars/maven-test-c-1.0.jar b/maven-compat/src/test/resources/local-repo/maven-test/jars/maven-test-c-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/local-repo/maven-test/jars/maven-test-c-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/local-repo/maven-test/jars/maven-test-d-1.0.jar b/maven-compat/src/test/resources/local-repo/maven-test/jars/maven-test-d-1.0.jar deleted file mode 100644 index 257cc5642cb1..000000000000 --- a/maven-compat/src/test/resources/local-repo/maven-test/jars/maven-test-d-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-a-1.0.pom b/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-a-1.0.pom deleted file mode 100644 index 6905f6c8de25..000000000000 --- a/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-a-1.0.pom +++ /dev/null @@ -1,23 +0,0 @@ - - 4.0.0 - maven-test - maven-test-a - jar - 1.0 - - - central - Fake Maven Central Repository - file://dummy - - - - - maven-test - maven-test-b - 1.0 - jar - compile - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-b-1.0.pom b/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-b-1.0.pom deleted file mode 100644 index e814951a0dbb..000000000000 --- a/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-b-1.0.pom +++ /dev/null @@ -1,23 +0,0 @@ - - 4.0.0 - maven-test - maven-test-b - jar - 1.0 - - - maven-test - maven-test-c - 1.0 - jar - compile - - - maven-test - maven-test-d - 1.1 - jar - compile - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-c-1.0.pom b/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-c-1.0.pom deleted file mode 100644 index 4631b88f3c1c..000000000000 --- a/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-c-1.0.pom +++ /dev/null @@ -1,16 +0,0 @@ - - 4.0.0 - maven-test - maven-test-c - jar - 1.0 - - - maven-test - maven-test-d - 1.2 - jar - compile - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-d-1.1.pom b/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-d-1.1.pom deleted file mode 100644 index 6e22f6083ef2..000000000000 --- a/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-d-1.1.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - maven-test-d - jar - 1.1 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-d-1.2.pom b/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-d-1.2.pom deleted file mode 100644 index 6e22f6083ef2..000000000000 --- a/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-d-1.2.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - maven-test - maven-test-d - jar - 1.1 - \ No newline at end of file diff --git a/maven-compat/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-a-1.0-SNAPSHOT.jar b/maven-compat/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-a-1.0-SNAPSHOT.jar deleted file mode 100644 index c2c027fec1a7..000000000000 --- a/maven-compat/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-a-1.0-SNAPSHOT.jar +++ /dev/null @@ -1 +0,0 @@ -local \ No newline at end of file diff --git a/maven-compat/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-a-1.0-SNAPSHOT.jar.snapshot-version b/maven-compat/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-a-1.0-SNAPSHOT.jar.snapshot-version deleted file mode 100644 index 09f9180ff24b..000000000000 --- a/maven-compat/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-a-1.0-SNAPSHOT.jar.snapshot-version +++ /dev/null @@ -1 +0,0 @@ -20040101.101010 \ No newline at end of file diff --git a/maven-compat/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-b-1.0-SNAPSHOT.jar b/maven-compat/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-b-1.0-SNAPSHOT.jar deleted file mode 100644 index c2c027fec1a7..000000000000 --- a/maven-compat/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-b-1.0-SNAPSHOT.jar +++ /dev/null @@ -1 +0,0 @@ -local \ No newline at end of file diff --git a/maven-compat/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-b-1.0-SNAPSHOT.jar.snapshot-version b/maven-compat/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-b-1.0-SNAPSHOT.jar.snapshot-version deleted file mode 100644 index 09f9180ff24b..000000000000 --- a/maven-compat/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-b-1.0-SNAPSHOT.jar.snapshot-version +++ /dev/null @@ -1 +0,0 @@ -20040101.101010 \ No newline at end of file diff --git a/maven-compat/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-e-1.0-SNAPSHOT.jar b/maven-compat/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-e-1.0-SNAPSHOT.jar deleted file mode 100644 index c2c027fec1a7..000000000000 --- a/maven-compat/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-e-1.0-SNAPSHOT.jar +++ /dev/null @@ -1 +0,0 @@ -local \ No newline at end of file diff --git a/maven-compat/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-e-1.0-SNAPSHOT.jar.snapshot-version b/maven-compat/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-e-1.0-SNAPSHOT.jar.snapshot-version deleted file mode 100644 index 09f9180ff24b..000000000000 --- a/maven-compat/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-e-1.0-SNAPSHOT.jar.snapshot-version +++ /dev/null @@ -1 +0,0 @@ -20040101.101010 \ No newline at end of file diff --git a/maven-compat/src/test/resources/local-repo/snapshot-test/poms/maven-test-snapshot-resolving-1.0.pom b/maven-compat/src/test/resources/local-repo/snapshot-test/poms/maven-test-snapshot-resolving-1.0.pom deleted file mode 100644 index 64a075f4e98f..000000000000 --- a/maven-compat/src/test/resources/local-repo/snapshot-test/poms/maven-test-snapshot-resolving-1.0.pom +++ /dev/null @@ -1,49 +0,0 @@ - - snapshot-test - maven-test-snapshot-resolving - jar - - - central - Fake Maven Central Repository - file://dummy - - - - - snapshot-test - maven-snapshot-a - 1.0-SNAPSHOT - jar - compile - - - snapshot-test - maven-snapshot-b - 1.0-SNAPSHOT - jar - compile - - - snapshot-test - maven-snapshot-c - 1.0-SNAPSHOT - jar - compile - - - snapshot-test - maven-snapshot-d - 1.0-SNAPSHOT - jar - compile - - - snapshot-test - maven-snapshot-e - 1.0-SNAPSHOT - jar - compile - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/org/apache/maven/artifact/deployer/ArtifactDeployerTest.xml b/maven-compat/src/test/resources/org/apache/maven/artifact/deployer/ArtifactDeployerTest.xml deleted file mode 100644 index f7c381fe2cc0..000000000000 --- a/maven-compat/src/test/resources/org/apache/maven/artifact/deployer/ArtifactDeployerTest.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - diff --git a/maven-compat/src/test/resources/org/apache/maven/artifact/installer/ArtifactInstallerTest.xml b/maven-compat/src/test/resources/org/apache/maven/artifact/installer/ArtifactInstallerTest.xml deleted file mode 100644 index f7c381fe2cc0..000000000000 --- a/maven-compat/src/test/resources/org/apache/maven/artifact/installer/ArtifactInstallerTest.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - diff --git a/maven-compat/src/test/resources/org/apache/maven/artifact/manager/DefaultWagonManagerTest.xml b/maven-compat/src/test/resources/org/apache/maven/artifact/manager/DefaultWagonManagerTest.xml deleted file mode 100644 index 925022ef95f1..000000000000 --- a/maven-compat/src/test/resources/org/apache/maven/artifact/manager/DefaultWagonManagerTest.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - org.apache.maven.wagon.Wagon - a - org.apache.maven.artifact.manager.WagonA - - - org.apache.maven.wagon.Wagon - b1 - org.apache.maven.artifact.manager.WagonB - - - org.apache.maven.wagon.Wagon - b2 - org.apache.maven.artifact.manager.WagonB - - - org.apache.maven.wagon.Wagon - c - org.apache.maven.artifact.manager.WagonC - - - org.apache.maven.wagon.Wagon - string - org.apache.maven.artifact.manager.StringWagon - - - diff --git a/maven-compat/src/test/resources/org/apache/maven/artifact/resolver/ArtifactResolverTest.xml b/maven-compat/src/test/resources/org/apache/maven/artifact/resolver/ArtifactResolverTest.xml deleted file mode 100644 index 2b950859de03..000000000000 --- a/maven-compat/src/test/resources/org/apache/maven/artifact/resolver/ArtifactResolverTest.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - org.apache.maven.artifact.resolver.ArtifactResolver - default - org.apache.maven.artifact.resolver.DefaultArtifactResolver - false - - - org.codehaus.plexus.logging.Logger - default - logger - - - org.apache.maven.artifact.factory.ArtifactFactory - default - artifactFactory - - - org.apache.maven.artifact.resolver.ArtifactCollector - default - artifactCollector - - - org.apache.maven.artifact.resolver.ResolutionErrorHandler - default - resolutionErrorHandler - - - org.apache.maven.artifact.metadata.ArtifactMetadataSource - test - source - - - org.codehaus.plexus.PlexusContainer - default - container - - - org.apache.maven.plugin.LegacySupport - default - legacySupport - - - org.eclipse.aether.RepositorySystem - default - repoSystem - - - - - diff --git a/maven-compat/src/test/resources/org/apache/maven/artifact/resolver/ArtifactUpdatePolicyTest.xml b/maven-compat/src/test/resources/org/apache/maven/artifact/resolver/ArtifactUpdatePolicyTest.xml deleted file mode 100644 index b434d7b93dc8..000000000000 --- a/maven-compat/src/test/resources/org/apache/maven/artifact/resolver/ArtifactUpdatePolicyTest.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - org.apache.maven.wagon.Wagon - testfile - org.apache.maven.artifact.resolver.TestFileWagon - per-lookup - - - \ No newline at end of file diff --git a/maven-compat/src/test/resources/org/apache/maven/project/AbstractMavenProjectTestCase.xml b/maven-compat/src/test/resources/org/apache/maven/project/AbstractMavenProjectTestCase.xml deleted file mode 100644 index bcc291e17487..000000000000 --- a/maven-compat/src/test/resources/org/apache/maven/project/AbstractMavenProjectTestCase.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - org.apache.maven.lifecycle.LifeCyclePluginAnalyzer - org.apache.maven.project.EmptyLifecyclePluginAnalyzer - - - diff --git a/maven-compat/src/test/resources/pom.xml b/maven-compat/src/test/resources/pom.xml deleted file mode 100644 index 55dda42afb86..000000000000 --- a/maven-compat/src/test/resources/pom.xml +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - 4.0.0 - org.apache.maven - maven-core - jar - Maven - 2.0-SNAPSHOT - 2001 - - - org.apache.maven - maven-model - 2.0-SNAPSHOT - jar - compile - - - org.apache.maven - maven-plugin - 2.0-SNAPSHOT - jar - compile - - - commons-cli - commons-cli - 1.0-beta-2 - jar - compile - - - plexus - plexus-i18n - 1.0-beta-2-SNAPSHOT - jar - compile - - - ognl - ognl - 2.5.1 - jar - compile - - - marmalade - marmalade-core - 0.1 - jar - compile - - - marmalade - marmalade-el-ognl - 0.1 - jar - compile - - - plexus - plexus-compiler-api - 1.0 - jar - compile - - - plexus - plexus-compiler-javac - 1.0 - jar - compile - - - surefire - surefire-booter - 1.1 - jar - compile - - - maven - wagon-api - 0.9-SNAPSHOT - jar - compile - - - org.apache.maven - wagon-http-lightweight - 0.9-SNAPSHOT - jar - compile - - - maven - wagon-ssh - 0.9-SNAPSHOT - jar - compile - - - jsch - jsch - 0.1.14 - jar - compile - - - qdox - qdox - 1.2 - jar - compile - - - diff --git a/maven-compat/src/test/resources/projects/scope/project-with-scoped-dependencies.xml b/maven-compat/src/test/resources/projects/scope/project-with-scoped-dependencies.xml deleted file mode 100644 index c706250170c7..000000000000 --- a/maven-compat/src/test/resources/projects/scope/project-with-scoped-dependencies.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - 4.0.0 - maven - maven-project-test - Maven - 1.0-beta-9 - - - - maven-test - scope-default - 1.0 - - - - maven-test - scope-test - 1.0 - test - - - - maven-test - scope-runtime - 1.0 - runtime - - - - maven-test - scope-compile - 1.0 - compile - - - - maven-test - scope-provided - 1.0 - provided - - - - maven-inherited - scope-default - 1.0 - - - - maven-inherited - scope-compile - 1.0 - compile - - - - maven-inherited - scope-runtime - 1.0 - runtime - - - - maven-inherited - scope-test - 1.0 - test - - - - maven-inherited - scope-provided - 1.0 - provided - - - - diff --git a/maven-compat/src/test/resources/projects/scope/transitive-compile-dep.xml b/maven-compat/src/test/resources/projects/scope/transitive-compile-dep.xml deleted file mode 100644 index 1161c6986810..000000000000 --- a/maven-compat/src/test/resources/projects/scope/transitive-compile-dep.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - 4.0.0 - maven-test - scope-compile - 1.0 - - - - maven-test-compile - scope-default - 1.0 - - - - maven-test-compile - scope-test - 1.0 - test - - - - maven-test-compile - scope-runtime - 1.0 - runtime - - - - maven-test-compile - scope-compile - 1.0 - compile - - - - diff --git a/maven-compat/src/test/resources/projects/scope/transitive-default-dep.xml b/maven-compat/src/test/resources/projects/scope/transitive-default-dep.xml deleted file mode 100644 index c904be0ef9ae..000000000000 --- a/maven-compat/src/test/resources/projects/scope/transitive-default-dep.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - 4.0.0 - maven-test - scope-default - 1.0 - - - - maven-test-default - scope-default - 1.0 - - - - maven-test-default - scope-test - 1.0 - test - - - - maven-test-default - scope-runtime - 1.0 - runtime - - - - maven-test-default - scope-compile - 1.0 - compile - - - - - diff --git a/maven-compat/src/test/resources/projects/scope/transitive-provided-dep.xml b/maven-compat/src/test/resources/projects/scope/transitive-provided-dep.xml deleted file mode 100644 index b85669ce033e..000000000000 --- a/maven-compat/src/test/resources/projects/scope/transitive-provided-dep.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - 4.0.0 - maven-test - scope-provided - 1.0 - - - - maven-test-provided - scope-default - 1.0 - - - - maven-test-provided - scope-test - 1.0 - test - - - - maven-test-provided - scope-runtime - 1.0 - runtime - - - - maven-test-provided - scope-compile - 1.0 - compile - - - - diff --git a/maven-compat/src/test/resources/projects/scope/transitive-runtime-dep.xml b/maven-compat/src/test/resources/projects/scope/transitive-runtime-dep.xml deleted file mode 100644 index 921723c7e0fb..000000000000 --- a/maven-compat/src/test/resources/projects/scope/transitive-runtime-dep.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - 4.0.0 - maven-test - scope-runtime - 1.0 - - - - maven-test-runtime - scope-default - 1.0 - - - - maven-test-runtime - scope-test - 1.0 - test - - - - maven-test-runtime - scope-runtime - 1.0 - runtime - - - - maven-test-runtime - scope-compile - 1.0 - compile - - - - - diff --git a/maven-compat/src/test/resources/projects/scope/transitive-test-dep.xml b/maven-compat/src/test/resources/projects/scope/transitive-test-dep.xml deleted file mode 100644 index ea2dde9f48c0..000000000000 --- a/maven-compat/src/test/resources/projects/scope/transitive-test-dep.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - 4.0.0 - maven-test - scope-test - 1.0 - - - - maven-test-test - scope-default - 1.0 - - - - maven-test-test - scope-test - 1.0 - test - - - - maven-test-test - scope-runtime - 1.0 - runtime - - - - maven-test-test - scope-compile - 1.0 - compile - - - - - diff --git a/maven-core/pom.xml b/maven-core/pom.xml index 1ff00fa3aaa5..53b2998a42fa 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -181,6 +181,10 @@ under the License. plexus-testing test + + org.apache.maven.wagon + wagon-provider-api + diff --git a/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java b/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java deleted file mode 100644 index 0ee0bee02910..000000000000 --- a/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java +++ /dev/null @@ -1,225 +0,0 @@ -package org.apache.maven; - -/* - * 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.HashSet; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; -import org.apache.maven.artifact.resolver.ArtifactResolutionResult; -import org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException; -import org.apache.maven.artifact.resolver.ResolutionErrorHandler; -import org.apache.maven.artifact.resolver.filter.CumulativeScopeArtifactFilter; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.artifact.ProjectArtifact; -import org.apache.maven.repository.RepositorySystem; - -/** - * @deprecated As of 3.2.2, and there is no direct replacement. This is an internal class which was not marked as such, - * but should have been. - * - */ -@Deprecated -@Named -@Singleton -public class DefaultProjectDependenciesResolver - implements ProjectDependenciesResolver -{ - - @Inject - private RepositorySystem repositorySystem; - - @Inject - private ResolutionErrorHandler resolutionErrorHandler; - - public Set resolve( MavenProject project, Collection scopesToResolve, MavenSession session ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - return resolve( Collections.singleton( project ), scopesToResolve, session ); - } - - public Set resolve( MavenProject project, Collection scopesToCollect, - Collection scopesToResolve, MavenSession session ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - Set mavenProjects = Collections.singleton( project ); - return resolveImpl( mavenProjects, scopesToCollect, scopesToResolve, session, - getIgnorableArtifacts( mavenProjects ) ); - } - - public Set resolve( Collection projects, Collection scopesToResolve, - MavenSession session ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - return resolveImpl( projects, null, scopesToResolve, session, getIgnorableArtifacts( projects ) ); - } - - public Set resolve( MavenProject project, Collection scopesToCollect, - Collection scopesToResolve, MavenSession session, - Set ignoreableArtifacts ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - return resolveImpl( Collections.singleton( project ), scopesToCollect, scopesToResolve, session, - getIgnorableArtifacts( ignoreableArtifacts ) ); - } - - - private Set resolveImpl( Collection projects, Collection scopesToCollect, - Collection scopesToResolve, MavenSession session, - Set projectIds ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - Set resolved = new LinkedHashSet<>(); - - if ( projects == null || projects.isEmpty() ) - { - return resolved; - } - - if ( ( scopesToCollect == null || scopesToCollect.isEmpty() ) - && ( scopesToResolve == null || scopesToResolve.isEmpty() ) ) - { - return resolved; - } - - /* - - Logic for transitive global exclusions - - List exclusions = new ArrayList(); - - for ( Dependency d : project.getDependencies() ) - { - if ( d.getExclusions() != null ) - { - for ( Exclusion e : d.getExclusions() ) - { - exclusions.add( e.getGroupId() + ":" + e.getArtifactId() ); - } - } - } - - ArtifactFilter scopeFilter = new ScopeArtifactFilter( scope ); - - ArtifactFilter filter; - - if ( ! exclusions.isEmpty() ) - { - filter = new AndArtifactFilter( Arrays.asList( new ArtifactFilter[]{ - new ExcludesArtifactFilter( exclusions ), scopeFilter } ) ); - } - else - { - filter = scopeFilter; - } - */ - - CumulativeScopeArtifactFilter resolutionScopeFilter = new CumulativeScopeArtifactFilter( scopesToResolve ); - - CumulativeScopeArtifactFilter collectionScopeFilter = new CumulativeScopeArtifactFilter( scopesToCollect ); - collectionScopeFilter = new CumulativeScopeArtifactFilter( collectionScopeFilter, resolutionScopeFilter ); - - ArtifactResolutionRequest request = - new ArtifactResolutionRequest().setResolveRoot( false ).setResolveTransitively( true ).setCollectionFilter( - collectionScopeFilter ).setResolutionFilter( resolutionScopeFilter ).setLocalRepository( - session.getLocalRepository() ).setOffline( session.isOffline() ).setForceUpdate( - session.getRequest().isUpdateSnapshots() ); - request.setServers( session.getRequest().getServers() ); - request.setMirrors( session.getRequest().getMirrors() ); - request.setProxies( session.getRequest().getProxies() ); - - for ( MavenProject project : projects ) - { - request.setArtifact( new ProjectArtifact( project ) ); - request.setArtifactDependencies( project.getDependencyArtifacts() ); - request.setManagedVersionMap( project.getManagedVersionMap() ); - request.setRemoteRepositories( project.getRemoteArtifactRepositories() ); - - ArtifactResolutionResult result = repositorySystem.resolve( request ); - - try - { - resolutionErrorHandler.throwErrors( request, result ); - } - catch ( MultipleArtifactsNotFoundException e ) - { - - Collection missing = new HashSet<>( e.getMissingArtifacts() ); - - for ( Iterator it = missing.iterator(); it.hasNext(); ) - { - String key = ArtifactUtils.key( it.next() ); - if ( projectIds.contains( key ) ) - { - it.remove(); - } - } - - if ( !missing.isEmpty() ) - { - throw e; - } - } - - resolved.addAll( result.getArtifacts() ); - } - - return resolved; - } - - - private Set getIgnorableArtifacts( Collection projects ) - { - Set projectIds = new HashSet<>( projects.size() * 2 ); - - for ( MavenProject p : projects ) - { - String key = ArtifactUtils.key( p.getGroupId(), p.getArtifactId(), p.getVersion() ); - projectIds.add( key ); - } - return projectIds; - } - - private Set getIgnorableArtifacts( Iterable artifactIterable ) - { - Set projectIds = new HashSet<>(); - - for ( Artifact artifact : artifactIterable ) - { - String key = ArtifactUtils.key( artifact ); - projectIds.add( key ); - } - return projectIds; - } - -} diff --git a/maven-core/src/main/java/org/apache/maven/ProjectDependenciesResolver.java b/maven-core/src/main/java/org/apache/maven/ProjectDependenciesResolver.java deleted file mode 100644 index f7a524439200..000000000000 --- a/maven-core/src/main/java/org/apache/maven/ProjectDependenciesResolver.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.apache.maven; - -/* - * 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.Set; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.project.MavenProject; - -/** - * @deprecated As of 3.2.2, and there is no direct replacement. This is an internal class which was not marked as such, - * but should have been. - * @author jvanzyl - * - */ -@Deprecated -public interface ProjectDependenciesResolver -{ - - /** - * Resolves the transitive dependencies of the specified project. - * - * @param project The project whose dependencies should be resolved, must not be {@code null}. - * @param scopesToResolve The dependency scopes that should be resolved, may be {@code null}. - * @param session The current build session, must not be {@code null}. - * @return The transitive dependencies of the specified project that match the requested scopes, never {@code null}. - */ - Set resolve( MavenProject project, Collection scopesToResolve, MavenSession session ) - throws ArtifactResolutionException, ArtifactNotFoundException; - - /** - * Resolves the transitive dependencies of the specified project. - * - * @param project The project whose dependencies should be resolved, must not be {@code null}. - * @param scopesToCollect The dependency scopes that should be collected, may be {@code null}. - * @param scopesToResolve The dependency scopes that should be collected and also resolved, may be {@code null}. - * @param session The current build session, must not be {@code null}. - * @return The transitive dependencies of the specified project that match the requested scopes, never {@code null}. - */ - Set resolve( MavenProject project, Collection scopesToCollect, - Collection scopesToResolve, MavenSession session ) - throws ArtifactResolutionException, ArtifactNotFoundException; - - /** - * Resolves the transitive dependencies of the specified project. - * - * @param project The project whose dependencies should be resolved, must not be {@code null}. - * @param scopesToCollect The dependency scopes that should be collected, may be {@code null}. - * @param scopesToResolve The dependency scopes that should be collected and also resolved, may be {@code null}. - * @param session The current build session, must not be {@code null}. - * @param ignoreableArtifacts Artifacts that need not be resolved - * @return The transitive dependencies of the specified project that match the requested scopes, never {@code null}. - */ - Set resolve( MavenProject project, Collection scopesToCollect, - Collection scopesToResolve, MavenSession session, Set ignoreableArtifacts ) - throws ArtifactResolutionException, ArtifactNotFoundException; - - /** - * Resolves the transitive dependencies of the specified projects. Note that dependencies which can't be resolved - * from any repository but are present among the set of specified projects will not cause an exception. Instead, - * those unresolved artifacts will be returned in the result set, allowing the caller to take special care of - * artifacts that haven't been build yet. - * - * @param projects The projects whose dependencies should be resolved, may be {@code null}. - * @param scopes The dependency scopes that should be resolved, may be {@code null}. - * @param session The current build session, must not be {@code null}. - * @return The transitive dependencies of the specified projects that match the requested scopes, never - * {@code null}. - */ - Set resolve( Collection projects, Collection scopes, - MavenSession session ) - throws ArtifactResolutionException, ArtifactNotFoundException; - -} diff --git a/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java b/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java index f6b83c002b73..6c495014e0c6 100644 --- a/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java +++ b/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java @@ -55,7 +55,6 @@ import org.apache.maven.model.Dependency; import org.apache.maven.model.Plugin; import org.apache.maven.repository.Proxy; -import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Mirror; import org.codehaus.plexus.util.StringUtils; import org.eclipse.aether.RepositorySystemSession; @@ -71,6 +70,21 @@ @Singleton public class MavenRepositorySystem { + public static final String DEFAULT_LOCAL_REPO_ID = "local"; + + @SuppressWarnings( "checkstyle:constantname" ) + public static final String userHome = System.getProperty( "user.home" ); + + @SuppressWarnings( "checkstyle:constantname" ) + public static final File userMavenConfigurationHome = new File( userHome, ".m2" ); + + @SuppressWarnings( "checkstyle:constantname" ) + public static final File defaultUserLocalRepository = new File( userMavenConfigurationHome, "repository" ); + + public static final String DEFAULT_REMOTE_REPO_ID = "central"; + + public static final String DEFAULT_REMOTE_REPO_URL = "https://repo.maven.apache.org/maven2"; + private final ArtifactHandlerManager artifactHandlerManager; private final Map layouts; @@ -173,6 +187,12 @@ public Artifact createPluginArtifact( Plugin plugin ) return createPluginArtifactX( plugin.getGroupId(), plugin.getArtifactId(), versionRange ); } + public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, + String type, String classifier ) + { + return createArtifactX( groupId, artifactId, version, type, null, classifier, null ); + } + public void injectMirror( List repositories, List mirrors ) { if ( repositories != null && mirrors != null ) @@ -427,7 +447,7 @@ public static ArtifactRepositoryPolicy buildArtifactRepositoryPolicy( org.apache public ArtifactRepository createArtifactRepository( String id, String url, String layoutId, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ) - throws Exception + throws InvalidRepositoryException { ArtifactRepositoryLayout layout = layouts.get( layoutId ); @@ -437,12 +457,13 @@ public ArtifactRepository createArtifactRepository( String id, String url, Strin } private void checkLayout( String repositoryId, String layoutId, ArtifactRepositoryLayout layout ) - throws Exception + throws InvalidRepositoryException { if ( layout == null ) { - throw new Exception( String.format( "Cannot find ArtifactRepositoryLayout instance for: %s %s", layoutId, - repositoryId ) ); + throw new InvalidRepositoryException( + String.format( "Cannot find ArtifactRepositoryLayout instance for: %s %s", layoutId, repositoryId ), + repositoryId ); } } @@ -577,9 +598,9 @@ else if ( Artifact.SCOPE_COMPILE.equals( scope ) && Artifact.SCOPE_COMPILE.equal // public ArtifactRepository createDefaultRemoteRepository( MavenExecutionRequest request ) - throws Exception + throws InvalidRepositoryException { - return createRepository( RepositorySystem.DEFAULT_REMOTE_REPO_URL, RepositorySystem.DEFAULT_REMOTE_REPO_ID, + return createRepository( DEFAULT_REMOTE_REPO_URL, DEFAULT_REMOTE_REPO_ID, true, ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY, false, ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY, ArtifactRepositoryPolicy.DEFAULT_CHECKSUM_POLICY ); @@ -587,7 +608,7 @@ public ArtifactRepository createDefaultRemoteRepository( MavenExecutionRequest r public ArtifactRepository createRepository( String url, String repositoryId, boolean releases, String releaseUpdates, boolean snapshots, String snapshotUpdates, - String checksumPolicy ) throws Exception + String checksumPolicy ) throws InvalidRepositoryException { ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy( snapshots, snapshotUpdates, checksumPolicy ); @@ -705,10 +726,10 @@ private ArtifactRepositoryPolicy getEffectivePolicy( CollectionBrett Porter * @author Jason van Zyl */ -@Component( role = LegacyArtifactCollector.class ) -public class DefaultLegacyArtifactCollector - implements LegacyArtifactCollector +@Singleton +class ArtifactCollector { - @Requirement( hint = "nearest" ) + @Inject @Named( "nearest" ) private ConflictResolver defaultConflictResolver; - @Requirement + @Inject private Logger logger; - @Requirement + @Inject private LegacySupport legacySupport; private void injectSession( ArtifactResolutionRequest request ) @@ -87,22 +85,6 @@ private void injectSession( ArtifactResolutionRequest request ) } } - @SuppressWarnings( "checkstyle:parameternumber" ) - public ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, - Map managedVersions, ArtifactRepository localRepository, - List remoteRepositories, - ArtifactMetadataSource source, ArtifactFilter filter, - List listeners, - List conflictResolvers ) - { - ArtifactResolutionRequest request = new ArtifactResolutionRequest(); - request.setLocalRepository( localRepository ); - request.setRemoteRepositories( remoteRepositories ); - injectSession( request ); - return collect( artifacts, originatingArtifact, managedVersions, request, source, filter, listeners, - conflictResolvers ); - } - @SuppressWarnings( "checkstyle:parameternumber" ) public ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, Map managedVersions, @@ -141,7 +123,7 @@ public ArtifactResolutionResult collect( Set artifacts, Artifact origi return result; } - ManagedVersionMap versionMap = getManagedVersionsMap( originatingArtifact, managedVersions ); + Map versionMap = getManagedVersionsMap( originatingArtifact, managedVersions ); try { @@ -210,7 +192,7 @@ public ArtifactResolutionResult collect( Set artifacts, Artifact origi * @param originatingArtifact artifact we are processing * @param managedVersions original managed versions */ - private ManagedVersionMap getManagedVersionsMap( Artifact originatingArtifact, + private Map getManagedVersionsMap( Artifact originatingArtifact, Map managedVersions ) { ManagedVersionMap versionMap; @@ -243,7 +225,7 @@ private ManagedVersionMap getManagedVersionsMap( Artifact originatingArtifact, @SuppressWarnings( { "checkstyle:parameternumber", "checkstyle:methodlength" } ) private void recurse( ArtifactResolutionResult result, ResolutionNode node, - Map> resolvedArtifacts, ManagedVersionMap managedVersions, + Map> resolvedArtifacts, Map managedVersions, ArtifactResolutionRequest request, ArtifactMetadataSource source, ArtifactFilter filter, List listeners, List conflictResolvers ) throws ArtifactResolutionException @@ -621,7 +603,7 @@ private void recurse( ArtifactResolutionResult result, ResolutionNode node, } } - private void manageArtifact( ResolutionNode node, ManagedVersionMap managedVersions, + private void manageArtifact( ResolutionNode node, Map managedVersions, List listeners ) { Artifact artifact = managedVersions.get( node.getKey() ); @@ -695,7 +677,7 @@ boolean checkScopeUpdate( ResolutionNode farthest, ResolutionNode nearest, List< fireEvent( ResolutionListener.UPDATE_SCOPE, listeners, nearest, farthestArtifact ); // previously we cloned the artifact, but it is more efficient to just update the artifactScope - // if problems are later discovered that the original object needs its original artifactScope value, + // if problems are later discovered that the original object needs its original artifactScope value, // cloning may // again be appropriate nearestArtifact.setScope( farthestArtifact.getScope() ); @@ -794,25 +776,4 @@ private void fireEvent( int event, List listeners, Resolutio } } - @SuppressWarnings( "checkstyle:parameternumber" ) - public ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, - Map managedVersions, ArtifactRepository localRepository, - List remoteRepositories, - ArtifactMetadataSource source, ArtifactFilter filter, - List listeners ) - { - return collect( artifacts, originatingArtifact, managedVersions, localRepository, remoteRepositories, source, - filter, listeners, null ); - } - - public ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, - ArtifactRepository localRepository, - List remoteRepositories, - ArtifactMetadataSource source, ArtifactFilter filter, - List listeners ) - { - return collect( artifacts, originatingArtifact, null, localRepository, remoteRepositories, source, filter, - listeners ); - } - } diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java b/maven-core/src/main/java/org/apache/maven/bridge/legacy/ArtifactResolver.java similarity index 63% rename from maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java rename to maven-core/src/main/java/org/apache/maven/bridge/legacy/ArtifactResolver.java index 45dcb5f4509e..638ac05725b7 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java +++ b/maven-core/src/main/java/org/apache/maven/bridge/legacy/ArtifactResolver.java @@ -1,4 +1,4 @@ -package org.apache.maven.artifact.resolver; +package org.apache.maven.bridge.legacy; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -21,7 +21,6 @@ import java.io.File; import java.util.ArrayList; -import java.util.Collections; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; @@ -37,30 +36,31 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Matcher; +import javax.annotation.PreDestroy; +import javax.inject.Inject; +import javax.inject.Singleton; + import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.LegacyLocalRepositoryManager; -import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.repository.metadata.Snapshot; -import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; +import org.apache.maven.artifact.resolver.ArtifactNotFoundException; +import org.apache.maven.artifact.resolver.ArtifactResolutionException; +import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; +import org.apache.maven.artifact.resolver.ArtifactResolutionResult; +import org.apache.maven.artifact.resolver.ResolutionListener; +import org.apache.maven.artifact.resolver.ResolutionNode; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; -import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.repository.legacy.metadata.DefaultMetadataResolutionRequest; import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; -import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver; -import org.apache.maven.wagon.events.TransferListener; import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.LocalRepositoryManager; @@ -70,47 +70,46 @@ /** * @author Jason van Zyl */ -@Component( role = ArtifactResolver.class ) -public class DefaultArtifactResolver - implements ArtifactResolver, Disposable +@Singleton +class ArtifactResolver { - @Requirement + @Inject private Logger logger; - @Requirement - protected ArtifactFactory artifactFactory; - - @Requirement + @Inject private ArtifactCollector artifactCollector; - @Requirement - private ResolutionErrorHandler resolutionErrorHandler; - - @Requirement + @Inject private ArtifactMetadataSource source; - @Requirement + @Inject private PlexusContainer container; - @Requirement + @Inject private LegacySupport legacySupport; - @Requirement + @Inject private RepositorySystem repoSystem; private final Executor executor; - public DefaultArtifactResolver() + ArtifactResolver() { int threads = Integer.getInteger( "maven.artifact.threads", 5 ); if ( threads <= 1 ) { - executor = Runnable::run; + executor = new Executor() + { + public void execute( Runnable command ) + { + command.run(); + } + }; } else { executor = new ThreadPoolExecutor( threads, threads, 3, TimeUnit.SECONDS, - new LinkedBlockingQueue<>(), new DaemonThreadCreator() ); + new LinkedBlockingQueue(), new DaemonThreadCreator() ); } } @@ -120,41 +119,6 @@ private RepositorySystemSession getSession( ArtifactRepository localRepository ) repoSystem ); } - private void injectSession1( RepositoryRequest request, MavenSession session ) - { - if ( session != null ) - { - request.setOffline( session.isOffline() ); - request.setForceUpdate( session.getRequest().isUpdateSnapshots() ); - } - } - - private void injectSession2( ArtifactResolutionRequest request, MavenSession session ) - { - injectSession1( request, session ); - - if ( session != null ) - { - request.setServers( session.getRequest().getServers() ); - request.setMirrors( session.getRequest().getMirrors() ); - request.setProxies( session.getRequest().getProxies() ); - } - } - - public void resolve( Artifact artifact, List remoteRepositories, - ArtifactRepository localRepository, TransferListener resolutionListener ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - resolve( artifact, remoteRepositories, getSession( localRepository ) ); - } - - public void resolveAlways( Artifact artifact, List remoteRepositories, - ArtifactRepository localRepository ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - resolve( artifact, remoteRepositories, getSession( localRepository ) ); - } - private void resolve( Artifact artifact, List remoteRepositories, RepositorySystemSession session ) throws ArtifactResolutionException, ArtifactNotFoundException @@ -245,121 +209,6 @@ private void resolve( Artifact artifact, List remoteReposito } } - public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, - ArtifactRepository localRepository, - List remoteRepositories, - ArtifactMetadataSource source, ArtifactFilter filter ) - throws ArtifactResolutionException, - ArtifactNotFoundException - { - return resolveTransitively( - artifacts, originatingArtifact, Collections.emptyMap(), localRepository, - remoteRepositories, source, filter ); - - } - - public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, - Map managedVersions, - ArtifactRepository localRepository, - List remoteRepositories, - ArtifactMetadataSource source ) - throws ArtifactResolutionException, - ArtifactNotFoundException - { - return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository, - remoteRepositories, source, null ); - } - - public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, - Map managedVersions, - ArtifactRepository localRepository, - List remoteRepositories, - ArtifactMetadataSource source, ArtifactFilter filter ) - throws ArtifactResolutionException, - ArtifactNotFoundException - { - return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository, - remoteRepositories, source, filter, null ); - } - - public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, - List remoteRepositories, - ArtifactRepository localRepository, - ArtifactMetadataSource source ) - throws ArtifactResolutionException, - ArtifactNotFoundException - { - return resolveTransitively( artifacts, originatingArtifact, localRepository, remoteRepositories, source, null ); - } - - public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, - List remoteRepositories, - ArtifactRepository localRepository, - ArtifactMetadataSource source, - List listeners ) - throws ArtifactResolutionException, - ArtifactNotFoundException - { - return resolveTransitively( - artifacts, originatingArtifact, Collections.emptyMap(), localRepository, - remoteRepositories, source, null, listeners ); - } - - @SuppressWarnings( "checkstyle:parameternumber" ) - public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, - Map managedVersions, - ArtifactRepository localRepository, - List remoteRepositories, - ArtifactMetadataSource source, ArtifactFilter filter, - List listeners ) - throws ArtifactResolutionException, - ArtifactNotFoundException - { - return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository, - remoteRepositories, source, filter, listeners, null ); - } - - @SuppressWarnings( "checkstyle:parameternumber" ) - public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, - Map managedVersions, - ArtifactRepository localRepository, - List remoteRepositories, - ArtifactMetadataSource source, ArtifactFilter filter, - List listeners, - List conflictResolvers ) - throws ArtifactResolutionException, - ArtifactNotFoundException - { - ArtifactResolutionRequest request = new ArtifactResolutionRequest(). - setArtifact( originatingArtifact ). - setResolveRoot( false ). - // This is required by the surefire plugin - setArtifactDependencies( artifacts ). - setManagedVersionMap( managedVersions ). - setLocalRepository( localRepository ). - setRemoteRepositories( remoteRepositories ). - setCollectionFilter( filter ). - setListeners( listeners ); - - injectSession2( request, legacySupport.getSession() ); - - return resolveWithExceptions( request ); - } - - public ArtifactResolutionResult resolveWithExceptions( ArtifactResolutionRequest request ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - ArtifactResolutionResult result = resolve( request ); - - // We have collected all the problems so let's mimic the way the old code worked and just blow up right here. - // That's right lets just let it rip right here and send a big incomprehensible blob of text at unsuspecting - // users. Bad dog! - - resolutionErrorHandler.throwErrors( request, result ); - - return result; - } - // ------------------------------------------------------------------------ // // ------------------------------------------------------------------------ @@ -397,8 +246,6 @@ public ArtifactResolutionResult resolve( ArtifactResolutionRequest request ) { listeners.add( new DebugResolutionListener( logger ) ); } - - listeners.add( new WarningResolutionListener( logger ) ); } ArtifactResolutionResult result = new ArtifactResolutionResult(); @@ -554,13 +401,6 @@ public ArtifactResolutionResult resolve( ArtifactResolutionRequest request ) return result; } - public void resolve( Artifact artifact, List remoteRepositories, - ArtifactRepository localRepository ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - resolve( artifact, remoteRepositories, localRepository, null ); - } - /** * ThreadCreator for creating daemon threads with fixed ThreadGroup-name. */ @@ -648,7 +488,7 @@ public void run() } - @Override + @PreDestroy public void dispose() { if ( executor instanceof ExecutorService ) diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/ChecksumFailedException.java b/maven-core/src/main/java/org/apache/maven/bridge/legacy/ChecksumFailedException.java similarity index 82% rename from maven-compat/src/main/java/org/apache/maven/repository/legacy/ChecksumFailedException.java rename to maven-core/src/main/java/org/apache/maven/bridge/legacy/ChecksumFailedException.java index 4e0c4a6bfc61..c885af3a1e26 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/ChecksumFailedException.java +++ b/maven-core/src/main/java/org/apache/maven/bridge/legacy/ChecksumFailedException.java @@ -1,4 +1,4 @@ -package org.apache.maven.repository.legacy; +package org.apache.maven.bridge.legacy; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -26,16 +26,16 @@ * * @author Brett Porter */ -public class ChecksumFailedException +class ChecksumFailedException extends TransferFailedException { - public ChecksumFailedException( String s ) + ChecksumFailedException( String s ) { super( s ); } - public ChecksumFailedException( String message, - Throwable cause ) + ChecksumFailedException( String message, + Throwable cause ) { super( message, cause ); } diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/ConflictResolver.java b/maven-core/src/main/java/org/apache/maven/bridge/legacy/ConflictResolver.java similarity index 94% rename from maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/ConflictResolver.java rename to maven-core/src/main/java/org/apache/maven/bridge/legacy/ConflictResolver.java index 4d129b7e765a..894b680c33b4 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/ConflictResolver.java +++ b/maven-core/src/main/java/org/apache/maven/bridge/legacy/ConflictResolver.java @@ -1,4 +1,4 @@ -package org.apache.maven.repository.legacy.resolver.conflict; +package org.apache.maven.bridge.legacy; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -27,7 +27,7 @@ * @author Jason van Zyl * @author Mark Hobson */ -public interface ConflictResolver +interface ConflictResolver { String ROLE = ConflictResolver.class.getName(); diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DebugResolutionListener.java b/maven-core/src/main/java/org/apache/maven/bridge/legacy/DebugResolutionListener.java similarity index 97% rename from maven-compat/src/main/java/org/apache/maven/artifact/resolver/DebugResolutionListener.java rename to maven-core/src/main/java/org/apache/maven/bridge/legacy/DebugResolutionListener.java index 56c1805cd29e..08de006588e0 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DebugResolutionListener.java +++ b/maven-core/src/main/java/org/apache/maven/bridge/legacy/DebugResolutionListener.java @@ -1,4 +1,4 @@ -package org.apache.maven.artifact.resolver; +package org.apache.maven.bridge.legacy; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -24,6 +24,7 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.resolver.ResolutionListener; import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.plexus.logging.Logger; @@ -32,7 +33,7 @@ * * @author Brett Porter */ -public class DebugResolutionListener +class DebugResolutionListener implements ResolutionListener, ResolutionListenerForDepMgmt { private Logger logger; @@ -41,7 +42,7 @@ public class DebugResolutionListener private static Set ignoredArtifacts = new HashSet<>(); - public DebugResolutionListener( Logger logger ) + DebugResolutionListener( Logger logger ) { this.logger = logger; } diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/versioning/ManagedVersionMap.java b/maven-core/src/main/java/org/apache/maven/bridge/legacy/ManagedVersionMap.java similarity index 91% rename from maven-compat/src/main/java/org/apache/maven/artifact/versioning/ManagedVersionMap.java rename to maven-core/src/main/java/org/apache/maven/bridge/legacy/ManagedVersionMap.java index c098d7fdea0d..8385bc27ad83 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/versioning/ManagedVersionMap.java +++ b/maven-core/src/main/java/org/apache/maven/bridge/legacy/ManagedVersionMap.java @@ -1,4 +1,4 @@ -package org.apache.maven.artifact.versioning; +package org.apache.maven.bridge.legacy; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -28,11 +28,10 @@ /** * ManagedVersionMap */ -@Deprecated -public class ManagedVersionMap +class ManagedVersionMap extends HashMap { - public ManagedVersionMap( Map map ) + ManagedVersionMap( Map map ) { super(); if ( map != null ) diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/MavenArtifact.java b/maven-core/src/main/java/org/apache/maven/bridge/legacy/MavenArtifact.java similarity index 98% rename from maven-compat/src/main/java/org/apache/maven/repository/legacy/MavenArtifact.java rename to maven-core/src/main/java/org/apache/maven/bridge/legacy/MavenArtifact.java index 07d2cdb67f55..d09fac3ed698 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/MavenArtifact.java +++ b/maven-core/src/main/java/org/apache/maven/bridge/legacy/MavenArtifact.java @@ -1,4 +1,4 @@ -package org.apache.maven.repository.legacy; +package org.apache.maven.bridge.legacy; /* * Licensed to the Apache Software Foundation (ASF) under one diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/NearestConflictResolver.java b/maven-core/src/main/java/org/apache/maven/bridge/legacy/NearestConflictResolver.java similarity index 90% rename from maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/NearestConflictResolver.java rename to maven-core/src/main/java/org/apache/maven/bridge/legacy/NearestConflictResolver.java index 338baed613bd..cc774b239ff3 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/NearestConflictResolver.java +++ b/maven-core/src/main/java/org/apache/maven/bridge/legacy/NearestConflictResolver.java @@ -1,4 +1,4 @@ -package org.apache.maven.repository.legacy.resolver.conflict; +package org.apache.maven.bridge.legacy; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -19,8 +19,10 @@ * under the License. */ +import javax.inject.Named; +import javax.inject.Singleton; + import org.apache.maven.artifact.resolver.ResolutionNode; -import org.codehaus.plexus.component.annotations.Component; /** * Resolves conflicting artifacts by always selecting the nearest declaration. Nearest is defined as the @@ -30,7 +32,8 @@ * @author Mark Hobson * @since 3.0 */ -@Component( role = ConflictResolver.class, hint = "nearest" ) +@Singleton +@Named( "nearest" ) public class NearestConflictResolver implements ConflictResolver { diff --git a/maven-core/src/main/java/org/apache/maven/bridge/legacy/RepositorySystemImpl.java b/maven-core/src/main/java/org/apache/maven/bridge/legacy/RepositorySystemImpl.java new file mode 100644 index 000000000000..acc8fb4a8b4d --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/bridge/legacy/RepositorySystemImpl.java @@ -0,0 +1,389 @@ +package org.apache.maven.bridge.legacy; + +/* + * 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.HashMap; +import java.util.List; +import java.util.Map; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.InvalidRepositoryException; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; +import org.apache.maven.artifact.repository.Authentication; +import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; +import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; +import org.apache.maven.artifact.resolver.ArtifactResolutionResult; +import org.apache.maven.bridge.MavenRepositorySystem; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.Repository; +import org.apache.maven.repository.ArtifactDoesNotExistException; +import org.apache.maven.repository.ArtifactTransferFailedException; +import org.apache.maven.repository.ArtifactTransferListener; +import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.settings.Mirror; +import org.apache.maven.settings.Proxy; +import org.apache.maven.settings.Server; +import org.apache.maven.settings.building.SettingsProblem; +import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest; +import org.apache.maven.settings.crypto.SettingsDecrypter; +import org.apache.maven.settings.crypto.SettingsDecryptionRequest; +import org.apache.maven.settings.crypto.SettingsDecryptionResult; +import org.apache.maven.wagon.proxy.ProxyInfo; +import org.apache.maven.wagon.proxy.ProxyUtils; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.logging.Logger; +import org.codehaus.plexus.util.StringUtils; +import org.eclipse.aether.RepositorySystemSession; + +@Singleton +@Named +public class RepositorySystemImpl implements RepositorySystem +{ + + private final Logger logger; + private final MavenRepositorySystem mrs; + private final PlexusContainer plexus; + private final ArtifactResolver artifactResolver; + private final WagonManager wagonManager; + private final SettingsDecrypter settingsDecrypter; + + @Inject + public RepositorySystemImpl( + Logger logger, + MavenRepositorySystem mrs, + PlexusContainer plexus, + ArtifactResolver artifactResolver, + WagonManager wagonManager, + SettingsDecrypter settingsDecrypter ) + { + this.logger = logger; + this.mrs = mrs; + this.plexus = plexus; + this.artifactResolver = artifactResolver; + this.wagonManager = wagonManager; + this.settingsDecrypter = settingsDecrypter; + } + + @Override + public Artifact createArtifact( String groupId, String artifactId, String version, String type ) + { + return mrs.createArtifact( groupId, artifactId, version, null, type ); + } + + @Override + public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type ) + { + return mrs.createArtifact( groupId, artifactId, version, scope, type ); + } + + @Override + public Artifact createProjectArtifact( String groupId, String artifactId, String version ) + { + return mrs.createProjectArtifact( groupId, artifactId, version ); + } + + @Override + public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, + String type, String classifier ) + { + return mrs.createArtifactWithClassifier( groupId, artifactId, version, type, classifier ); + } + + @Override + public Artifact createPluginArtifact( Plugin plugin ) + { + return mrs.createPluginArtifact( plugin ); + } + + @Override + public Artifact createDependencyArtifact( Dependency dependency ) + { + return mrs.createDependencyArtifact( dependency ); + } + + @Override + public ArtifactRepository buildArtifactRepository( Repository repository ) throws InvalidRepositoryException + { + return MavenRepositorySystem.buildArtifactRepository( repository ); + } + + @Override + public ArtifactRepository createDefaultRemoteRepository() throws InvalidRepositoryException + { + return mrs.createDefaultRemoteRepository( null ); + } + + @Override + public ArtifactRepository createDefaultLocalRepository() throws InvalidRepositoryException + { + return mrs.createLocalRepository( null, RepositorySystem.defaultUserLocalRepository ); + } + + @Override + public ArtifactRepository createLocalRepository( File localRepository ) throws InvalidRepositoryException + { + return mrs.createLocalRepository( null, localRepository ); + } + + @Override + public ArtifactRepository createArtifactRepository( + String id, String url, ArtifactRepositoryLayout repositoryLayout, + ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ) + { + return MavenRepositorySystem.createArtifactRepository( id, url, repositoryLayout, snapshots, releases ); + } + + @Override + public List getEffectiveRepositories( List repositories ) + { + return mrs.getEffectiveRepositories( repositories ); + } + + @Override + public Mirror getMirror( ArtifactRepository repository, List mirrors ) + { + return MavenRepositorySystem.getMirror( repository, mirrors ); + } + + @Override + public void injectMirror( List repositories, List mirrors ) + { + mrs.injectMirror( repositories, mirrors ); + } + + @Override + public void injectMirror( RepositorySystemSession session, List repositories ) + { + mrs.injectMirror( session, repositories ); + } + + @Override + public void injectProxy( RepositorySystemSession session, List repositories ) + { + mrs.injectProxy( session, repositories ); + } + + @Override + public void injectAuthentication( RepositorySystemSession session, List repositories ) + { + mrs.injectAuthentication( session, repositories ); + } + + @Override + @Deprecated + public void injectProxy( List repositories, List proxies ) + { + if ( repositories != null ) + { + for ( ArtifactRepository repository : repositories ) + { + org.apache.maven.settings.Proxy proxy = getProxy( repository, proxies ); + + if ( proxy != null ) + { + SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest( proxy ); + SettingsDecryptionResult result = settingsDecrypter.decrypt( request ); + proxy = result.getProxy(); + + if ( logger.isDebugEnabled() ) + { + for ( SettingsProblem problem : result.getProblems() ) + { + logger.debug( problem.getMessage(), problem.getException() ); + } + } + + org.apache.maven.repository.Proxy p = new org.apache.maven.repository.Proxy(); + p.setHost( proxy.getHost() ); + p.setProtocol( proxy.getProtocol() ); + p.setPort( proxy.getPort() ); + p.setNonProxyHosts( proxy.getNonProxyHosts() ); + p.setUserName( proxy.getUsername() ); + p.setPassword( proxy.getPassword() ); + + repository.setProxy( p ); + } + else + { + repository.setProxy( null ); + } + } + } + } + + private org.apache.maven.settings.Proxy getProxy( ArtifactRepository repository, + List proxies ) + { + if ( proxies != null && repository.getProtocol() != null ) + { + for ( org.apache.maven.settings.Proxy proxy : proxies ) + { + if ( proxy.isActive() && repository.getProtocol().equalsIgnoreCase( proxy.getProtocol() ) ) + { + if ( StringUtils.isNotEmpty( proxy.getNonProxyHosts() ) ) + { + ProxyInfo pi = new ProxyInfo(); + pi.setNonProxyHosts( proxy.getNonProxyHosts() ); + + org.apache.maven.wagon.repository.Repository repo = + new org.apache.maven.wagon.repository.Repository( + repository.getId(), repository.getUrl() ); + + if ( !ProxyUtils.validateNonProxyHosts( pi, repo.getHost() ) ) + { + return proxy; + } + } + else + { + return proxy; + } + } + } + } + + return null; + } + + @Override + @Deprecated + public void injectAuthentication( List repositories, List servers ) + { + if ( repositories != null ) + { + Map serversById = new HashMap<>(); + + if ( servers != null ) + { + for ( Server server : servers ) + { + if ( !serversById.containsKey( server.getId() ) ) + { + serversById.put( server.getId(), server ); + } + } + } + + for ( ArtifactRepository repository : repositories ) + { + Server server = serversById.get( repository.getId() ); + + if ( server != null ) + { + SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest( server ); + SettingsDecryptionResult result = settingsDecrypter.decrypt( request ); + server = result.getServer(); + + if ( logger.isDebugEnabled() ) + { + for ( SettingsProblem problem : result.getProblems() ) + { + logger.debug( problem.getMessage(), problem.getException() ); + } + } + + Authentication authentication = new Authentication( server.getUsername(), server.getPassword() ); + authentication.setPrivateKey( server.getPrivateKey() ); + authentication.setPassphrase( server.getPassphrase() ); + + repository.setAuthentication( authentication ); + } + else + { + repository.setAuthentication( null ); + } + } + } + } + + @Override + @Deprecated + public ArtifactResolutionResult resolve( ArtifactResolutionRequest request ) + { + return artifactResolver.resolve( request ); + } + + @Override + @Deprecated + public void publish( + ArtifactRepository repository, + File source, + String remotePath, + ArtifactTransferListener transferListener ) + throws ArtifactTransferFailedException + { + try + { + wagonManager.putRemoteFile( repository, source, remotePath, + TransferListenerAdapter.newAdapter( transferListener ) ); + } + catch ( org.apache.maven.wagon.TransferFailedException e ) + { + throw new ArtifactTransferFailedException( getMessage( e, "Error transferring artifact." ), e ); + } + } + + @Override + @Deprecated + public void retrieve( + ArtifactRepository repository, + File destination, + String remotePath, + ArtifactTransferListener transferListener ) + throws ArtifactTransferFailedException, ArtifactDoesNotExistException + { + try + { + wagonManager.getRemoteFile( repository, destination, remotePath, + TransferListenerAdapter.newAdapter( transferListener ), + ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN, true ); + } + catch ( org.apache.maven.wagon.TransferFailedException e ) + { + throw new ArtifactTransferFailedException( getMessage( e, "Error transferring artifact." ), e ); + } + catch ( org.apache.maven.wagon.ResourceDoesNotExistException e ) + { + throw new ArtifactDoesNotExistException( getMessage( e, "Requested artifact does not exist." ), e ); + } + } + + private static String getMessage( Throwable error, String def ) + { + if ( error == null ) + { + return def; + } + String msg = error.getMessage(); + if ( StringUtils.isNotEmpty( msg ) ) + { + return msg; + } + return getMessage( error.getCause(), def ); + } + +} diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ResolutionListenerForDepMgmt.java b/maven-core/src/main/java/org/apache/maven/bridge/legacy/ResolutionListenerForDepMgmt.java similarity index 93% rename from maven-compat/src/main/java/org/apache/maven/artifact/resolver/ResolutionListenerForDepMgmt.java rename to maven-core/src/main/java/org/apache/maven/bridge/legacy/ResolutionListenerForDepMgmt.java index 6cf06b16f955..3b641aa5abd0 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ResolutionListenerForDepMgmt.java +++ b/maven-core/src/main/java/org/apache/maven/bridge/legacy/ResolutionListenerForDepMgmt.java @@ -1,4 +1,4 @@ -package org.apache.maven.artifact.resolver; +package org.apache.maven.bridge.legacy; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -29,8 +29,7 @@ * method (and the [yet to be done] addition of these methods to that * interface) has had a chance to propagate to all interested plugins. */ -@Deprecated -public interface ResolutionListenerForDepMgmt +interface ResolutionListenerForDepMgmt { void manageArtifactVersion( Artifact artifact, Artifact replacement ); diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/SnapshotArtifactRepositoryMetadata.java b/maven-core/src/main/java/org/apache/maven/bridge/legacy/SnapshotArtifactRepositoryMetadata.java similarity index 85% rename from maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/SnapshotArtifactRepositoryMetadata.java rename to maven-core/src/main/java/org/apache/maven/bridge/legacy/SnapshotArtifactRepositoryMetadata.java index 512019927674..4ba71d300310 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/SnapshotArtifactRepositoryMetadata.java +++ b/maven-core/src/main/java/org/apache/maven/bridge/legacy/SnapshotArtifactRepositoryMetadata.java @@ -1,4 +1,4 @@ -package org.apache.maven.artifact.repository.metadata; +package org.apache.maven.bridge.legacy; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -21,6 +21,8 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.metadata.AbstractRepositoryMetadata; +import org.apache.maven.artifact.repository.metadata.Snapshot; /** * Metadata for the artifact version directory of the repository. @@ -28,19 +30,13 @@ * @author Brett Porter * TODO split instantiation (versioning, plugin mappings) from definition */ -public class SnapshotArtifactRepositoryMetadata +class SnapshotArtifactRepositoryMetadata extends AbstractRepositoryMetadata { private Artifact artifact; - public SnapshotArtifactRepositoryMetadata( Artifact artifact ) - { - super( createMetadata( artifact, null ) ); - this.artifact = artifact; - } - - public SnapshotArtifactRepositoryMetadata( Artifact artifact, - Snapshot snapshot ) + SnapshotArtifactRepositoryMetadata( Artifact artifact, + Snapshot snapshot ) { super( createMetadata( artifact, createVersioning( snapshot ) ) ); this.artifact = artifact; diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/TransferListenerAdapter.java b/maven-core/src/main/java/org/apache/maven/bridge/legacy/TransferListenerAdapter.java similarity index 99% rename from maven-compat/src/main/java/org/apache/maven/repository/legacy/TransferListenerAdapter.java rename to maven-core/src/main/java/org/apache/maven/bridge/legacy/TransferListenerAdapter.java index c3bc5e95188d..49c7c91d5487 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/TransferListenerAdapter.java +++ b/maven-core/src/main/java/org/apache/maven/bridge/legacy/TransferListenerAdapter.java @@ -1,4 +1,4 @@ -package org.apache.maven.repository.legacy; +package org.apache.maven.bridge.legacy; /* * Licensed to the Apache Software Foundation (ASF) under one diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java b/maven-core/src/main/java/org/apache/maven/bridge/legacy/WagonManager.java similarity index 75% rename from maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java rename to maven-core/src/main/java/org/apache/maven/bridge/legacy/WagonManager.java index ab6383afe82f..94b6598d2924 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java +++ b/maven-core/src/main/java/org/apache/maven/bridge/legacy/WagonManager.java @@ -1,4 +1,4 @@ -package org.apache.maven.repository.legacy; +package org.apache.maven.bridge.legacy; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -29,8 +29,9 @@ import java.util.Map; import java.util.Properties; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadata; +import javax.inject.Inject; +import javax.inject.Singleton; + import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.plugin.LegacySupport; @@ -47,8 +48,6 @@ import org.apache.maven.wagon.proxy.ProxyInfo; import org.apache.maven.wagon.repository.Repository; import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.Logger; @@ -56,16 +55,8 @@ import org.eclipse.aether.ConfigurationProperties; import org.eclipse.aether.util.ConfigUtils; -//TODO remove the update check manager -//TODO separate into retriever and publisher -//TODO remove hardcoding of checksum logic - -/** - * Manages Wagon related operations in Maven. - */ -@Component( role = WagonManager.class ) -public class DefaultWagonManager - implements WagonManager +@Singleton +class WagonManager { private static final String[] CHECKSUM_IDS = @@ -81,172 +72,15 @@ public class DefaultWagonManager "MD5", "SHA-1" }; - @Requirement + @Inject private Logger logger; - @Requirement + @Inject private PlexusContainer container; - @Requirement - private UpdateCheckManager updateCheckManager; - - @Requirement + @Inject private LegacySupport legacySupport; - // - // Retriever - // - @Override - public void getArtifact( Artifact artifact, ArtifactRepository repository, TransferListener downloadMonitor, - boolean force ) - throws TransferFailedException, ResourceDoesNotExistException - { - String remotePath = repository.pathOf( artifact ); - - ArtifactRepositoryPolicy policy = artifact.isSnapshot() ? repository.getSnapshots() : repository.getReleases(); - - if ( !policy.isEnabled() ) - { - logger.debug( "Skipping disabled repository " + repository.getId() + " for resolution of " - + artifact.getId() ); - - } - else if ( artifact.isSnapshot() || !artifact.getFile().exists() ) - { - if ( force || updateCheckManager.isUpdateRequired( artifact, repository ) ) - { - logger.debug( "Trying repository " + repository.getId() + " for resolution of " + artifact.getId() - + " from " + remotePath ); - - try - { - getRemoteFile( repository, artifact.getFile(), remotePath, downloadMonitor, - policy.getChecksumPolicy(), false ); - - updateCheckManager.touch( artifact, repository, null ); - } - catch ( ResourceDoesNotExistException e ) - { - updateCheckManager.touch( artifact, repository, null ); - throw e; - } - catch ( TransferFailedException e ) - { - String error = ( e.getMessage() != null ) ? e.getMessage() : e.getClass().getSimpleName(); - updateCheckManager.touch( artifact, repository, error ); - throw e; - } - - logger.debug( " Artifact " + artifact.getId() + " resolved to " + artifact.getFile() ); - - artifact.setResolved( true ); - } - else if ( !artifact.getFile().exists() ) - { - String error = updateCheckManager.getError( artifact, repository ); - if ( error != null ) - { - throw new TransferFailedException( - "Failure to resolve " + remotePath + " from " + repository.getUrl() - + " was cached in the local repository. " - + "Resolution will not be reattempted until the update interval of " - + repository.getId() + " has elapsed or updates are forced. Original error: " + error ); - - } - else - { - throw new ResourceDoesNotExistException( - "Failure to resolve " + remotePath + " from " + repository.getUrl() - + " was cached in the local repository. " - + "Resolution will not be reattempted until the update interval of " - + repository.getId() + " has elapsed or updates are forced." ); - - } - } - } - } - - @Override - public void getArtifact( Artifact artifact, List remoteRepositories, - TransferListener downloadMonitor, boolean force ) - throws TransferFailedException, ResourceDoesNotExistException - { - TransferFailedException tfe = null; - - for ( ArtifactRepository repository : remoteRepositories ) - { - try - { - getArtifact( artifact, repository, downloadMonitor, force ); - - if ( artifact.isResolved() ) - { - artifact.setRepository( repository ); - break; - } - } - catch ( ResourceDoesNotExistException e ) - { - // This one we will eat when looking through remote repositories - // because we want to cycle through them all before squawking. - - logger.debug( "Unable to find artifact " + artifact.getId() + " in repository " + repository.getId() - + " (" + repository.getUrl() + ")", e ); - - } - catch ( TransferFailedException e ) - { - tfe = e; - - String msg = - "Unable to get artifact " + artifact.getId() + " from repository " + repository.getId() + " (" - + repository.getUrl() + "): " + e.getMessage(); - - if ( logger.isDebugEnabled() ) - { - logger.warn( msg, e ); - } - else - { - logger.warn( msg ); - } - } - } - - // if it already exists locally we were just trying to force it - ignore the update - if ( !artifact.getFile().exists() ) - { - if ( tfe != null ) - { - throw tfe; - } - else - { - throw new ResourceDoesNotExistException( "Unable to download the artifact from any repository" ); - } - } - } - - @Override - public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository repository, File destination, - String checksumPolicy ) - throws TransferFailedException, ResourceDoesNotExistException - { - String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata ); - - getRemoteFile( repository, destination, remotePath, null, checksumPolicy, true ); - } - - @Override - public void getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository repository, - File destination, String checksumPolicy ) - throws TransferFailedException, ResourceDoesNotExistException - { - String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata ); - - getRemoteFile( repository, destination, remotePath, null, checksumPolicy, true ); - } - /** * Deal with connecting to a wagon repository taking into account authentication and proxies. * @@ -338,7 +172,6 @@ private ProxyInfo proxyInfo( ArtifactRepository repository ) } @SuppressWarnings( "checkstyle:methodlength" ) - @Override public void getRemoteFile( ArtifactRepository repository, File destination, String remotePath, TransferListener downloadMonitor, String checksumPolicy, boolean force ) throws TransferFailedException, ResourceDoesNotExistException @@ -440,7 +273,7 @@ public void getRemoteFile( ArtifactRepository repository, File destination, Stri } catch ( ChecksumFailedException e ) { - // if we catch a ChecksumFailedException, it means the transfer/read succeeded, but the + // if we catch a ChecksumFailedException, it means the transfer/read succeeded, but the // checksum doesn't match. This could be a problem with the server (ibiblio HTTP-200 error // page), so we'll try this up to two times. On the second try, we'll handle it as a bona-fide // error, based on the repository's checksum checking policy. @@ -554,26 +387,6 @@ public void getRemoteFile( ArtifactRepository repository, File destination, Stri } } - // - // Publisher - // - @Override - public void putArtifact( File source, Artifact artifact, ArtifactRepository deploymentRepository, - TransferListener downloadMonitor ) - throws TransferFailedException - { - putRemoteFile( deploymentRepository, source, deploymentRepository.pathOf( artifact ), downloadMonitor ); - } - - @Override - public void putArtifactMetadata( File source, ArtifactMetadata artifactMetadata, ArtifactRepository repository ) - throws TransferFailedException - { - logger.info( "Uploading " + artifactMetadata ); - putRemoteFile( repository, source, repository.pathOfRemoteRepositoryMetadata( artifactMetadata ), null ); - } - - @Override public void putRemoteFile( ArtifactRepository repository, File source, String remotePath, TransferListener downloadMonitor ) throws TransferFailedException @@ -813,17 +626,7 @@ private void releaseWagon( String protocol, Wagon wagon ) } } - @Override - @Deprecated - public Wagon getWagon( Repository repository ) - throws UnsupportedProtocolException - { - return getWagon( repository.getProtocol() ); - } - - @Override - @Deprecated - public Wagon getWagon( String protocol ) + private Wagon getWagon( String protocol ) throws UnsupportedProtocolException { if ( protocol == null ) diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java index 94e9eccd4ab3..fb592d770e8d 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java +++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java @@ -33,7 +33,6 @@ import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.bridge.MavenRepositorySystem; -import org.apache.maven.repository.RepositorySystem; // // All of this needs to go away and be couched in terms of the execution request // @@ -123,7 +122,7 @@ private void injectDefaultRepositories( MavenExecutionRequest request ) { Set definedRepositories = repositorySystem.getRepoIds( request.getRemoteRepositories() ); - if ( !definedRepositories.contains( RepositorySystem.DEFAULT_REMOTE_REPO_ID ) ) + if ( !definedRepositories.contains( MavenRepositorySystem.DEFAULT_REMOTE_REPO_ID ) ) { try { @@ -141,7 +140,7 @@ private void injectDefaultPluginRepositories( MavenExecutionRequest request ) { Set definedRepositories = repositorySystem.getRepoIds( request.getPluginArtifactRepositories() ); - if ( !definedRepositories.contains( RepositorySystem.DEFAULT_REMOTE_REPO_ID ) ) + if ( !definedRepositories.contains( MavenRepositorySystem.DEFAULT_REMOTE_REPO_ID ) ) { try { @@ -192,7 +191,7 @@ private ArtifactRepository createLocalRepository( MavenExecutionRequest request if ( StringUtils.isEmpty( localRepositoryPath ) ) { - localRepositoryPath = RepositorySystem.defaultUserLocalRepository.getAbsolutePath(); + localRepositoryPath = MavenRepositorySystem.defaultUserLocalRepository.getAbsolutePath(); } try diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java index e5c89e6f1a70..ff8917f77a4c 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java @@ -37,6 +37,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.bridge.MavenRepositorySystem; import org.apache.maven.classrealm.ClassRealmManager; import org.apache.maven.model.Build; import org.apache.maven.model.Extension; @@ -48,7 +49,6 @@ import org.apache.maven.plugin.PluginManagerException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.version.PluginVersionResolutionException; -import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.logging.Logger; @@ -81,7 +81,7 @@ public class DefaultProjectBuildingHelper private ProjectRealmCache projectRealmCache; @Inject - private RepositorySystem repositorySystem; + private MavenRepositorySystem repositorySystem; @Inject private MavenPluginManager pluginManager; diff --git a/maven-core/src/main/java/org/apache/maven/repository/RepositorySystem.java b/maven-core/src/main/java/org/apache/maven/repository/RepositorySystem.java index 30b49256faea..96d51f266c11 100644 --- a/maven-core/src/main/java/org/apache/maven/repository/RepositorySystem.java +++ b/maven-core/src/main/java/org/apache/maven/repository/RepositorySystem.java @@ -71,16 +71,16 @@ Artifact createArtifactWithClassifier( String groupId, String artifactId, String Artifact createDependencyArtifact( Dependency dependency ); ArtifactRepository buildArtifactRepository( Repository repository ) - throws InvalidRepositoryException; + throws InvalidRepositoryException; ArtifactRepository createDefaultRemoteRepository() - throws InvalidRepositoryException; + throws InvalidRepositoryException; ArtifactRepository createDefaultLocalRepository() - throws InvalidRepositoryException; + throws InvalidRepositoryException; ArtifactRepository createLocalRepository( File localRepository ) - throws InvalidRepositoryException; + throws InvalidRepositoryException; ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout, ArtifactRepositoryPolicy snapshots, @@ -126,6 +126,7 @@ ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepo * @param repositories The repositories into which to inject the proxy information, may be {@code null}. * @param proxies The available proxies, may be {@code null}. */ + @Deprecated void injectProxy( List repositories, List proxies ); /** @@ -137,6 +138,7 @@ ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepo * @param repositories The repositories into which to inject the authentication information, may be {@code null}. * @param servers The available servers, may be {@code null}. */ + @Deprecated void injectAuthentication( List repositories, List servers ); void injectMirror( RepositorySystemSession session, List repositories ); @@ -145,6 +147,7 @@ ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepo void injectAuthentication( RepositorySystemSession session, List repositories ); + @Deprecated ArtifactResolutionResult resolve( ArtifactResolutionRequest request ); // Install @@ -156,12 +159,14 @@ ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepo // // Raw file transfers // + @Deprecated void publish( ArtifactRepository repository, File source, String remotePath, ArtifactTransferListener transferListener ) - throws ArtifactTransferFailedException; + throws ArtifactTransferFailedException; + @Deprecated void retrieve( ArtifactRepository repository, File destination, String remotePath, ArtifactTransferListener transferListener ) - throws ArtifactTransferFailedException, ArtifactDoesNotExistException; + throws ArtifactTransferFailedException, ArtifactDoesNotExistException; -} +} \ No newline at end of file diff --git a/maven-core/src/main/resources/META-INF/maven/extension.xml b/maven-core/src/main/resources/META-INF/maven/extension.xml index a9e201c70825..d71053634d5a 100644 --- a/maven-core/src/main/resources/META-INF/maven/extension.xml +++ b/maven-core/src/main/resources/META-INF/maven/extension.xml @@ -147,7 +147,6 @@ under the License. org.apache.maven:maven-aether-provider org.apache.maven:maven-resolver-provider org.apache.maven:maven-artifact-manager - org.apache.maven:maven-compat org.apache.maven:maven-core org.apache.maven:maven-error-diagnostics org.apache.maven:maven-lifecycle diff --git a/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java b/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java index 2d9400ef47cf..7911f094046d 100644 --- a/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java +++ b/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java @@ -28,6 +28,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.bridge.MavenRepositorySystem; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.DefaultMavenExecutionResult; import org.apache.maven.execution.MavenExecutionRequest; @@ -42,7 +43,6 @@ import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.internal.MavenRepositorySystemUtils; import org.codehaus.plexus.testing.PlexusTest; import org.codehaus.plexus.PlexusContainer; @@ -63,7 +63,7 @@ public abstract class AbstractCoreMavenComponentTestCase protected PlexusContainer container; @Inject - protected RepositorySystem repositorySystem; + protected MavenRepositorySystem repositorySystem; @Inject protected org.apache.maven.project.ProjectBuilder projectBuilder; @@ -199,7 +199,7 @@ protected List getRemoteRepositories() policy.setUpdatePolicy( "always" ); Repository repository = new Repository(); - repository.setId( RepositorySystem.DEFAULT_REMOTE_REPO_ID ); + repository.setId( MavenRepositorySystem.DEFAULT_REMOTE_REPO_ID ); repository.setUrl( "file://" + repoDir.toURI().getPath() ); repository.setReleases( policy ); repository.setSnapshots( policy ); @@ -214,11 +214,11 @@ protected List getPluginArtifactRepositories() } protected ArtifactRepository getLocalRepository() - throws InvalidRepositoryException + throws Exception { File repoDir = new File( getBasedir(), "target/local-repo" ).getAbsoluteFile(); - return repositorySystem.createLocalRepository( repoDir ); + return repositorySystem.createLocalRepository( null, repoDir ); } protected class ProjectBuilder diff --git a/maven-core/src/test/java/org/apache/maven/ProjectDependenciesResolverTest.java b/maven-core/src/test/java/org/apache/maven/ProjectDependenciesResolverTest.java deleted file mode 100644 index b648f2aec4e4..000000000000 --- a/maven-core/src/test/java/org/apache/maven/ProjectDependenciesResolverTest.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.apache.maven; - -/* - * 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.Collections; -import java.util.List; -import java.util.Properties; -import java.util.Set; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.project.MavenProject; - -import javax.inject.Inject; -import org.junit.jupiter.api.Test; - -import static org.codehaus.plexus.testing.PlexusExtension.getBasedir; -import static org.hamcrest.Matchers.endsWith; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.hamcrest.MatcherAssert.assertThat; - -public class ProjectDependenciesResolverTest - extends AbstractCoreMavenComponentTestCase -{ - @Inject - private ProjectDependenciesResolver resolver; - - protected String getProjectsDirectory() - { - return "src/test/projects/project-dependencies-resolver"; - } - - /* - @Test - public void testExclusionsInDependencies() - throws Exception - { - MavenSession session = createMavenSession( null ); - MavenProject project = session.getCurrentProject(); - - Exclusion exclusion = new Exclusion(); - exclusion.setGroupId( "org.apache.maven.its" ); - exclusion.setArtifactId( "a" ); - - new ProjectBuilder( project ).addDependency( "org.apache.maven.its", "b", "0.1", Artifact.SCOPE_RUNTIME, - exclusion ); - - Set artifactDependencies = - resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), session ); - assertEquals( 0, artifactDependencies.size() ); - - artifactDependencies = resolver.resolve( project, Collections.singleton( Artifact.SCOPE_RUNTIME ), session ); - assertEquals( 1, artifactDependencies.size() ); - assertEquals( "b", artifactDependencies.iterator().next().getArtifactId() ); - } - */ - - @Test - public void testSystemScopeDependencies() - throws Exception - { - MavenSession session = createMavenSession( null ); - MavenProject project = session.getCurrentProject(); - - new ProjectBuilder( project ) - .addDependency( "com.mycompany", "system-dependency", "1.0", Artifact.SCOPE_SYSTEM, new File( getBasedir(), "pom.xml" ).getAbsolutePath() ); - - Set artifactDependencies = - resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), session ); - assertEquals( 1, artifactDependencies.size() ); - } - - @Test - public void testSystemScopeDependencyIsPresentInTheCompileClasspathElements() - throws Exception - { - File pom = getProject( "it0063" ); - - Properties eps = new Properties(); - eps.setProperty( "jre.home", new File( pom.getParentFile(), "jdk/jre" ).getPath() ); - - MavenSession session = createMavenSession( pom, eps ); - MavenProject project = session.getCurrentProject(); - - project.setArtifacts( resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), session ) ); - - List elements = project.getCompileClasspathElements(); - assertEquals( 2, elements.size() ); - - @SuppressWarnings( "deprecation" ) - List artifacts = project.getCompileArtifacts(); - assertEquals( 1, artifacts.size() ); - assertThat( artifacts.get( 0 ).getFile().getName(), endsWith( "tools.jar" ) ); - } -} diff --git a/maven-core/src/test/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilterTest.java b/maven-core/src/test/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilterTest.java index 76b1654644bd..beade84c0a41 100644 --- a/maven-core/src/test/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilterTest.java +++ b/maven-core/src/test/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilterTest.java @@ -83,7 +83,7 @@ public void testExcludeGroupIdWildcardNoMatch() { Exclusion exclusion = new Exclusion(); exclusion.setGroupId( "*" ); - exclusion.setArtifactId( "maven-compat" ); + exclusion.setArtifactId( "maven-settings" ); ExclusionArtifactFilter filter = new ExclusionArtifactFilter( Collections.singletonList( exclusion ) ); assertThat( filter.include( artifact ), is( true ) ); diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ProjectDependenciesResolverStub.java b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ProjectDependenciesResolverStub.java deleted file mode 100644 index 8d01bc175924..000000000000 --- a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ProjectDependenciesResolverStub.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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. - */ - -package org.apache.maven.lifecycle.internal.stub; - -import org.apache.maven.ProjectDependenciesResolver; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.project.DependencyResolutionException; -import org.apache.maven.project.DependencyResolutionRequest; -import org.apache.maven.project.DependencyResolutionResult; -import org.apache.maven.project.MavenProject; -import org.eclipse.aether.graph.DefaultDependencyNode; -import org.eclipse.aether.graph.Dependency; -import org.eclipse.aether.graph.DependencyNode; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * @author Kristian Rosenvold - */ -public class ProjectDependenciesResolverStub - implements ProjectDependenciesResolver, org.apache.maven.project.ProjectDependenciesResolver -{ - public Set resolve( MavenProject project, Collection scopesToResolve, MavenSession session ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - return new HashSet<>(); - } - - public Set resolve( MavenProject project, Collection scopesToCollect, - Collection scopesToResolve, MavenSession session ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - return new HashSet<>(); - } - - public Set resolve( Collection projects, Collection scopes, - MavenSession session ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - return new HashSet<>(); - } - - public Set resolve( MavenProject project, Collection scopesToCollect, - Collection scopesToResolve, MavenSession session, - Set ignoreableArtifacts ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - return new HashSet<>(); - } - - public DependencyResolutionResult resolve( DependencyResolutionRequest request ) - throws DependencyResolutionException - { - return new DependencyResolutionResult() - { - - public List getUnresolvedDependencies() - { - return Collections.emptyList(); - } - - public List getResolvedDependencies() - { - return Collections.emptyList(); - } - - public List getResolutionErrors( Dependency dependency ) - { - return Collections.emptyList(); - } - - public DependencyNode getDependencyGraph() - { - return new DefaultDependencyNode( (Dependency) null ); - } - - public List getDependencies() - { - return Collections.emptyList(); - } - - public List getCollectionErrors() - { - return Collections.emptyList(); - } - }; - } - -} diff --git a/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java b/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java index 16deedd33794..d302f9a8d552 100644 --- a/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java +++ b/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java @@ -20,6 +20,10 @@ */ import java.io.File; +import java.io.FileNotFoundException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -29,19 +33,19 @@ import org.apache.maven.AbstractCoreMavenComponentTestCase; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; +import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.bridge.MavenRepositorySystem; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.DefaultMavenExecutionResult; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Build; -import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.DuplicateProjectException; import org.apache.maven.project.MavenProject; -import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.MutablePlexusContainer; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; @@ -65,7 +69,7 @@ public class PluginParameterExpressionEvaluatorTest private static final String FS = File.separator; @Inject - private RepositorySystem factory; + private MavenRepositorySystem factory; @Test public void testPluginDescriptorExpressionReference() @@ -90,7 +94,7 @@ public void testPluginArtifactsExpressionReference() { MojoExecution exec = newMojoExecution(); - Artifact depArtifact = createArtifact( "group", "artifact", "1" ); + Artifact depArtifact = new DefaultArtifact( "group", "artifact", "1", "compile", "jar", "", null ); List deps = new ArrayList<>(); deps.add( depArtifact ); @@ -116,7 +120,7 @@ public void testPluginArtifactMapExpressionReference() { MojoExecution exec = newMojoExecution(); - Artifact depArtifact = createArtifact( "group", "artifact", "1" ); + Artifact depArtifact = new DefaultArtifact( "group", "artifact", "1", "compile", "jar", "", null ); List deps = new ArrayList<>(); deps.add( depArtifact ); @@ -371,7 +375,7 @@ public void testShouldExtractPluginArtifacts() { PluginDescriptor pd = new PluginDescriptor(); - Artifact artifact = createArtifact( "testGroup", "testArtifact", "1.0" ); + Artifact artifact = new DefaultArtifact( "testGroup", "testArtifact", "1.0", "compile", "jar", "", null ); pd.setArtifacts( Collections.singletonList( artifact ) ); @@ -399,7 +403,7 @@ private MavenProject createDefaultProject() private ExpressionEvaluator createExpressionEvaluator( MavenProject project, PluginDescriptor pluginDescriptor, Properties executionProperties ) throws Exception { - ArtifactRepository repo = factory.createDefaultLocalRepository(); + ArtifactRepository repo = factory.createLocalRepository( null, getLocalRepositoryPath() ); MutablePlexusContainer container = (MutablePlexusContainer) getContainer(); MavenSession session = createSession( container, repo, executionProperties ); @@ -414,17 +418,27 @@ private ExpressionEvaluator createExpressionEvaluator( MavenProject project, Plu return new PluginParameterExpressionEvaluator( session, mojoExecution ); } - protected Artifact createArtifact( String groupId, String artifactId, String version ) - throws Exception + protected static File getFileForClasspathResource( String resource ) + throws FileNotFoundException + { + ClassLoader cloader = Thread.currentThread().getContextClassLoader(); + + URL resourceUrl = cloader.getResource( resource ); + + if ( resourceUrl == null ) + { + throw new FileNotFoundException( "Unable to find: " + resource ); + } + + return new File( URI.create( resourceUrl.toString().replaceAll( " ", "%20" ) ) ); + } + + private File getLocalRepositoryPath() + throws FileNotFoundException, URISyntaxException { - Dependency dependency = new Dependency(); - dependency.setGroupId( groupId ); - dependency.setArtifactId( artifactId ); - dependency.setVersion( version ); - dependency.setType( "jar" ); - dependency.setScope( "compile" ); - - return factory.createDependencyArtifact( dependency ); + File markerFile = getFileForClasspathResource( "local-repo/marker.txt" ); + + return markerFile.getAbsoluteFile().getParentFile(); } private MojoExecution newMojoExecution() diff --git a/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java b/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java index 785958e05401..8c8a9faf55c1 100644 --- a/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java +++ b/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java @@ -23,9 +23,10 @@ import java.util.Arrays; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; +import org.apache.maven.bridge.MavenRepositorySystem; import org.apache.maven.model.building.ModelBuildingException; import org.apache.maven.model.building.ModelProblem; -import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.internal.MavenRepositorySystemUtils; import org.codehaus.plexus.testing.PlexusTest; import org.codehaus.plexus.PlexusContainer; @@ -44,7 +45,7 @@ public abstract class AbstractMavenProjectTestCase protected ProjectBuilder projectBuilder; @Inject - protected RepositorySystem repositorySystem; + protected MavenRepositorySystem repositorySystem; @Inject protected PlexusContainer container; @@ -103,7 +104,7 @@ protected static File getFileForClasspathResource( String resource ) protected ArtifactRepository getLocalRepository() throws Exception { - return repositorySystem.createLocalRepository( getLocalRepositoryPath() ); + return repositorySystem.createLocalRepository( null, getLocalRepositoryPath() ); } // ---------------------------------------------------------------------- @@ -152,7 +153,12 @@ protected MavenProject getProjectFromRemoteRepository( final File pom ) { final ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest(); configuration.setLocalRepository( this.getLocalRepository() ); - configuration.setRemoteRepositories( Arrays.asList( this.repositorySystem.createDefaultRemoteRepository() ) ); + configuration.setRemoteRepositories( Arrays.asList( this.repositorySystem.createRepository( + "file://" + new File( System.getProperty( "basedir", "." ), "src/test/remote-repo" ).getAbsoluteFile().toURI().getPath(), + MavenRepositorySystem.DEFAULT_REMOTE_REPO_ID, + true, ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY, + false, ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY, + ArtifactRepositoryPolicy.DEFAULT_CHECKSUM_POLICY ) ) ); initRepoSession( configuration ); return projectBuilder.build( pom, configuration ).getProject(); diff --git a/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java b/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java index 727f28de33e0..e99d16741fa9 100644 --- a/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java @@ -37,7 +37,10 @@ import java.util.List; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.project.artifact.ProjectArtifact; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -147,7 +150,8 @@ public void testFutureSchemaModelVersion() public void testBuildStubModelForMissingRemotePom() throws Exception { - Artifact pom = repositorySystem.createProjectArtifact( "org.apache.maven.its", "missing", "0.1" ); + Artifact pom = new DefaultArtifact("org.apache.maven.its", "missing", "0.1", + "compile", "pom", "", new PomArtifactHandler()); MavenProject project = getProject( pom, true ); assertNotNull( project.getArtifactId() ); @@ -168,7 +172,7 @@ public void testBuildStubModelForMissingRemotePom() protected ArtifactRepository getLocalRepository() throws Exception { - return repositorySystem.createLocalRepository( getLocalRepositoryPath() ); + return repositorySystem.createLocalRepository( null, getLocalRepositoryPath() ); } @Test @@ -350,4 +354,42 @@ public void rereadPom_mng7063() throws Exception assertThat( project.getName(), is( "PROJECT NAME" ) ); } + static class PomArtifactHandler + implements ArtifactHandler + { + public String getClassifier() + { + return null; + } + + public String getDirectory() + { + return null; + } + + public String getExtension() + { + return "pom"; + } + + public String getLanguage() + { + return "none"; + } + + public String getPackaging() + { + return "pom"; + } + + public boolean isAddedToClasspath() + { + return false; + } + + public boolean isIncludesDependencies() + { + return false; + } + } } diff --git a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java index ff7cc050f6a9..ce4c295fd54d 100644 --- a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java @@ -28,13 +28,13 @@ import javax.inject.Inject; +import org.apache.maven.bridge.MavenRepositorySystem; import org.codehaus.plexus.testing.PlexusTest; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.building.ModelBuildingRequest; import org.apache.maven.project.harness.PomTestWrapper; -import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.internal.MavenRepositorySystemUtils; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; @@ -67,7 +67,7 @@ public class PomConstructionTest private DefaultProjectBuilder projectBuilder; @Inject - private RepositorySystem repositorySystem; + private MavenRepositorySystem repositorySystem; private File testDirectory; @@ -1354,8 +1354,8 @@ private void testCompleteModel( PomTestWrapper pom ) assertEquals( "project-remote-repo", pom.getValue( "repositories[1]/id" ) ); assertEquals( "https://project.url/remote", pom.getValue( "repositories[1]/url" ) ); assertEquals( "repo", pom.getValue( "repositories[1]/name" ) ); - assertEquals( RepositorySystem.DEFAULT_REMOTE_REPO_ID, pom.getValue( "repositories[2]/id" ) ); - assertEquals( RepositorySystem.DEFAULT_REMOTE_REPO_URL, pom.getValue( "repositories[2]/url" ) ); + assertEquals( MavenRepositorySystem.DEFAULT_REMOTE_REPO_ID, pom.getValue( "repositories[2]/id" ) ); + assertEquals( MavenRepositorySystem.DEFAULT_REMOTE_REPO_URL, pom.getValue( "repositories[2]/url" ) ); assertEquals( "test", pom.getValue( "build/defaultGoal" ) ); assertEquals( "coreit", pom.getValue( "build/finalName" ) ); diff --git a/maven-core/src/test/java/org/apache/maven/project/ProjectModelResolverTest.java b/maven-core/src/test/java/org/apache/maven/project/ProjectModelResolverTest.java index 709b88cba365..cb9c0bae7375 100644 --- a/maven-core/src/test/java/org/apache/maven/project/ProjectModelResolverTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/ProjectModelResolverTest.java @@ -24,6 +24,7 @@ import java.util.List; import org.apache.maven.artifact.InvalidRepositoryException; +import org.apache.maven.bridge.MavenRepositorySystem; import org.apache.maven.model.Dependency; import org.apache.maven.model.Parent; import org.apache.maven.model.resolution.ModelResolver; @@ -221,7 +222,7 @@ private List getRemoteRepositories() { final File repoDir = new File( getBasedir(), "src/test/remote-repo" ).getAbsoluteFile(); final RemoteRepository remoteRepository = - new RemoteRepository.Builder( org.apache.maven.repository.RepositorySystem.DEFAULT_REMOTE_REPO_ID, + new RemoteRepository.Builder( MavenRepositorySystem.DEFAULT_REMOTE_REPO_ID, "default", repoDir.toURI().toASCIIString() ).build(); return Collections.singletonList( remoteRepository ); diff --git a/maven-core/src/test/java/org/apache/maven/project/artifact/DefaultMavenMetadataCacheTest.java b/maven-core/src/test/java/org/apache/maven/project/artifact/DefaultMavenMetadataCacheTest.java deleted file mode 100644 index 2d5c1baa7fb9..000000000000 --- a/maven-core/src/test/java/org/apache/maven/project/artifact/DefaultMavenMetadataCacheTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.apache.maven.project.artifact; - -/* - * 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.Collections; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter; -import org.apache.maven.project.artifact.DefaultMavenMetadataCache.CacheKey; -import org.apache.maven.repository.DelegatingLocalArtifactRepository; -import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.repository.TestRepositorySystem; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.BeforeEach; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotSame; - -/** - * @author Igor Fedorenko - */ -public class DefaultMavenMetadataCacheTest -{ - private RepositorySystem repositorySystem; - - @BeforeEach - public void setUp() - throws Exception - { - repositorySystem = new TestRepositorySystem( null, null ); - } - - @AfterEach - public void tearDown() - throws Exception - { - repositorySystem = null; - } - - @Test - public void testCacheKey() - throws Exception - { - Artifact a1 = repositorySystem.createArtifact( "testGroup", "testArtifact", "1.2.3", "jar" ); - @SuppressWarnings( "deprecation" ) - ArtifactRepository lr1 = new DelegatingLocalArtifactRepository( repositorySystem.createDefaultLocalRepository() ); - ArtifactRepository rr1 = repositorySystem.createDefaultRemoteRepository(); - a1.setDependencyFilter( new ExcludesArtifactFilter( Arrays.asList( "foo" ) ) ); - - Artifact a2 = repositorySystem.createArtifact( "testGroup", "testArtifact", "1.2.3", "jar" ); - @SuppressWarnings( "deprecation" ) - ArtifactRepository lr2 = new DelegatingLocalArtifactRepository( repositorySystem.createDefaultLocalRepository() ); - ArtifactRepository rr2 = repositorySystem.createDefaultRemoteRepository(); - a2.setDependencyFilter( new ExcludesArtifactFilter( Arrays.asList( "foo" ) ) ); - - // sanity checks - assertNotSame( a1, a2 ); - assertNotSame( lr1, lr2 ); - assertNotSame( rr1, rr2 ); - - CacheKey k1 = new CacheKey( a1, false, lr1, Collections.singletonList( rr1 ) ); - CacheKey k2 = new CacheKey( a2, false, lr2, Collections.singletonList( rr2 ) ); - - assertEquals(k1.hashCode(), k2.hashCode()); - } -} diff --git a/maven-core/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java b/maven-core/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java index 7d5150d4d6d4..e8a893629f03 100644 --- a/maven-core/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java @@ -21,7 +21,7 @@ import javax.inject.Inject; -import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.bridge.MavenRepositorySystem; import org.codehaus.plexus.testing.PlexusTest; import org.codehaus.plexus.PlexusContainer; import org.junit.jupiter.api.Disabled; @@ -31,7 +31,7 @@ public class MavenMetadataSourceTest { @Inject - private RepositorySystem repositorySystem; + private MavenRepositorySystem repositorySystem; @Inject PlexusContainer container; diff --git a/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java b/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java deleted file mode 100644 index c95f42843f5e..000000000000 --- a/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java +++ /dev/null @@ -1,337 +0,0 @@ -package org.apache.maven.repository; - -/* - * 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.io.IOException; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.artifact.InvalidRepositoryException; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; -import org.apache.maven.artifact.repository.MavenArtifactRepository; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; -import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; -import org.apache.maven.artifact.resolver.ArtifactResolutionResult; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.maven.model.Dependency; -import org.apache.maven.model.Model; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.Repository; -import org.apache.maven.model.io.ModelReader; -import org.apache.maven.project.artifact.ArtifactWithDependencies; -import org.apache.maven.settings.Mirror; -import org.apache.maven.settings.Proxy; -import org.apache.maven.settings.Server; -import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.StringUtils; -import org.eclipse.aether.RepositorySystemSession; - -/** - * @author Benjamin Bentmann - */ -@Named -@Singleton -public class TestRepositorySystem - implements RepositorySystem -{ - - private final ModelReader modelReader; - - private final ArtifactFactory artifactFactory; - - @Inject - public TestRepositorySystem( ModelReader modelReader, ArtifactFactory artifactFactory ) - { - this.modelReader = modelReader; - this.artifactFactory = artifactFactory; - } - - public ArtifactRepository buildArtifactRepository( Repository repository ) - throws InvalidRepositoryException - { - return new MavenArtifactRepository( repository.getId(), repository.getUrl(), new DefaultRepositoryLayout(), - new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() ); - } - - public Artifact createArtifact( String groupId, String artifactId, String version, String packaging ) - { - return createArtifact( groupId, artifactId, version, null, packaging ); - } - - public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type ) - { - return new DefaultArtifact( groupId, artifactId, version, scope, type, null, new TestArtifactHandler( type ) ); - } - - public ArtifactRepository createArtifactRepository( String id, String url, - ArtifactRepositoryLayout repositoryLayout, - ArtifactRepositoryPolicy snapshots, - ArtifactRepositoryPolicy releases ) - { - return new MavenArtifactRepository( id, url, repositoryLayout, snapshots, releases ); - } - - public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type, - String classifier ) - { - return new DefaultArtifact( groupId, artifactId, version, null, type, classifier, - new TestArtifactHandler( type ) ); - } - - public ArtifactRepository createDefaultLocalRepository() - throws InvalidRepositoryException - { - return createLocalRepository( new File( System.getProperty( "basedir", "." ), "target/local-repo" ).getAbsoluteFile() ); - } - - public ArtifactRepository createDefaultRemoteRepository() - throws InvalidRepositoryException - { - return new MavenArtifactRepository( DEFAULT_REMOTE_REPO_ID, "file://" - + new File( System.getProperty( "basedir", "." ), "src/test/remote-repo" ).getAbsoluteFile().toURI().getPath(), - new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), - new ArtifactRepositoryPolicy() ); - } - - public Artifact createDependencyArtifact( Dependency dependency ) - { - Artifact artifact = - new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), - dependency.getScope(), dependency.getType(), dependency.getClassifier(), - new TestArtifactHandler( dependency.getType() ) ); - - if ( Artifact.SCOPE_SYSTEM.equals( dependency.getScope() ) ) - { - artifact.setFile( new File( dependency.getSystemPath() ) ); - artifact.setResolved( true ); - } - - return artifact; - } - - public ArtifactRepository createLocalRepository( File localRepository ) - throws InvalidRepositoryException - { - return new MavenArtifactRepository( DEFAULT_LOCAL_REPO_ID, "file://" + localRepository.toURI().getPath(), - new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), - new ArtifactRepositoryPolicy() ); - } - - public Artifact createPluginArtifact( Plugin plugin ) - { - VersionRange versionRange; - try - { - String version = plugin.getVersion(); - if ( StringUtils.isEmpty( version ) ) - { - version = "RELEASE"; - } - versionRange = VersionRange.createFromVersionSpec( version ); - } - catch ( InvalidVersionSpecificationException e ) - { - return null; - } - - return artifactFactory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange ); - } - - public Artifact createProjectArtifact( String groupId, String artifactId, String version ) - { - return createArtifact( groupId, artifactId, version, "pom" ); - } - - public List getEffectiveRepositories( List repositories ) - { - return repositories; - } - - public Mirror getMirror( ArtifactRepository repository, List mirrors ) - { - return null; - } - - public void injectAuthentication( List repositories, List servers ) - { - } - - public void injectMirror( List repositories, List mirrors ) - { - } - - public void injectProxy( List repositories, List proxies ) - { - } - - public void publish( ArtifactRepository repository, File source, String remotePath, - ArtifactTransferListener transferListener ) - throws ArtifactTransferFailedException - { - // TODO Auto-generated method stub - - } - - public ArtifactResolutionResult resolve( ArtifactResolutionRequest request ) - { - ArtifactResolutionResult result = new ArtifactResolutionResult(); - - if ( request.isResolveRoot() ) - { - try - { - resolve( request.getArtifact(), request ); - result.addArtifact( request.getArtifact() ); - } - catch ( IOException e ) - { - result.addMissingArtifact( request.getArtifact() ); - } - } - - if ( request.isResolveTransitively() ) - { - Map artifacts = new LinkedHashMap<>(); - - if ( request.getArtifactDependencies() != null ) - { - for ( Artifact artifact : request.getArtifactDependencies() ) - { - artifacts.put( artifact.getDependencyConflictId(), artifact ); - } - } - - List dependencies = new ArrayList<>(); - if ( request.getArtifact() instanceof ArtifactWithDependencies ) - { - dependencies = ( (ArtifactWithDependencies) request.getArtifact() ).getDependencies(); - } - else - { - Artifact pomArtifact = - createProjectArtifact( request.getArtifact().getGroupId(), request.getArtifact().getArtifactId(), - request.getArtifact().getVersion() ); - File pomFile = - new File( request.getLocalRepository().getBasedir(), - request.getLocalRepository().pathOf( pomArtifact ) ); - - try - { - Model model = modelReader.read( pomFile, null ); - - dependencies = model.getDependencies(); - } - catch ( IOException e ) - { - e.printStackTrace(); - } - } - - for ( Dependency dependency : dependencies ) - { - Artifact artifact = createDependencyArtifact( dependency ); - if ( !artifacts.containsKey( artifact.getDependencyConflictId() ) ) - { - artifacts.put( artifact.getDependencyConflictId(), artifact ); - } - } - - for ( Artifact artifact : artifacts.values() ) - { - try - { - resolve( artifact, request ); - result.addArtifact( artifact ); - } - catch ( IOException e ) - { - result.addMissingArtifact( artifact ); - } - } - } - - return result; - } - - private void resolve( Artifact artifact, ArtifactResolutionRequest request ) - throws IOException - { - if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) ) - { - return; - } - - ArtifactRepository localRepo = request.getLocalRepository(); - - File localFile = new File( localRepo.getBasedir(), localRepo.pathOf( artifact ) ); - - artifact.setFile( localFile ); - - if ( !localFile.exists() ) - { - if ( request.getRemoteRepositories().isEmpty() ) - { - throw new IOException( localFile + " does not exist and no remote repositories are configured" ); - } - - ArtifactRepository remoteRepo = request.getRemoteRepositories().get( 0 ); - - File remoteFile = new File( remoteRepo.getBasedir(), remoteRepo.pathOf( artifact ) ); - - FileUtils.copyFile( remoteFile, localFile ); - } - - artifact.setResolved( true ); - } - - public void retrieve( ArtifactRepository repository, File destination, String remotePath, - ArtifactTransferListener transferListener ) - throws ArtifactTransferFailedException, ArtifactDoesNotExistException - { - // TODO Auto-generated method stub - - } - - public void injectMirror( RepositorySystemSession session, List repositories ) - { - } - - public void injectProxy( RepositorySystemSession session, List repositories ) - { - } - - public void injectAuthentication( RepositorySystemSession session, List repositories ) - { - } - -} diff --git a/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java b/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java index e13382b53224..6214f7374c69 100644 --- a/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java +++ b/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java @@ -24,12 +24,12 @@ import java.io.Reader; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; +import org.apache.maven.bridge.MavenRepositorySystem; import org.apache.maven.model.Profile; import org.apache.maven.project.DefaultProjectBuilder; import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.project.harness.PomTestWrapper; -import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.internal.MavenRepositorySystemUtils; import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader; import org.codehaus.plexus.testing.PlexusTest; @@ -57,7 +57,7 @@ public class PomConstructionWithSettingsTest private DefaultProjectBuilder projectBuilder; @Inject - private RepositorySystem repositorySystem; + private MavenRepositorySystem repositorySystem; private File testDirectory; diff --git a/maven-core/src/test/projects/lifecycle-executor/project-with-inheritance/pom.xml b/maven-core/src/test/projects/lifecycle-executor/project-with-inheritance/pom.xml index 5b51ce080911..ee50cc58d2d1 100644 --- a/maven-core/src/test/projects/lifecycle-executor/project-with-inheritance/pom.xml +++ b/maven-core/src/test/projects/lifecycle-executor/project-with-inheritance/pom.xml @@ -245,7 +245,6 @@ under the License. maven-mercury maven-embedder maven-toolchain - maven-compat maven-repository maven-repository-mercury @@ -323,11 +322,6 @@ under the License. maven-repository ${project.version} - - org.apache.maven - maven-compat - ${project.version} - diff --git a/maven-core/src/test/projects/plugin-manager/project-with-inheritance/pom.xml b/maven-core/src/test/projects/plugin-manager/project-with-inheritance/pom.xml index 5b51ce080911..ee50cc58d2d1 100644 --- a/maven-core/src/test/projects/plugin-manager/project-with-inheritance/pom.xml +++ b/maven-core/src/test/projects/plugin-manager/project-with-inheritance/pom.xml @@ -245,7 +245,6 @@ under the License. maven-mercury maven-embedder maven-toolchain - maven-compat maven-repository maven-repository-mercury @@ -323,11 +322,6 @@ under the License. maven-repository ${project.version} - - org.apache.maven - maven-compat - ${project.version} - diff --git a/maven-core/src/test/resources/org/apache/maven/lifecycle/pom.xml b/maven-core/src/test/resources/org/apache/maven/lifecycle/pom.xml index 39e165456d5f..1cede14fe997 100644 --- a/maven-core/src/test/resources/org/apache/maven/lifecycle/pom.xml +++ b/maven-core/src/test/resources/org/apache/maven/lifecycle/pom.xml @@ -245,7 +245,6 @@ under the License. maven-mercury maven-embedder maven-toolchain - maven-compat maven-repository maven-repository-mercury @@ -323,11 +322,6 @@ under the License. maven-repository ${project.version} - - org.apache.maven - maven-compat - ${project.version} - diff --git a/pom.xml b/pom.xml index c1bb3036b7d4..c063e8978a05 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,6 @@ under the License. maven-slf4j-provider maven-slf4j-wrapper maven-embedder - maven-compat apache-maven maven-wrapper apache-maven/maven-wrapper.pom @@ -188,11 +187,6 @@ under the License. pom import - - org.apache.maven - maven-compat - ${project.version} - org.apache.maven maven-slf4j-provider