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