maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: svn commit: r810121 - in /maven/plugins/trunk/maven-remote-resources-plugin/src: main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java test/java/org/apache/maven/plugin/resources/remote/RemoteResourcesMojoTest.java
Date Tue, 01 Sep 2009 17:22:07 GMT
On Tue September 1 2009 12:58:52 pm Jason van Zyl wrote:
> I can't tell from the issue what it is exactly you're trying to
> accomplish?

Well, the "goal" is to eventually be able to use the Apache parent pom for 
CXF.   Right now, we cannot.   

We have to be able to specify different supplemental models in different parts 
of the maven build.   Example:  the first module in our reactor is our 
buildtools module that actually packages up the supplemental models into a jar 
that the rest of the build then uses.

To load it in the other modules, we currently have to have a direct dependency 
on the buildtools module:
<plugin>
                <artifactId>maven-remote-resources-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.cxf</groupId>
                        <artifactId>cxf-buildtools</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                </dependencies>
....


However, to accomplish that, we HAVE to make sure the remote-resources is NOT 
loaded in buildtools.   Otherwise, due to the bug in maven that doesn't re-
evaluate plugin dependencies after the first load, the subsequent modules 
would not be able to get the supplements.    When we use the Apache parent, 
buildtools ends up with remote-resources running and then all the rest of the 
remote-resources invokations break.

The goal is basically to make it so we don't need to have a direct dependency 
on the artifact.   We DON'T currently need a direct dependency on the artifact 
for the actual resource bundle, why do we need one for the supplements?  
That's what it fixes.   

We either need the bug in maven fixed (and on 2.0.x) or we need this fixed or 
we just say Apache parent is useless for us.   We've BEEN saying Apache parent 
is useless, but I want to change that.

Does that answer the question?

Dan



