[MNG-6685] Convert Maven Model Builder to JSR 330

This closes #256
This commit is contained in:
Joseph Walton 2019-06-17 22:13:19 +10:00 committed by Michael Osipov
parent 59bd396e6e
commit 353d3eaa8f
37 changed files with 213 additions and 119 deletions

View File

@ -27,16 +27,20 @@ import org.apache.maven.model.ActivationProperty;
import org.apache.maven.model.Profile;
import org.apache.maven.profiles.DefaultProfileManager;
import org.apache.maven.profiles.ProfileManager;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusTestCase;
public class DefaultProfileManagerTest
extends PlexusTestCase
{
public void setUp()
throws Exception
@Override
protected void customizeContainerConfiguration( ContainerConfiguration configuration )
{
super.setUp();
super.customizeContainerConfiguration( configuration );
configuration.setAutoWiring( true );
configuration.setClassPathScanning( PlexusConstants.SCANNING_ON );
}
public void testShouldActivateDefaultProfile()

View File

@ -28,13 +28,15 @@ import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
import org.apache.maven.project.artifact.DefaultMavenMetadataCache.CacheKey;
import org.apache.maven.repository.DelegatingLocalArtifactRepository;
import org.apache.maven.repository.RepositorySystem;
import org.codehaus.plexus.PlexusTestCase;
import org.apache.maven.repository.TestRepositorySystem;
import junit.framework.TestCase;
/**
* @author Igor Fedorenko
*/
public class DefaultMavenMetadataCacheTest
extends PlexusTestCase
extends TestCase
{
private RepositorySystem repositorySystem;
@ -42,7 +44,7 @@ public class DefaultMavenMetadataCacheTest
throws Exception
{
super.setUp();
repositorySystem = lookup( RepositorySystem.class );
repositorySystem = new TestRepositorySystem();
}
@Override

View File

@ -21,7 +21,9 @@ package org.apache.maven.project.artifact;
import org.apache.maven.repository.RepositorySystem;
import org.codehaus.plexus.PlexusTestCase;
import org.junit.Ignore;
@Ignore
public class MavenMetadataSourceTest
extends PlexusTestCase
{

View File

@ -28,15 +28,16 @@ import java.util.Comparator;
import java.util.List;
import org.apache.commons.cli.Option;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.FileUtils;
import junit.framework.TestCase;
/**
* Pseudo test to generate documentation fragment about supported CLI options. TODO such documentation generation code
* should not be necessary as unit test but should be run during site generation (Velocity? Doxia macro?)
*/
public class CLIManagerDocumentationTest
extends PlexusTestCase
extends TestCase
{
private final static String LS = System.getProperty( "line.separator" );
@ -100,7 +101,7 @@ public class CLIManagerDocumentationTest
public void testOptionsAsHtml()
throws IOException
{
File options = getTestFile( "target/test-classes/options.html" );
File options = new File( "target/test-classes/options.html" );
FileUtils.fileWrite( options, "UTF-8", getOptionsAsHtml() );
}

View File

@ -43,8 +43,8 @@ under the License.
<artifactId>plexus-interpolation</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-annotations</artifactId>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
@ -58,6 +58,10 @@ under the License.
<groupId>org.apache.maven</groupId>
<artifactId>maven-builder-support</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.inject</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>

View File

@ -59,10 +59,9 @@ import org.apache.maven.model.resolution.UnresolvableModelException;
import org.apache.maven.model.resolution.WorkspaceModelResolver;
import org.apache.maven.model.superpom.SuperPomProvider;
import org.apache.maven.model.validation.ModelValidator;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.interpolation.MapBasedValueSource;
import org.codehaus.plexus.interpolation.StringSearchInterpolator;
import org.eclipse.sisu.Nullable;
import java.io.File;
import java.io.IOException;
@ -76,65 +75,71 @@ import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import static org.apache.maven.model.building.Result.error;
import static org.apache.maven.model.building.Result.newResult;
/**
* @author Benjamin Bentmann
*/
@Component( role = ModelBuilder.class )
@Named
@Singleton
public class DefaultModelBuilder
implements ModelBuilder
{
@Requirement
@Inject
private ModelProcessor modelProcessor;
@Requirement
@Inject
private ModelValidator modelValidator;
@Requirement
@Inject
private ModelNormalizer modelNormalizer;
@Requirement
@Inject
private ModelInterpolator modelInterpolator;
@Requirement
@Inject
private ModelPathTranslator modelPathTranslator;
@Requirement
@Inject
private ModelUrlNormalizer modelUrlNormalizer;
@Requirement
@Inject
private SuperPomProvider superPomProvider;
@Requirement
@Inject
private InheritanceAssembler inheritanceAssembler;
@Requirement
@Inject
private ProfileSelector profileSelector;
@Requirement
@Inject
private ProfileInjector profileInjector;
@Requirement
@Inject
private PluginManagementInjector pluginManagementInjector;
@Requirement
@Inject
private DependencyManagementInjector dependencyManagementInjector;
@Requirement
@Inject
private DependencyManagementImporter dependencyManagementImporter;
@Requirement( optional = true )
@Inject
@Nullable
private LifecycleBindingsInjector lifecycleBindingsInjector;
@Requirement
@Inject
private PluginConfigurationExpander pluginConfigurationExpander;
@Requirement
@Inject
private ReportConfigurationExpander reportConfigurationExpander;
@Requirement
@Inject
private ReportingConverter reportingConverter;
public DefaultModelBuilder setModelProcessor( ModelProcessor modelProcessor )

View File

@ -25,24 +25,29 @@ import java.io.InputStream;
import java.io.Reader;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.ModelReader;
import org.apache.maven.model.locator.ModelLocator;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.eclipse.sisu.Typed;
/**
* DefaultModelProcessor
*/
@Component( role = ModelProcessor.class )
@Named
@Singleton
@Typed( ModelProcessor.class )
public class DefaultModelProcessor
implements ModelProcessor
{
@Requirement
@Inject
private ModelLocator locator;
@Requirement
@Inject
private ModelReader reader;
public DefaultModelProcessor setModelLocator( ModelLocator locator )

View File

@ -24,19 +24,22 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.Model;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.model.building.ModelProblemCollector;
import org.codehaus.plexus.component.annotations.Component;
/**
* Handles the import of dependency management from other models into the target model.
*
* @author Benjamin Bentmann
*/
@Component( role = DependencyManagementImporter.class )
@Named
@Singleton
public class DefaultDependencyManagementImporter
implements DependencyManagementImporter
{

View File

@ -26,6 +26,9 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.InputLocation;
import org.apache.maven.model.Model;
import org.apache.maven.model.ModelBase;
@ -36,7 +39,6 @@ import org.apache.maven.model.Reporting;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.model.building.ModelProblemCollector;
import org.apache.maven.model.merge.MavenModelMerger;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils;
/**
@ -45,7 +47,8 @@ import org.codehaus.plexus.util.StringUtils;
* @author Benjamin Bentmann
*/
@SuppressWarnings( { "checkstyle:methodname" } )
@Component( role = InheritanceAssembler.class )
@Named
@Singleton
public class DefaultInheritanceAssembler
implements InheritanceAssembler
{

View File

@ -27,6 +27,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import javax.inject.Inject;
import org.apache.maven.model.Model;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.model.building.ModelProblem.Severity;
@ -35,7 +37,6 @@ import org.apache.maven.model.building.ModelProblemCollector;
import org.apache.maven.model.building.ModelProblemCollectorRequest;
import org.apache.maven.model.path.PathTranslator;
import org.apache.maven.model.path.UrlNormalizer;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.interpolation.AbstractValueSource;
import org.codehaus.plexus.interpolation.InterpolationException;
import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
@ -86,10 +87,10 @@ public abstract class AbstractStringBasedModelInterpolator
TRANSLATED_PATH_EXPRESSIONS = translatedPrefixes;
}
@Requirement
@Inject
private PathTranslator pathTranslator;
@Requirement
@Inject
private UrlNormalizer urlNormalizer;
private Interpolator interpolator;

View File

@ -26,7 +26,6 @@ import org.apache.maven.model.building.ModelProblem.Severity;
import org.apache.maven.model.building.ModelProblem.Version;
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.interpolation.InterpolationPostProcessor;
import org.codehaus.plexus.interpolation.Interpolator;
import org.codehaus.plexus.interpolation.StringSearchInterpolator;
@ -45,10 +44,14 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.inject.Named;
import javax.inject.Singleton;
/**
* StringSearchModelInterpolator
*/
@Component( role = ModelInterpolator.class )
@Named
@Singleton
public class StringSearchModelInterpolator
extends AbstractStringBasedModelInterpolator
{

View File

@ -27,11 +27,13 @@ import java.io.Reader;
import java.util.Map;
import java.util.Objects;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.InputSource;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.model.io.xpp3.MavenXpp3ReaderEx;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.xml.XmlStreamReader;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@ -41,7 +43,8 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
*
* @author Benjamin Bentmann
*/
@Component( role = ModelReader.class )
@Named
@Singleton
public class DefaultModelReader
implements ModelReader
{

View File

@ -27,9 +27,11 @@ import java.io.Writer;
import java.util.Map;
import java.util.Objects;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.WriterFactory;
/**
@ -37,7 +39,8 @@ import org.codehaus.plexus.util.WriterFactory;
*
* @author Benjamin Bentmann
*/
@Component( role = ModelWriter.class )
@Named
@Singleton
public class DefaultModelWriter
implements ModelWriter
{

View File

@ -21,14 +21,16 @@ package org.apache.maven.model.locator;
import java.io.File;
import org.codehaus.plexus.component.annotations.Component;
import javax.inject.Named;
import javax.inject.Singleton;
/**
* Locates a POM file within a project base directory.
*
* @author Benjamin Bentmann
*/
@Component( role = ModelLocator.class )
@Named
@Singleton
public class DefaultModelLocator
implements ModelLocator
{

View File

@ -24,6 +24,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.Exclusion;
@ -31,7 +34,6 @@ import org.apache.maven.model.Model;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.model.building.ModelProblemCollector;
import org.apache.maven.model.merge.MavenModelMerger;
import org.codehaus.plexus.component.annotations.Component;
/**
* Handles injection of dependency management into the model.
@ -39,7 +41,8 @@ import org.codehaus.plexus.component.annotations.Component;
* @author Benjamin Bentmann
*/
@SuppressWarnings( { "checkstyle:methodname" } )
@Component( role = DependencyManagementInjector.class )
@Named
@Singleton
public class DefaultDependencyManagementInjector
implements DependencyManagementInjector
{

View File

@ -25,6 +25,9 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.Build;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
@ -34,7 +37,6 @@ import org.apache.maven.model.PluginManagement;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.model.building.ModelProblemCollector;
import org.apache.maven.model.merge.MavenModelMerger;
import org.codehaus.plexus.component.annotations.Component;
/**
* Handles injection of plugin management into the model.
@ -42,7 +44,8 @@ import org.codehaus.plexus.component.annotations.Component;
* @author Benjamin Bentmann
*/
@SuppressWarnings( { "checkstyle:methodname" } )
@Component( role = PluginManagementInjector.class )
@Named
@Singleton
public class DefaultPluginManagementInjector
implements PluginManagementInjector
{

View File

@ -25,6 +25,9 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.Build;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
@ -32,7 +35,6 @@ import org.apache.maven.model.Plugin;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.model.building.ModelProblemCollector;
import org.apache.maven.model.merge.MavenModelMerger;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils;
/**
@ -40,7 +42,8 @@ import org.codehaus.plexus.util.StringUtils;
*
* @author Benjamin Bentmann
*/
@Component( role = ModelNormalizer.class )
@Named
@Singleton
public class DefaultModelNormalizer
implements ModelNormalizer
{

View File

@ -23,25 +23,28 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
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.apache.maven.model.building.ModelBuildingRequest;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
/**
* Resolves relative paths within a model against a specific base directory.
*
* @author Benjamin Bentmann
*/
@Component( role = ModelPathTranslator.class )
@Named
@Singleton
public class DefaultModelPathTranslator
implements ModelPathTranslator
{
@Requirement
@Inject
private PathTranslator pathTranslator;
public DefaultModelPathTranslator setPathTranslator( PathTranslator pathTranslator )

View File

@ -19,13 +19,15 @@ package org.apache.maven.model.path;
* under the License.
*/
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Model;
import org.apache.maven.model.Scm;
import org.apache.maven.model.Site;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
/**
* Normalizes URLs to remove the ugly parent references "../" that got potentially inserted by URL adjustment during
@ -33,12 +35,13 @@ import org.codehaus.plexus.component.annotations.Requirement;
*
* @author Benjamin Bentmann
*/
@Component( role = ModelUrlNormalizer.class )
@Named
@Singleton
public class DefaultModelUrlNormalizer
implements ModelUrlNormalizer
{
@Requirement
@Inject
private UrlNormalizer urlNormalizer;
public DefaultModelUrlNormalizer setUrlNormalizer( UrlNormalizer urlNormalizer )

View File

@ -21,14 +21,16 @@ package org.apache.maven.model.path;
import java.io.File;
import org.codehaus.plexus.component.annotations.Component;
import javax.inject.Named;
import javax.inject.Singleton;
/**
* Resolves relative paths against a specific base directory.
*
* @author Benjamin Bentmann
*/
@Component( role = PathTranslator.class )
@Named
@Singleton
public class DefaultPathTranslator
implements PathTranslator
{

View File

@ -19,14 +19,16 @@ package org.apache.maven.model.path;
* under the License.
*/
import org.codehaus.plexus.component.annotations.Component;
import javax.inject.Named;
import javax.inject.Singleton;
/**
* Normalizes a URL.
*
* @author Benjamin Bentmann
*/
@Component( role = UrlNormalizer.class )
@Named
@Singleton
public class DefaultUrlNormalizer
implements UrlNormalizer
{

View File

@ -21,6 +21,9 @@ package org.apache.maven.model.plugin;
import java.util.List;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.Build;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
@ -28,7 +31,6 @@ import org.apache.maven.model.PluginExecution;
import org.apache.maven.model.PluginManagement;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.model.building.ModelProblemCollector;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.xml.Xpp3Dom;
/**
@ -36,7 +38,8 @@ import org.codehaus.plexus.util.xml.Xpp3Dom;
*
* @author Benjamin Bentmann
*/
@Component( role = PluginConfigurationExpander.class )
@Named
@Singleton
public class DefaultPluginConfigurationExpander
implements PluginConfigurationExpander
{

View File

@ -19,13 +19,15 @@ package org.apache.maven.model.plugin;
* under the License.
*/
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.Model;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.ReportSet;
import org.apache.maven.model.Reporting;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.model.building.ModelProblemCollector;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.xml.Xpp3Dom;
/**
@ -33,7 +35,8 @@ import org.codehaus.plexus.util.xml.Xpp3Dom;
*
* @author Benjamin Bentmann
*/
@Component( role = ReportConfigurationExpander.class )
@Named
@Singleton
public class DefaultReportConfigurationExpander
implements ReportConfigurationExpander
{

View File

@ -19,6 +19,9 @@ package org.apache.maven.model.plugin;
* under the License.
*/
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.Build;
import org.apache.maven.model.InputLocation;
import org.apache.maven.model.InputSource;
@ -33,7 +36,6 @@ import org.apache.maven.model.building.ModelProblemCollector;
import org.apache.maven.model.building.ModelProblemCollectorRequest;
import org.apache.maven.model.building.ModelProblem.Severity;
import org.apache.maven.model.building.ModelProblem.Version;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
@ -43,7 +45,8 @@ import org.codehaus.plexus.util.xml.Xpp3Dom;
*
* @author Benjamin Bentmann
*/
@Component( role = ReportingConverter.class )
@Named
@Singleton
public class DefaultReportingConverter
implements ReportingConverter
{

View File

@ -25,6 +25,9 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.Build;
import org.apache.maven.model.BuildBase;
import org.apache.maven.model.Model;
@ -39,14 +42,14 @@ import org.apache.maven.model.Reporting;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.model.building.ModelProblemCollector;
import org.apache.maven.model.merge.MavenModelMerger;
import org.codehaus.plexus.component.annotations.Component;
/**
* Handles profile injection into the model.
*
* @author Benjamin Bentmann
*/
@Component( role = ProfileInjector.class )
@Named
@Singleton
@SuppressWarnings( { "checkstyle:methodname" } )
public class DefaultProfileInjector
implements ProfileInjector

View File

@ -24,6 +24,10 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.Activation;
import org.apache.maven.model.Profile;
import org.apache.maven.model.building.ModelProblemCollector;
@ -31,20 +35,19 @@ import org.apache.maven.model.building.ModelProblem.Severity;
import org.apache.maven.model.building.ModelProblem.Version;
import org.apache.maven.model.building.ModelProblemCollectorRequest;
import org.apache.maven.model.profile.activation.ProfileActivator;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
/**
* Calculates the active profiles among a given collection of profiles.
*
* @author Benjamin Bentmann
*/
@Component( role = ProfileSelector.class )
@Named
@Singleton
public class DefaultProfileSelector
implements ProfileSelector
{
@Requirement( role = ProfileActivator.class )
@Inject
private List<ProfileActivator> activators = new ArrayList<>();
public DefaultProfileSelector addProfileActivator( ProfileActivator profileActivator )

View File

@ -21,6 +21,10 @@ package org.apache.maven.model.profile.activation;
import java.io.File;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.Activation;
import org.apache.maven.model.ActivationFile;
import org.apache.maven.model.Profile;
@ -30,8 +34,6 @@ import org.apache.maven.model.building.ModelProblem.Version;
import org.apache.maven.model.building.ModelProblemCollectorRequest;
import org.apache.maven.model.path.PathTranslator;
import org.apache.maven.model.profile.ProfileActivationContext;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.interpolation.AbstractValueSource;
import org.codehaus.plexus.interpolation.MapBasedValueSource;
import org.codehaus.plexus.interpolation.RegexBasedInterpolator;
@ -49,12 +51,13 @@ import org.codehaus.plexus.util.StringUtils;
* @see ActivationFile
* @see org.apache.maven.model.validation.DefaultModelValidator#validateRawModel
*/
@Component( role = ProfileActivator.class, hint = "file" )
@Named( "file" )
@Singleton
public class FileProfileActivator
implements ProfileActivator
{
@Requirement
@Inject
private PathTranslator pathTranslator;
public FileProfileActivator setPathTranslator( PathTranslator pathTranslator )

View File

@ -23,6 +23,9 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.Activation;
import org.apache.maven.model.Profile;
import org.apache.maven.model.building.ModelProblemCollector;
@ -30,7 +33,6 @@ import org.apache.maven.model.building.ModelProblem.Severity;
import org.apache.maven.model.building.ModelProblem.Version;
import org.apache.maven.model.building.ModelProblemCollectorRequest;
import org.apache.maven.model.profile.ProfileActivationContext;
import org.codehaus.plexus.component.annotations.Component;
/**
* Determines profile activation based on the version of the current Java runtime.
@ -38,7 +40,8 @@ import org.codehaus.plexus.component.annotations.Component;
* @author Benjamin Bentmann
* @see Activation#getJdk()
*/
@Component( role = ProfileActivator.class, hint = "jdk-version" )
@Named( "jdk-version" )
@Singleton
public class JdkVersionProfileActivator
implements ProfileActivator
{

View File

@ -19,12 +19,14 @@ package org.apache.maven.model.profile.activation;
* under the License.
*/
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.Activation;
import org.apache.maven.model.ActivationOS;
import org.apache.maven.model.Profile;
import org.apache.maven.model.building.ModelProblemCollector;
import org.apache.maven.model.profile.ProfileActivationContext;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.Os;
/**
@ -33,7 +35,8 @@ import org.codehaus.plexus.util.Os;
* @author Benjamin Bentmann
* @see ActivationOS
*/
@Component( role = ProfileActivator.class, hint = "os" )
@Named( "os" )
@Singleton
public class OperatingSystemProfileActivator
implements ProfileActivator
{

View File

@ -19,6 +19,9 @@ package org.apache.maven.model.profile.activation;
* under the License.
*/
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.Activation;
import org.apache.maven.model.ActivationProperty;
import org.apache.maven.model.Profile;
@ -27,7 +30,6 @@ import org.apache.maven.model.building.ModelProblem.Severity;
import org.apache.maven.model.building.ModelProblem.Version;
import org.apache.maven.model.building.ModelProblemCollectorRequest;
import org.apache.maven.model.profile.ProfileActivationContext;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils;
/**
@ -36,7 +38,8 @@ import org.codehaus.plexus.util.StringUtils;
* @author Benjamin Bentmann
* @see ActivationProperty
*/
@Component( role = ProfileActivator.class, hint = "property" )
@Named( "property" )
@Singleton
public class PropertyProfileActivator
implements ProfileActivator
{

View File

@ -24,18 +24,21 @@ import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.InputSource;
import org.apache.maven.model.Model;
import org.apache.maven.model.building.ModelProcessor;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
/**
* Provides the super POM that all models implicitly inherit from.
*
* @author Benjamin Bentmann
*/
@Component( role = SuperPomProvider.class )
@Named
@Singleton
public class DefaultSuperPomProvider
implements SuperPomProvider
{
@ -45,7 +48,7 @@ public class DefaultSuperPomProvider
*/
private Model superModel;
@Requirement
@Inject
private ModelProcessor modelProcessor;
public DefaultSuperPomProvider setModelProcessor( ModelProcessor modelProcessor )

View File

@ -45,7 +45,6 @@ import org.apache.maven.model.building.ModelProblem.Version;
import org.apache.maven.model.building.ModelProblemCollector;
import org.apache.maven.model.building.ModelProblemCollectorRequest;
import org.apache.maven.model.interpolation.AbstractStringBasedModelInterpolator;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
@ -58,10 +57,14 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.inject.Named;
import javax.inject.Singleton;
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*/
@Component( role = ModelValidator.class )
@Named
@Singleton
public class DefaultModelValidator
implements ModelValidator
{

View File

@ -21,12 +21,15 @@ package org.apache.maven.model.inheritance;
import org.apache.maven.model.Model;
import org.apache.maven.model.building.SimpleProblemCollector;
import org.apache.maven.model.io.DefaultModelReader;
import org.apache.maven.model.io.DefaultModelWriter;
import org.apache.maven.model.io.ModelReader;
import org.apache.maven.model.io.ModelWriter;
import org.codehaus.plexus.PlexusTestCase;
import org.xmlunit.matchers.CompareMatcher;
import junit.framework.TestCase;
import java.io.File;
import java.io.IOException;
@ -36,7 +39,7 @@ import static org.junit.Assert.assertThat;
* @author Hervé Boutemy
*/
public class DefaultInheritanceAssemblerTest
extends PlexusTestCase
extends TestCase
{
private ModelReader reader;
@ -50,14 +53,14 @@ public class DefaultInheritanceAssemblerTest
{
super.setUp();
reader = lookup( ModelReader.class );
writer = lookup( ModelWriter.class );
assembler = lookup( InheritanceAssembler.class );
reader = new DefaultModelReader();
writer = new DefaultModelWriter();
assembler = new DefaultInheritanceAssembler();
}
private File getPom( String name )
{
return getTestFile( "src/test/resources/poms/inheritance/" + name + ".xml" );
return new File( "src/test/resources/poms/inheritance/" + name + ".xml" );
}
private Model getModel( String name )
@ -201,7 +204,7 @@ public class DefaultInheritanceAssemblerTest
assembler.assembleModelInheritance( child, parent, null, problems );
// write baseName + "-actual"
File actual = getTestFile( "target/test-classes/poms/inheritance/" + baseName
File actual = new File( "target/test-classes/poms/inheritance/" + baseName
+ ( fromRepo ? "-build" : "-repo" ) + "-actual.xml" );
writer.write( actual, null, child );
@ -222,7 +225,7 @@ public class DefaultInheritanceAssemblerTest
assembler.assembleModelInheritance( child, parent, null, problems );
File actual = getTestFile( "target/test-classes/poms/inheritance/module-path-not-artifactId-actual.xml" );
File actual = new File( "target/test-classes/poms/inheritance/module-path-not-artifactId-actual.xml" );
writer.write( actual, null, child );

View File

@ -30,7 +30,8 @@ import org.apache.maven.model.building.DefaultModelBuildingRequest;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.model.building.SimpleProblemCollector;
import org.apache.maven.model.path.PathTranslator;
import org.codehaus.plexus.PlexusTestCase;
import junit.framework.TestCase;
import java.io.File;
import java.text.SimpleDateFormat;
@ -45,7 +46,7 @@ import java.util.TimeZone;
* @author jdcasey
*/
public abstract class AbstractModelInterpolatorTest
extends PlexusTestCase
extends TestCase
{
private Properties context;

View File

@ -48,7 +48,7 @@ public class StringSearchModelInterpolatorTest
throws Exception
{
super.setUp();
interpolator = lookup( ModelInterpolator.class );
interpolator = new StringSearchModelInterpolator();
}

View File

@ -27,8 +27,8 @@ import org.apache.maven.model.Profile;
import org.apache.maven.model.building.SimpleProblemCollector;
import org.apache.maven.model.profile.DefaultProfileActivationContext;
import org.apache.maven.model.profile.ProfileActivationContext;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.component.annotations.Component;
import junit.framework.TestCase;
/**
* Provides common services to test {@link ProfileActivator} implementations.
@ -36,20 +36,16 @@ import org.codehaus.plexus.component.annotations.Component;
* @author Benjamin Bentmann
*/
public abstract class AbstractProfileActivatorTest<T extends ProfileActivator>
extends PlexusTestCase
extends TestCase
{
private Class<T> activatorClass;
private String roleHint;
protected T activator;
public AbstractProfileActivatorTest( Class<T> activatorClass )
{
this.activatorClass = Objects.requireNonNull( activatorClass, "activatorClass cannot be null" );;
roleHint = activatorClass.getAnnotation( Component.class ).hint();
}
@Override
@ -58,7 +54,7 @@ public abstract class AbstractProfileActivatorTest<T extends ProfileActivator>
{
super.setUp();
activator = activatorClass.cast( lookup( ProfileActivator.class, roleHint ) );
activator = activatorClass.getConstructor().newInstance();
}
@Override

View File

@ -27,13 +27,14 @@ import org.apache.maven.model.building.DefaultModelBuildingRequest;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.model.building.SimpleProblemCollector;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.codehaus.plexus.PlexusTestCase;
import junit.framework.TestCase;
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*/
public class DefaultModelValidatorTest
extends PlexusTestCase
extends TestCase
{
private ModelValidator validator;
@ -94,7 +95,7 @@ public class DefaultModelValidatorTest
{
super.setUp();
validator = lookup( ModelValidator.class );
validator = new DefaultModelValidator();
}
@Override