o using annos

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@721759 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2008-11-30 05:18:34 +00:00
parent 9bc9c86231
commit 4f5cdce538
19 changed files with 96 additions and 302 deletions

View File

@ -76,6 +76,10 @@ under the License.
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.modello</groupId>
<artifactId>modello-maven-plugin</artifactId>

View File

@ -26,7 +26,10 @@ import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.model.DeploymentRepository;
import org.apache.maven.model.Repository;
import org.apache.maven.model.RepositoryPolicy;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.MissingRepositoryElementException;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import java.util.ArrayList;
import java.util.Iterator;
@ -35,9 +38,11 @@ import java.util.List;
/**
* @author Jason van Zyl
*/
@Component(role = MavenTools.class)
public class DefaultMavenTools
implements MavenTools
{
@Requirement
private ArtifactRepositoryFactory artifactRepositoryFactory;
// ----------------------------------------------------------------------------

View File

@ -20,6 +20,7 @@ package org.apache.maven.profiles;
*/
import org.apache.maven.profiles.io.xpp3.ProfilesXpp3Reader;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.ReaderFactory;
@ -33,6 +34,7 @@ import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
@Component(role = MavenProfilesBuilder.class)
public class DefaultMavenProfilesBuilder
extends AbstractLogEnabled
implements MavenProfilesBuilder

View File

@ -21,7 +21,9 @@ package org.apache.maven.profiles.activation;
import org.apache.maven.model.Profile;
import org.apache.maven.profiles.AlwaysOnActivation;
import org.codehaus.plexus.component.annotations.Component;
@Component(role = ProfileActivator.class, hint = "always-on")
public class AlwaysOnProfileActivator
implements ProfileActivator
{

View File

@ -24,6 +24,8 @@ import org.apache.maven.model.ActivationCustom;
import org.apache.maven.model.Profile;
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.configurator.BasicComponentConfigurator;
import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
import org.codehaus.plexus.component.configurator.ComponentConfigurator;
@ -44,10 +46,11 @@ import org.codehaus.plexus.util.xml.Xpp3Dom;
* in configuring the activator. This activator will lookup/configure custom activators on-the-fly,
* without caching any of the lookups from the container.
*/
@Component(role = ProfileActivator.class, hint = "custom")
public class CustomActivator
implements ProfileActivator, Contextualizable, LogEnabled
implements ProfileActivator, LogEnabled
{
@Requirement
private PlexusContainer container;
private Logger logger;
@ -125,12 +128,6 @@ public class CustomActivator
return activator.isActive( profile, context );
}
public void contextualize( Context context )
throws ContextException
{
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
}
protected Logger getLogger()
{
if ( logger == null )

View File

@ -22,6 +22,7 @@ package org.apache.maven.profiles.activation;
import org.apache.maven.model.Activation;
import org.apache.maven.model.ActivationFile;
import org.apache.maven.model.Profile;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.interpolation.EnvarBasedValueSource;
import org.codehaus.plexus.interpolation.InterpolationException;
import org.codehaus.plexus.interpolation.MapBasedValueSource;
@ -33,6 +34,7 @@ import org.codehaus.plexus.util.StringUtils;
import java.io.IOException;
@Component(role = ProfileActivator.class, hint = "file")
public class FileProfileActivator
implements ProfileActivator, LogEnabled
{

View File

@ -21,12 +21,14 @@ package org.apache.maven.profiles.activation;
import org.apache.maven.model.Activation;
import org.apache.maven.model.Profile;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@Component(role = ProfileActivator.class, hint = "jdk-prefix")
public class JdkPrefixProfileActivator
extends DetectedProfileActivator
{

View File

@ -22,8 +22,10 @@ package org.apache.maven.profiles.activation;
import org.apache.maven.model.Activation;
import org.apache.maven.model.ActivationOS;
import org.apache.maven.model.Profile;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.Os;
@Component(role = ProfileActivator.class, hint = "os")
public class OperatingSystemProfileActivator
implements ProfileActivator
{

View File

@ -22,10 +22,12 @@ package org.apache.maven.profiles.activation;
import org.apache.maven.model.Activation;
import org.apache.maven.model.ActivationProperty;
import org.apache.maven.model.Profile;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils;
import java.util.Properties;
@Component(role = ProfileActivator.class, hint = "system-property")
public class SystemPropertyProfileActivator
extends DetectedProfileActivator
{

View File

@ -37,6 +37,8 @@ import org.apache.maven.profiles.injection.ProfileInjector;
import org.apache.maven.project.ProjectBuildingException;
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.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.logging.LogEnabled;
@ -51,18 +53,22 @@ import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
@Component(role = ProfileAdvisor.class)
public class DefaultProfileAdvisor
implements ProfileAdvisor, LogEnabled, Contextualizable
{
public static final String ROLE_HINT = "default";
@Requirement
private MavenTools mavenTools;
@Requirement
private MavenProfilesBuilder profilesBuilder;
@Requirement
private ProfileInjector profileInjector;
@Requirement
private PlexusContainer container;
private Logger logger;
@ -71,8 +77,6 @@ public class DefaultProfileAdvisor
ProfileActivationContext activationContext )
throws ProjectBuildingException
{
// logger.debug( "Building profile manager for model: " + model.getId() + " with pom file: "
// + pomFile );
ProfileManager profileManager = buildProfileManager( model, pomFile, useProfilesXml, activationContext );
return applyActivatedProfiles( model, pomFile, profileManager );
@ -86,9 +90,6 @@ public class DefaultProfileAdvisor
return Collections.EMPTY_LIST;
}
// logger.debug( "Building profile manager for model: " + model.getId()
// + " with external profile manager including profiles: "
// + externalProfileManager.getProfilesById() );
return applyActivatedProfiles( model, projectDir, externalProfileManager );
}

View File

@ -21,6 +21,7 @@ package org.apache.maven.profiles.injection;
import org.apache.maven.model.*;
import org.apache.maven.project.ModelUtils;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
@ -46,10 +47,10 @@ import java.util.Properties;
* in the code to justify the extra code involved with separating them, in order to simplify
* the logic.
*/
@Component(role = ProfileInjector.class)
public class DefaultProfileInjector
implements ProfileInjector
{
public void inject( Profile profile, Model model )
{
@ -58,8 +59,6 @@ public class DefaultProfileInjector
injectModules( profile, model );
model.setRepositories( ModelUtils.mergeRepositoryLists( profile.getRepositories(), model.getRepositories() ) );
// model.setPluginRepositories( ModelUtils.mergeRepositoryLists( profile.getPluginRepositories(), model
// .getPluginRepositories() ) );
injectReporting( profile, model );

View File

@ -44,6 +44,8 @@ import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.project.builder.*;
import org.apache.maven.project.validation.ModelValidationResult;
import org.apache.maven.project.validation.ModelValidator;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
@ -65,30 +67,39 @@ import java.text.SimpleDateFormat;
/**
* @version $Id$
*/
@Component(role = MavenProjectBuilder.class)
public class DefaultMavenProjectBuilder
implements MavenProjectBuilder, Initializable, LogEnabled
{
@Requirement
protected MavenProfilesBuilder profilesBuilder;
@Requirement
protected ArtifactResolver artifactResolver;
@Requirement
protected ArtifactMetadataSource artifactMetadataSource;
@Requirement
private ArtifactFactory artifactFactory;
@Requirement
private ModelValidator validator;
// TODO: make it a component
private MavenXpp3Reader modelReader;
@Requirement
private ProfileAdvisor profileAdvisor;
@Requirement
private MavenTools mavenTools;
@Requirement
private ProjectBuilder projectBuilder;
@Requirement
private RepositoryHelper repositoryHelper;
private MavenXpp3Reader modelReader;
private Logger logger;
//DO NOT USE, it is here only for backward compatibility reasons. The existing

View File

@ -28,6 +28,8 @@ import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.model.Resource;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import java.io.File;
@ -35,11 +37,12 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
@Component(role = MavenProjectHelper.class)
public class DefaultMavenProjectHelper
extends AbstractLogEnabled
implements MavenProjectHelper
{
@Requirement
private ArtifactHandlerManager artifactHandlerManager;
public void attachArtifact( MavenProject project, String artifactType, String artifactClassifier,

View File

@ -36,6 +36,8 @@ import org.apache.maven.model.Repository;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.profiles.activation.ProfileActivationContext;
import org.apache.maven.profiles.build.ProfileAdvisor;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
@ -56,22 +58,26 @@ import java.util.*;
* This is a temporary class. These methods are originally from the DefaultMavenProjectHelper. This class will be
* eliminated when Mercury is integrated.
*/
@Component(role = RepositoryHelper.class)
public class DefaultRepositoryHelper
implements RepositoryHelper, Initializable, LogEnabled
{
@Requirement
private ArtifactFactory artifactFactory;
@Requirement
private ArtifactResolver artifactResolver;
@Requirement
private MavenTools mavenTools;
@Requirement
private ProfileAdvisor profileAdvisor;
private Logger logger;
public static final String MAVEN_MODEL_VERSION = "4.0.0";
private ArtifactFactory artifactFactory;
private ArtifactResolver artifactResolver;
private MavenTools mavenTools;
private ProfileAdvisor profileAdvisor;
private MavenXpp3Reader modelReader;
private static HashMap<String, Artifact> cache = new HashMap<String, Artifact>();

View File

@ -41,6 +41,7 @@ import org.apache.maven.model.Dependency;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Exclusion;
import org.apache.maven.model.Relocation;
import org.apache.maven.profiles.activation.ProfileActivator;
import org.apache.maven.project.DefaultProjectBuilderConfiguration;
import org.apache.maven.project.InvalidProjectModelException;
import org.apache.maven.project.MavenProject;
@ -49,6 +50,8 @@ import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.project.validation.ModelValidationResult;
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;
@ -64,23 +67,28 @@ import java.util.*;
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
@Component(role = ArtifactMetadataSource.class )
public class MavenMetadataSource
extends AbstractLogEnabled
implements ArtifactMetadataSource, Contextualizable
{
public static final String ROLE_HINT = "default";
private MavenProjectBuilder mavenProjectBuilder;
@Requirement
private ArtifactFactory artifactFactory;
@Requirement
private RepositoryMetadataManager repositoryMetadataManager;
// lazily instantiated and cached.
private MavenProject superProject;
@Requirement
private PlexusContainer container;
//!! not injected which is a problem
private MavenProjectBuilder mavenProjectBuilder;
/**
* Unfortunately we have projects that are still sending us JARs without the accompanying POMs.
*/

View File

@ -50,32 +50,32 @@ import org.apache.maven.shared.model.ImportModel;
import org.apache.maven.shared.model.InterpolatorProperty;
import org.apache.maven.shared.model.ModelEventListener;
import org.apache.maven.shared.model.ModelTransformerContext;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.Logger;
/**
* Default implementation of the project builder.
*/
@Component(role = ProjectBuilder.class)
public final class DefaultProjectBuilder
implements ProjectBuilder, LogEnabled
{
@Requirement
private ArtifactFactory artifactFactory;
/**
* Logger instance
*/
private Logger logger;
@Requirement
private ModelValidator validator;
@Requirement
private MavenTools mavenTools;
@Requirement
List<ModelEventListener> listeners;
/**
* Default constructor
*/
private Logger logger;
public DefaultProjectBuilder()
{
}

View File

@ -27,7 +27,9 @@ import java.util.List;
import org.apache.maven.model.Build;
import org.apache.maven.model.Model;
import org.apache.maven.model.Resource;
import org.codehaus.plexus.component.annotations.Component;
@Component(role = PathTranslator.class)
public class DefaultPathTranslator
implements PathTranslator
{

View File

@ -30,6 +30,8 @@ import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.Reporting;
import org.apache.maven.model.Repository;
import org.apache.maven.model.Resource;
import org.apache.maven.profiles.activation.ProfileActivator;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
@ -40,14 +42,12 @@ import java.util.List;
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
* @version $Id$
*/
@Component(role = ModelValidator.class )
public class DefaultModelValidator
implements ModelValidator
{
private static final String ID_REGEX = "[A-Za-z0-9_\\-.]+";
///////////////////////////////////////////////////////////////////////////
// ModelValidator Implementation
public ModelValidationResult validate( Model model )
{
ModelValidationResult result = new ModelValidationResult();

View File

@ -19,259 +19,5 @@ under the License.
<component-set>
<components>
<component>
<role>org.apache.maven.project.path.PathTranslator</role>
<implementation>org.apache.maven.project.path.DefaultPathTranslator</implementation>
</component>
<component>
<role>org.apache.maven.profiles.MavenProfilesBuilder</role>
<implementation>org.apache.maven.profiles.DefaultMavenProfilesBuilder</implementation>
</component>
<component>
<role>org.apache.maven.profiles.build.ProfileAdvisor</role>
<role-hint>default</role-hint>
<implementation>org.apache.maven.profiles.build.DefaultProfileAdvisor</implementation>
<requirements>
<requirement>
<role>org.apache.maven.MavenTools</role>
</requirement>
<requirement>
<role>org.apache.maven.profiles.MavenProfilesBuilder</role>
</requirement>
<requirement>
<role>org.apache.maven.profiles.injection.ProfileInjector</role>
</requirement>
</requirements>
</component>
<!--
|
|
|
-->
<component>
<role>org.apache.maven.project.MavenProjectHelper</role>
<implementation>org.apache.maven.project.DefaultMavenProjectHelper</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
</requirements>
</component>
<!--
|
|
|
-->
<component>
<role>org.apache.maven.profiles.injection.ProfileInjector</role>
<implementation>org.apache.maven.profiles.injection.DefaultProfileInjector</implementation>
</component>
<!--
|
|
|
-->
<component>
<role>org.apache.maven.project.builder.ProjectBuilder</role>
<role-hint>default</role-hint>
<implementation>org.apache.maven.project.builder.impl.DefaultProjectBuilder</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.MavenTools</role>
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.project.MavenProjectBuilder</role>
<role-hint>default</role-hint>
<implementation>org.apache.maven.project.DefaultMavenProjectBuilder</implementation>
<requirements>
<requirement>
<role>org.apache.maven.project.RepositoryHelper</role>
</requirement>
<requirement>
<role>org.apache.maven.project.builder.ProjectBuilder</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
</requirement>
<requirement>
<role>org.apache.maven.profiles.build.ProfileAdvisor</role>
</requirement>
<requirement>
<role>org.apache.maven.profiles.MavenProfilesBuilder</role>
</requirement>
<requirement>
<role>org.apache.maven.project.validation.ModelValidator</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
<role-hint>default</role-hint>
</requirement>
<requirement>
<role>org.apache.maven.MavenTools</role>
</requirement>
</requirements>
</component>
<!--Eliminate this component after Mercury Integration-->
<component>
<role>org.apache.maven.project.RepositoryHelper</role>
<implementation>org.apache.maven.project.DefaultRepositoryHelper</implementation>
<requirements>
<requirement>
<role>org.apache.maven.profiles.build.ProfileAdvisor</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
<role-hint>default</role-hint>
</requirement>
<requirement>
<role>org.apache.maven.MavenTools</role>
</requirement>
</requirements>
</component>
<!--
|
|
|
-->
<component>
<role>org.apache.maven.profiles.activation.ProfileActivator</role>
<role-hint>always-on</role-hint>
<implementation>org.apache.maven.profiles.activation.AlwaysOnProfileActivator</implementation>
</component>
<!--
|
|
|
-->
<component>
<role>org.apache.maven.profiles.activation.ProfileActivator</role>
<role-hint>jdk-prefix</role-hint>
<implementation>org.apache.maven.profiles.activation.JdkPrefixProfileActivator</implementation>
</component>
<!--
|
|
|
-->
<component>
<role>org.apache.maven.profiles.activation.ProfileActivator</role>
<role-hint>system-property</role-hint>
<implementation>org.apache.maven.profiles.activation.SystemPropertyProfileActivator</implementation>
</component>
<!--
|
|
|
-->
<component>
<role>org.apache.maven.profiles.activation.ProfileActivator</role>
<role-hint>os</role-hint>
<implementation>org.apache.maven.profiles.activation.OperatingSystemProfileActivator</implementation>
</component>
<!--
|
|
|
-->
<component>
<role>org.apache.maven.profiles.activation.ProfileActivator</role>
<role-hint>file</role-hint>
<implementation>org.apache.maven.profiles.activation.FileProfileActivator</implementation>
</component>
<!--
|
|
|
-->
<component>
<role>org.apache.maven.profiles.activation.ProfileActivator</role>
<role-hint>custom</role-hint>
<implementation>org.apache.maven.profiles.activation.CustomActivator</implementation>
</component>
<!--
|
|
|
-->
<component>
<role>org.apache.maven.project.validation.ModelValidator</role>
<implementation>org.apache.maven.project.validation.DefaultModelValidator</implementation>
</component>
<!-- ********************* FIXME *******************************************
| I realize this is duplicated but allows the project builder to work by itself
-->
<component>
<role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
<role-hint>maven</role-hint>
<implementation>org.apache.maven.project.artifact.MavenMetadataSource</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager</role>
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
<role-hint>maven-strict</role-hint>
<implementation>org.apache.maven.project.artifact.MavenMetadataSource</implementation>
<configuration>
<strictlyEnforceThePresenceOfAValidMavenPOM>true</strictlyEnforceThePresenceOfAValidMavenPOM>
</configuration>
<requirements>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager</role>
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
<role-hint>default</role-hint>
<implementation>org.apache.maven.project.artifact.MavenMetadataSource</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager</role>
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.MavenTools</role>
<implementation>org.apache.maven.DefaultMavenTools</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
</requirement>
</requirements>
</component>
</components>
</component-set>