> On 2009-09-01, at 11:55 AM, dkulp@apache.org wrote:
> > Author: dkulp
> > Date: Tue Sep  1 16:55:14 2009
> > New Revision: 810121
> >
> > URL: http://svn.apache.org/viewvc?rev=810121&view=rev
> > Log:
> > [MRRESOURCES-43] Add ability to load supplimental models from remote
> > artifacts and not direct dependencies of the plugin
> >
> > Modified:
> >    maven/plugins/trunk/maven-remote-resources-plugin/src/main/java/
> > org/apache/maven/plugin/resources/remote/
> > ProcessRemoteResourcesMojo.java
> >    maven/plugins/trunk/maven-remote-resources-plugin/src/test/java/
> > org/apache/maven/plugin/resources/remote/RemoteResourcesMojoTest.java
> >
> > Modified: maven/plugins/trunk/maven-remote-resources-plugin/src/main/
> > java/org/apache/maven/plugin/resources/remote/
> > ProcessRemoteResourcesMojo.java
> > URL:
> > http://svn.apache.org/viewvc/maven/plugins/trunk/maven-remote-resources-p
> >lugin/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemote
> >ResourcesMojo.java?rev=810121&r1=810120&r2=810121&view=diff =
> > =
> > =
> > =
> > =
> > =
> > =
> > =
> > ======================================================================
> > --- maven/plugins/trunk/maven-remote-resources-plugin/src/main/java/
> > org/apache/maven/plugin/resources/remote/
> > ProcessRemoteResourcesMojo.java (original)
> > +++ maven/plugins/trunk/maven-remote-resources-plugin/src/main/java/
> > org/apache/maven/plugin/resources/remote/
> > ProcessRemoteResourcesMojo.java Tue Sep  1 16:55:14 2009
> > @@ -237,9 +237,19 @@
> >     private String[] supplementalModels;
> >
> >     /**
> > +     * List of artifacts that are added to the search path when
> > looking
> > +     * for supplementalModels
> > +     * @parameter
> > +     * @since 1.1
> > +     */
> > +    private List supplementalModelArtifacts;
> > +
> > +    /**
> >      * Map of artifacts to supplemental project object models.
> >      */
> >     private Map supplementModels;
> > +
> > +
> >
> >     /**
> >      * Merges supplemental data model with artifact
> > @@ -269,7 +279,7 @@
> >     private boolean skip;
> >
> >     /**
> > -     * Skip remote-resource processing
> > +     * Attaches the resource to the project as a resource directory
> >      *
> >      * @parameter default-value="true"
> >      * @since 1.0-beta-1
> > @@ -466,6 +476,7 @@
> >             }
> >         }
> >
> > +        addSupplementalModelArtifacts();
> >         locator.addSearchPath( FileResourceLoader.ID, project.getFile
> > ().getParentFile().getAbsolutePath() );
> >         if ( appendedResourcesDirectory != null )
> >         {
> > @@ -481,7 +492,7 @@
> >
> >             validate();
> >
> > -            List resourceBundleArtifacts = downloadResourceBundles
> > ( resourceBundles );
> > +            List resourceBundleArtifacts = downloadBundles
> > ( resourceBundles );
> >             supplementModels = loadSupplements( supplementalModels );
> >
> >             VelocityContext context = new VelocityContext
> > ( properties );
> > @@ -531,6 +542,38 @@
> >         }
> >     }
> >
> > +    private void addSupplementalModelArtifacts() throws
> > MojoExecutionException
> > +    {
> > +        if ( supplementalModelArtifacts != null && !
> > supplementalModelArtifacts.isEmpty() )
> > +        {
> > +            List artifacts = downloadBundles
> > ( supplementalModelArtifacts );
> > +
> > +            for ( Iterator i = artifacts.iterator(); i.hasNext(); )
> > +            {
> > +                File artifact = (File) i.next();
> > +
> > +                if ( artifact.isDirectory() )
> > +                {
> > +                    locator.addSearchPath( FileResourceLoader.ID,
> > artifact.getAbsolutePath() );
> > +                }
> > +                else
> > +                {
> > +                    try
> > +                    {
> > +                        locator.addSearchPath( "jar", "jar:" +
> > artifact.toURL().toExternalForm() );
> > +                    }
> > +                    catch (MalformedURLException e)
> > +                    {
> > +                        throw new MojoExecutionException( "Could
> > not use jar "
> > +                                                          +
> > artifact.getAbsolutePath(), e );
> > +                    }
> > +                }
> > +            }
> > +
> > +
> > +        }
> > +    }
> > +
> >     protected List getProjects()
> >         throws MojoExecutionException
> >     {
> > @@ -925,24 +968,44 @@
> >         }
> >     }
> >
> > -    private List downloadResourceBundles( List resourceBundles )
> > +    private List downloadBundles( List bundles )
> >         throws MojoExecutionException
> >     {
> > -        List resourceBundleArtifacts = new ArrayList();
> > +        List bundleArtifacts = new ArrayList();
> >
> >         try
> >         {
> > -            for ( Iterator i = resourceBundles.iterator(); i.hasNext
> > (); )
> > +            for ( Iterator i = bundles.iterator(); i.hasNext(); )
> >             {
> >                 String artifactDescriptor = (String) i.next();
> >                 // groupId:artifactId:version
> >                 String[] s = artifactDescriptor.split( ":" );
> > -                File artifact = downloader.download( s[0], s[1], s
> > [2], localRepository,
> > +                File artifact = null;
> > +                //check if the artifact is part of the reactor
> > +                if ( mavenSession != null )
> > +                {
> > +                    List list = mavenSession.getSortedProjects();
> > +                    Iterator it = list.iterator();
> > +                    while ( it.hasNext() )
> > +                    {
> > +                        MavenProject p = (MavenProject) it.next();
> > +                        if ( s[0].equals( p.getGroupId() )
> > +                            && s[1].equals( p.getArtifactId() )
> > +                            && s[2].equals( p.getVersion() ) )
> > +                        {
> > +                            artifact = new File( p.getBuild
> > ().getOutputDirectory() );
> > +                        }
> > +                    }
> > +                }
> > +                if ( artifact == null || !artifact.exists() )
> > +                {
> > +                    artifact = downloader.download( s[0], s[1], s
> > [2], localRepository,
> >
> > ProjectUtils.buildArtifactRepositories( repositories,
> >                                                                          
> >                    artifactRepositoryFactory ,
> >                                                                          
> >                    mavenSession.getContainer () ) );
> > +                }
> >
> > -                resourceBundleArtifacts.add( artifact );
> > +                bundleArtifacts.add( artifact );
> >             }
> >         }
> >         catch ( DownloadException e )
> > @@ -958,7 +1021,7 @@
> >             throw new MojoExecutionException( "Resources JAR cannot
> > be found.", e );
> >         }
> >
> > -        return resourceBundleArtifacts;
> > +        return bundleArtifacts;
> >     }
> >
> >     private void initalizeClassloader( RemoteResourcesClassLoader
> > cl, List artifacts )
> >
> > Modified: maven/plugins/trunk/maven-remote-resources-plugin/src/test/
> > java/org/apache/maven/plugin/resources/remote/
> > RemoteResourcesMojoTest.java
> > URL:
> > http://svn.apache.org/viewvc/maven/plugins/trunk/maven-remote-resources-p
> >lugin/src/test/java/org/apache/maven/plugin/resources/remote/RemoteResourc
> >esMojoTest.java?rev=810121&r1=810120&r2=810121&view=diff =
> > =
> > =
> > =
> > =
> > =
> > =
> > =
> > ======================================================================
> > --- maven/plugins/trunk/maven-remote-resources-plugin/src/test/java/
> > org/apache/maven/plugin/resources/remote/
> > RemoteResourcesMojoTest.java (original)
> > +++ maven/plugins/trunk/maven-remote-resources-plugin/src/test/java/
> > org/apache/maven/plugin/resources/remote/
> > RemoteResourcesMojoTest.java Tue Sep  1 16:55:14 2009
> > @@ -24,6 +24,7 @@
> > import org.apache.maven.artifact.repository.ArtifactRepository;
> > import org.apache.maven.artifact.versioning.VersionRange;
> > import org.apache.maven.execution.MavenSession;
> > +import org.apache.maven.execution.ReactorManager;
> > import
> > org.apache.maven.plugin.resources.remote.stub.MavenProjectResourcesStub
> > ;
> > import org.apache.maven.plugin.testing.AbstractMojoTestCase;
> > import org.apache.maven.project.MavenProject;
> > @@ -385,7 +386,7 @@
> >                                     null, //Settings settings,
> >                                     null, //ArtifactRepository
> > localRepository,
> >                                     null, //EventDispatcher
> > eventDispatcher,
> > -                                    null, //ReactorManager
> > reactorManager,
> > +                                    new ReactorManager(new ArrayList
> > ()),
> >                                     Arrays.asList( new String[]
> > {"install"} ),
> >                                     project.getBasedir().toString(),
> >                                     new Properties(),
>
> Thanks,
>
> Jason
>
> ----------------------------------------------------------
> Jason van Zyl
> Founder,  Apache Maven
> http://twitter.com/jvanzyl
> http://twitter.com/SonatypeNexus
> http://twitter.com/SonatypeM2E
> ----------------------------------------------------------
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Mime
View raw message