You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2006/11/19 23:36:11 UTC

svn commit: r476959 - in /maven/plugins/trunk/maven-remote-resources-plugin: pom.xml src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java

Author: jvanzyl
Date: Sun Nov 19 14:36:11 2006
New Revision: 476959

URL: http://svn.apache.org/viewvc?view=rev&rev=476959
Log:
o have to add some voodoo to convert the repositories ...

Modified:
    maven/plugins/trunk/maven-remote-resources-plugin/pom.xml
    maven/plugins/trunk/maven-remote-resources-plugin/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java

Modified: maven/plugins/trunk/maven-remote-resources-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-remote-resources-plugin/pom.xml?view=diff&rev=476959&r1=476958&r2=476959
==============================================================================
--- maven/plugins/trunk/maven-remote-resources-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-remote-resources-plugin/pom.xml Sun Nov 19 14:36:11 2006
@@ -26,6 +26,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
+      <artifactId>maven-core</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
       <version>2.0</version>
     </dependency>

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-plugin/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java?view=diff&rev=476959&r1=476958&r2=476959
==============================================================================
--- 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 Sun Nov 19 14:36:11 2006
@@ -16,36 +16,38 @@
  * limitations under the License.
  */
 
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.InvalidRepositoryException;
+import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.resources.remote.io.xpp3.RemoteResourcesBundleXpp3Reader;
-import org.apache.maven.shared.downloader.Downloader;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectUtils;
 import org.apache.maven.shared.downloader.DownloadException;
 import org.apache.maven.shared.downloader.DownloadNotFoundException;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.downloader.Downloader;
 import org.apache.velocity.VelocityContext;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 import org.codehaus.plexus.velocity.VelocityComponent;
 
 import java.io.File;
+import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.Writer;
-import java.io.FileWriter;
-import java.util.List;
-import java.util.Iterator;
-import java.util.Enumeration;
-import java.util.ArrayList;
-import java.util.Date;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
-import java.text.DateFormat;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.Iterator;
 
 /**
  * Pull down artifacts containing remote resources and process the resources contained
@@ -63,7 +65,7 @@
     private ArtifactRepository localRepository;
 
     /**
-     * @parameter expression="${project.remoteRepositories}
+     * @parameter expression="${project.repositories}
      */
     private ArrayList remoteRepositories;
 
@@ -97,6 +99,21 @@
      */
     private File workDirectory;
 
