You are viewing a plain text version of this content. The canonical link for it is here.
Posted to m2-dev@maven.apache.org by Jerome Lacoste <je...@coffeebreaks.org> on 2004/06/17 18:57:50 UTC
Re: cvs commit:
maven-components/maven-core/src/main/java/org/apache/maven/artifact/factory
DefaultMavenArtifactFactory.java MavenArtifactFactory.java
On Mon, 2004-06-14 at 17:43, jvanzyl@apache.org wrote:
> jvanzyl 2004/06/14 08:43:18
>
> Added: maven-core/src/main/java/org/apache/maven/artifact/factory
> DefaultMavenArtifactFactory.java
> MavenArtifactFactory.java
> Log:
> o move from artifact
>
> Revision Changes Path
> 1.1 maven-components/maven-core/src/main/java/org/apache/maven/artifact/factory/DefaultMavenArtifactFactory.java
>
> Index: DefaultMavenArtifactFactory.java
> ===================================================================
> package org.apache.maven.artifact.factory;
>
> /*
> * Copyright 2001-2004 The Apache Software Foundation.
> *
> * Licensed 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.GenericMavenArtifact;
> import org.apache.maven.artifact.MavenArtifact;
> import org.apache.maven.model.Dependency;
> import org.apache.maven.project.MavenProject;
> import org.codehaus.plexus.util.StringUtils;
>
> import java.io.File;
> import java.util.ArrayList;
> import java.util.Iterator;
> import java.util.List;
>
> public class DefaultMavenArtifactFactory
> implements MavenArtifactFactory
> {
> public List createArtifacts( MavenProject project )
> {
> List projectArtifacts = new ArrayList();
>
> String mavenRepoLocal = project.getLocalRepository();
>
> boolean mavenJarOverride = project.getBooleanProperty( "maven.jar.override" );
>
> for ( Iterator i = project.getDependencies().iterator(); i.hasNext(); )
> {
> Dependency d = (Dependency) i.next();
>
> String mavenJarProperty = project.getProperty( "maven.jar." + MavenProject.standardToLegacyId( d.getId() ) );
>
> MavenArtifact artifact = createArtifact( d );
>
> if ( mavenJarOverride && StringUtils.isNotEmpty(mavenJarProperty) )
> {
> // The jar override option has been set and we have a property
> // for the this dependency so override the path with the user
> // specified value.
> if ( Character.isDigit( mavenJarProperty.charAt( 0 ) ) )
> {
> // User is requesting a specific version of a dependency
> // be used.
> d.setVersion( mavenJarProperty );
>
> artifact.setPath( mavenRepoLocal + artifact.generatePath() );
> }
> else
> {
> // User is requesting a specific path to a dependency
> // be used.
> artifact.setPath( new File( mavenJarProperty ).getAbsolutePath() );
> }
> }
> else
> {
> artifact.setPath( mavenRepoLocal + artifact.generatePath() );
> }
>
> project.setDependencyPath( artifact.getDependency().getArtifactId(), artifact.getPath() );
>
> projectArtifacts.add( artifact );
> }
>
> return projectArtifacts;
> }
>
> public MavenArtifact createArtifact( Dependency dependency )
> {
> if ( dependency.getType() == null
> || dependency.getType().trim().length() == 0
> || dependency.getType().equals( "jar" )
> || dependency.getType().equals( "test" ) )
> {
> dependency.setType( "jar" );
> return new GenericMavenArtifact( dependency );
> }
> else
> {
> return new GenericMavenArtifact( dependency );
> }
> }
return createArtifact( dependency, null );
> public MavenArtifact createArtifact( Dependency dependency, String mavenRepoLocal )
> {
>
> MavenArtifact retValue = null;
>
> if ( dependency.getType() == null
> || dependency.getType().trim().length() == 0
> || dependency.getType().equals( "jar" )
> || dependency.getType().equals( "test" ) )
> {
> dependency.setType( "jar" );
> retValue = new GenericMavenArtifact( dependency );
> }
> else
> {
> retValue = new GenericMavenArtifact( dependency );
> }
add here:
if (mavenRepoLocal != null)
{
> retValue.setPath( mavenRepoLocal + retValue.generatePath() );
}
>
> return retValue;
> }