+    // These two things make this horrible. Maven artifact is way too complicated and the relationship between
+    // the model usage and maven-artifact needs to be reworked as well as all our tools that deal with it. The
+    // ProjectUtils should be a component so I don't have to expose the container and artifact factory here. Can't
+    // change it now because it's not released ...
+
+    /**
+     * @component
+     */
+    private ArtifactRepositoryFactory artifactRepositoryFactory;
+
+    /**
+     * @parameter expression="${session}"
+     */
+    private MavenSession mavenSession;
+
     public void execute()
         throws MojoExecutionException
     {
@@ -116,7 +133,10 @@
 
             try
             {
-                File artifact = downloader.download( s[0], s[1], s[2], localRepository, remoteRepositories );
+                File artifact = downloader.download( s[0], s[1], s[2], localRepository,
+                                                     ProjectUtils.buildArtifactRepositories( remoteRepositories,
+                                                                                             artifactRepositoryFactory,
+                                                                                             mavenSession.getContainer() ) );
 
                 classLoader.addURL( artifact.toURI().toURL() );
             }
@@ -128,6 +148,10 @@
             {
                 throw new MojoExecutionException( "Resources JAR cannot be found.", e );
             }
+            catch( InvalidRepositoryException e )
+            {
+                throw new MojoExecutionException( "Resources JAR cannot be found.", e );
+            }
             catch ( MalformedURLException e )
             {
                 // Won't happen.
@@ -144,7 +168,7 @@
 
         context.put( "project", project );
 
-        String year = new SimpleDateFormat("yyyy").format( new Date() );
+        String year = new SimpleDateFormat( "yyyy" ).format( new Date() );
 
         context.put( "presentYear", year );
 



Re: svn commit: r476959 - in /maven/plugins/trunk/maven-remote-resources-plugin: pom.xml src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java

Posted by Jason van Zyl <ja...@maven.org>.
On 19 Nov 06, at 5:53 PM 19 Nov 06, Brett Porter wrote:

> A way to get the container with less voodoo (but still voodoo)  
> would be to make the mojo Contextualizable and grab it from the  
> context. Is that a bit cleaner?
>

I think the ProjectUtils should just be a component and then I  
wouldn't need the container in that plugin at all.

Jason.

> - Brett
>
> On 20/11/2006, at 9:36 AM, jvanzyl@apache.org wrote:
>
>> Author: jvanzyl
>> Date: Sun Nov 19 14:36:11 2006
>> New Revision: 476959
>>
>> URL: http://svn.apache.org/viewvc?view=rev&rev=476959
>> Log:
>> o have to add some voodoo to convert the repositories ...
>>
>> Modified:
>>     maven/plugins/trunk/maven-remote-resources-plugin/pom.xml
>>     maven/plugins/trunk/maven-remote-resources-plugin/src/main/ 
>> java/org/apache/maven/plugin/resources/remote/ 
>> ProcessRemoteResourcesMojo.java
>>
>> Modified: maven/plugins/trunk/maven-remote-resources-plugin/pom.xml
>> URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-remote- 
>> resources-plugin/pom.xml?view=diff&rev=476959&r1=476958&r2=476959
>> ===================================================================== 
>> =========
>> --- maven/plugins/trunk/maven-remote-resources-plugin/pom.xml  
>> (original)
>> +++ maven/plugins/trunk/maven-remote-resources-plugin/pom.xml Sun  
>> Nov 19 14:36:11 2006
>> @@ -26,6 +26,11 @@
>>      </dependency>
>>      <dependency>
>>        <groupId>org.apache.maven</groupId>
>> +      <artifactId>maven-core</artifactId>
>> +      <version>2.0</version>
>> +    </dependency>
>> +    <dependency>
>> +      <groupId>org.apache.maven</groupId>
>>        <artifactId>maven-plugin-api</artifactId>
>>        <version>2.0</version>
>>      </dependency>
>>
>> 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-plugin/src/main/java/org/apache/maven/plugin/resources/ 
>> remote/ProcessRemoteResourcesMojo.java? 
>> view=diff&rev=476959&r1=476958&r2=476959
>> ===================================================================== 
>> =========
>> --- 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 Sun Nov 19 14:36:11 2006
>> @@ -16,36 +16,38 @@
>>   * limitations under the License.
>>   */
>>
>> +import org.apache.maven.artifact.repository.ArtifactRepository;
>> +import  
>> org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
>> +import org.apache.maven.artifact.InvalidRepositoryException;
>> +import org.apache.maven.execution.MavenSession;
>>  import org.apache.maven.plugin.AbstractMojo;
>>  import org.apache.maven.plugin.MojoExecutionException;
>>  import  
>> org.apache.maven.plugin.resources.remote.io.xpp3.RemoteResourcesBundl 
>> eXpp3Reader;
>> -import org.apache.maven.shared.downloader.Downloader;
>> +import org.apache.maven.project.MavenProject;
>> +import org.apache.maven.project.ProjectUtils;
>>  import org.apache.maven.shared.downloader.DownloadException;
>>  import org.apache.maven.shared.downloader.DownloadNotFoundException;
>> -import org.apache.maven.artifact.repository.ArtifactRepository;
>> -import org.apache.maven.project.MavenProject;
>> +import org.apache.maven.shared.downloader.Downloader;
>>  import org.apache.velocity.VelocityContext;
>> -import org.codehaus.plexus.util.StringUtils;
>> -import org.codehaus.plexus.util.IOUtil;
>>  import org.codehaus.plexus.util.FileUtils;
>> +import org.codehaus.plexus.util.IOUtil;
>> +import org.codehaus.plexus.util.StringUtils;
>>  import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
>>  import org.codehaus.plexus.velocity.VelocityComponent;
>>
>>  import java.io.File;
>> +import java.io.FileWriter;
>>  import java.io.IOException;
>>  import java.io.InputStreamReader;
>>  import java.io.Writer;
>> -import java.io.FileWriter;
>> -import java.util.List;
>> -import java.util.Iterator;
>> -import java.util.Enumeration;
>> -import java.util.ArrayList;
>> -import java.util.Date;
>>  import java.net.MalformedURLException;
>>  import java.net.URL;
>>  import java.net.URLConnection;
>> -import java.text.DateFormat;
>>  import java.text.SimpleDateFormat;
>> +import java.util.ArrayList;
>> +import java.util.Date;
>> +import java.util.Enumeration;
>> +import java.util.Iterator;
>>
>>  /**
>>   * Pull down artifacts containing remote resources and process  
>> the resources contained
>> @@ -63,7 +65,7 @@
>>      private ArtifactRepository localRepository;
>>
>>      /**
>> -     * @parameter expression="${project.remoteRepositories}
>> +     * @parameter expression="${project.repositories}
>>       */
>>      private ArrayList remoteRepositories;
>>
>> @@ -97,6 +99,21 @@
>>       */
>>      private File workDirectory;
>>
>> +    // These two things make this horrible. Maven artifact is way  
>> too complicated and the relationship between
>> +    // the model usage and maven-artifact needs to be reworked as  
>> well as all our tools that deal with it. The
>> +    // ProjectUtils should be a component so I don't have to  
>> expose the container and artifact factory here. Can't
>> +    // change it now because it's not released ...
>> +
>> +    /**
>> +     * @component
>> +     */
>> +    private ArtifactRepositoryFactory artifactRepositoryFactory;
>> +
>> +    /**
>> +     * @parameter expression="${session}"
>> +     */
>> +    private MavenSession mavenSession;
>> +
>>      public void execute()
>>          throws MojoExecutionException
>>      {
>> @@ -116,7 +133,10 @@
>>
>>              try
>>              {
>> -                File artifact = downloader.download( s[0], s[1], s 
>> [2], localRepository, remoteRepositories );
>> +                File artifact = downloader.download( s[0], s[1], s 
>> [2], localRepository,
>> +                                                      
>> ProjectUtils.buildArtifactRepositories( remoteRepositories,
>> +                                                                     
>>                          artifactRepositoryFactory,
>> +                                                                     
>>                          mavenSession.getContainer() ) );
>>
>>                  classLoader.addURL( artifact.toURI().toURL() );
>>              }
>> @@ -128,6 +148,10 @@
>>              {
>>                  throw new MojoExecutionException( "Resources JAR  
>> cannot be found.", e );
>>              }
>> +            catch( InvalidRepositoryException e )
>> +            {
>> +                throw new MojoExecutionException( "Resources JAR  
>> cannot be found.", e );
>> +            }
>>              catch ( MalformedURLException e )
>>              {
>>                  // Won't happen.
>> @@ -144,7 +168,7 @@
>>
>>          context.put( "project", project );
>>
>> -        String year = new SimpleDateFormat("yyyy").format( new  
>> Date() );
>> +        String year = new SimpleDateFormat( "yyyy" ).format( new  
>> Date() );
>>
>>          context.put( "presentYear", year );
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>


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


Re: svn commit: r476959 - in /maven/plugins/trunk/maven-remote-resources-plugin: pom.xml src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java

Posted by Brett Porter <br...@apache.org>.
A way to get the container with less voodoo (but still voodoo) would  
be to make the mojo Contextualizable and grab it from the context. Is  
that a bit cleaner?

- Brett

On 20/11/2006, at 9:36 AM, jvanzyl@apache.org wrote:

> Author: jvanzyl
> Date: Sun Nov 19 14:36:11 2006
> New Revision: 476959
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=476959
> Log:
> o have to add some voodoo to convert the repositories ...
>
> Modified:
>     maven/plugins/trunk/maven-remote-resources-plugin/pom.xml
>     maven/plugins/trunk/maven-remote-resources-plugin/src/main/java/ 
> org/apache/maven/plugin/resources/remote/ 
> ProcessRemoteResourcesMojo.java
>
> Modified: maven/plugins/trunk/maven-remote-resources-plugin/pom.xml
> URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-remote- 
> resources-plugin/pom.xml?view=diff&rev=476959&r1=476958&r2=476959
> ====================================================================== 
> ========
> --- maven/plugins/trunk/maven-remote-resources-plugin/pom.xml  
> (original)
> +++ maven/plugins/trunk/maven-remote-resources-plugin/pom.xml Sun  
> Nov 19 14:36:11 2006
> @@ -26,6 +26,11 @@
>      </dependency>
>      <dependency>
>        <groupId>org.apache.maven</groupId>
> +      <artifactId>maven-core</artifactId>
> +      <version>2.0</version>
> +    </dependency>
> +    <dependency>
> +      <groupId>org.apache.maven</groupId>
>        <artifactId>maven-plugin-api</artifactId>
>        <version>2.0</version>
>      </dependency>
>
> 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-plugin/src/main/java/org/apache/maven/plugin/resources/ 
> remote/ProcessRemoteResourcesMojo.java? 
> view=diff&rev=476959&r1=476958&r2=476959
> ====================================================================== 
> ========
> --- 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 Sun Nov 19 14:36:11 2006
> @@ -16,36 +16,38 @@
>   * limitations under the License.
>   */
>
> +import org.apache.maven.artifact.repository.ArtifactRepository;
> +import  
> org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
> +import org.apache.maven.artifact.InvalidRepositoryException;
> +import org.apache.maven.execution.MavenSession;
>  import org.apache.maven.plugin.AbstractMojo;
>  import org.apache.maven.plugin.MojoExecutionException;
>  import  
> org.apache.maven.plugin.resources.remote.io.xpp3.RemoteResourcesBundle 
> Xpp3Reader;
> -import org.apache.maven.shared.downloader.Downloader;
> +import org.apache.maven.project.MavenProject;
> +import org.apache.maven.project.ProjectUtils;
>  import org.apache.maven.shared.downloader.DownloadException;
>  import org.apache.maven.shared.downloader.DownloadNotFoundException;
> -import org.apache.maven.artifact.repository.ArtifactRepository;
> -import org.apache.maven.project.MavenProject;
> +import org.apache.maven.shared.downloader.Downloader;
>  import org.apache.velocity.VelocityContext;
> -import org.codehaus.plexus.util.StringUtils;
> -import org.codehaus.plexus.util.IOUtil;
>  import org.codehaus.plexus.util.FileUtils;
> +import org.codehaus.plexus.util.IOUtil;
> +import org.codehaus.plexus.util.StringUtils;
>  import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
>  import org.codehaus.plexus.velocity.VelocityComponent;
>
>  import java.io.File;
> +import java.io.FileWriter;
>  import java.io.IOException;
>  import java.io.InputStreamReader;
>  import java.io.Writer;
> -import java.io.FileWriter;
> -import java.util.List;
> -import java.util.Iterator;
> -import java.util.Enumeration;
> -import java.util.ArrayList;
> -import java.util.Date;
>  import java.net.MalformedURLException;
>  import java.net.URL;
>  import java.net.URLConnection;
> -import java.text.DateFormat;
>  import java.text.SimpleDateFormat;
> +import java.util.ArrayList;
> +import java.util.Date;
> +import java.util.Enumeration;
> +import java.util.Iterator;
>
>  /**
>   * Pull down artifacts containing remote resources and process the  
> resources contained
> @@ -63,7 +65,7 @@
>      private ArtifactRepository localRepository;
>
>      /**
> -     * @parameter expression="${project.remoteRepositories}
> +     * @parameter expression="${project.repositories}
>       */
>      private ArrayList remoteRepositories;
>
> @@ -97,6 +99,21 @@
>       */
>      private File workDirectory;
>
> +    // These two things make this horrible. Maven artifact is way  
> too complicated and the relationship between
> +    // the model usage and maven-artifact needs to be reworked as  
> well as all our tools that deal with it. The
> +    // ProjectUtils should be a component so I don't have to  
> expose the container and artifact factory here. Can't
> +    // change it now because it's not released ...
> +
> +    /**
> +     * @component
> +     */
> +    private ArtifactRepositoryFactory artifactRepositoryFactory;
> +
> +    /**
> +     * @parameter expression="${session}"
> +     */
> +    private MavenSession mavenSession;
> +
>      public void execute()
>          throws MojoExecutionException
>      {
> @@ -116,7 +133,10 @@
>
>              try
>              {
> -                File artifact = downloader.download( s[0], s[1], s 
> [2], localRepository, remoteRepositories );
> +                File artifact = downloader.download( s[0], s[1], s 
> [2], localRepository,
> +                                                      
> ProjectUtils.buildArtifactRepositories( remoteRepositories,
> +                                                                      
>                         artifactRepositoryFactory,
> +                                                                      
>                         mavenSession.getContainer() ) );
>
>                  classLoader.addURL( artifact.toURI().toURL() );
>              }
> @@ -128,6 +148,10 @@
>              {
>                  throw new MojoExecutionException( "Resources JAR  
> cannot be found.", e );
>              }
> +            catch( InvalidRepositoryException e )
> +            {
> +                throw new MojoExecutionException( "Resources JAR  
> cannot be found.", e );
> +            }
>              catch ( MalformedURLException e )
>              {
>                  // Won't happen.
> @@ -144,7 +168,7 @@
>
>          context.put( "project", project );
>
> -        String year = new SimpleDateFormat("yyyy").format( new Date 
> () );
> +        String year = new SimpleDateFormat( "yyyy" ).format( new  
> Date() );
>
>          context.put( "presentYear", year );
>
>

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