The following comment has been added to this issue:

     Author: Krystian Nowak
    Created: Tue, 11 Jan 2005 7:30 AM
       Body:
to http://jira.codehaus.org/browse/MPECLIPSE-60#action_28830 (by  Stephane 
Nicoll)

Of course you are welcome to assist on the plugin version/diff development!

In my project I do not use SNAPSHOT dependencies, so I guess that is why I had 
none of the problems you descibed. Conclusion: Please help if you  have some 
time and ideas.
---------------------------------------------------------------------
View this comment:
  http://jira.codehaus.org/browse/MPECLIPSE-60?page=comments#action_28832

---------------------------------------------------------------------
View the issue:
  http://jira.codehaus.org/browse/MPECLIPSE-60

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: MPECLIPSE-60
    Summary: Downloading source zips
       Type: New Feature

     Status: Unassigned
   Priority: Major

 Original Estimate: 30 minutes
 Time Spent: Unknown
  Remaining: 30 minutes

    Project: maven-eclipse-plugin
   Fix Fors:
             1.9
   Versions:
             1.9

   Assignee: 
   Reporter: Krystian Nowak

    Created: Mon, 6 Dec 2004 3:18 AM
    Updated: Tue, 11 Jan 2005 7:30 AM

Description:
I've attached plugin.jelly for maven-eclipse-plugin downloading sources from 
${repo}/${groupId}/src/${artifactId}-${version}.zip and installing it as 
${maven.repo.local}/${groupId}/src/${artifactId}-${version}.zip.

It does it for all jar dependencies having eclipse.source property set to true. 
Example project.xml:

(...)
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <url>http://www.junit.org/</url>
            <properties>
                <eclipse.source>true</eclipse.source>
            </properties>
        </dependency>
    </dependencies>
(...)

What you have to do now is to call "maven eclipse" and refresh your project in 
Eclipse.


And here is the code of plugin.jelly - a patch made in Eclipse:

Index: plugin.jelly
===================================================================
RCS file: /home/cvspublic/maven-plugins/eclipse/plugin.jelly,v
retrieving revision 1.31
diff -u -r1.31 plugin.jelly
--- plugin.jelly        16 Nov 2004 10:48:15 -0000      1.31
+++ plugin.jelly        6 Dec 2004 08:10:33 -0000
@@ -78,7 +78,8 @@
   <!-- Generate Eclipse  .classpath file                                -->
   <!--==================================================================-->    
   <goal name="eclipse:generate-classpath"
-    description="Generate Eclipse .classpath file">
+    description="Generate Eclipse .classpath file"
+    prereqs="eclipse:sources:download">
   
     <ant:echo>Creating ${basedir}/.classpath ...</ant:echo>                
     <j:file name="${basedir}/.classpath" prettyPrint="true" outputMode="xml" 
xmlns="dummy">
@@ -263,5 +264,73 @@
 
     <ant:echo>Cleaned up eclipse generated files</ant:echo>
   </goal>  
+
+
+
+  <!--==================================================================-->
+  <!-- Download project dependency sources                                 -->
+  <!--==================================================================-->
+
+       <goal name="eclipse:sources:download">
+               <j:forEach var="depItem" items="${pom.getDependencies()}">
+                       <j:if 
test="${depItem.getType().equalsIgnoreCase('jar')}">
+                               <j:if 
test="${depItem.getProperty('eclipse.source') == 'true'}">
+                                       <j:set var="groupId" 
value="${depItem.getGroupId()}"/>
+                                       <j:set var="artifactId" 
value="${depItem.getArtifactId()}"/>
+                                       <j:set var="version" 
value="${depItem.getVersion()}"/>
+                                       <attainGoal 
name="eclipse:source:download"/>
+                                       <j:remove var="groupId"/>
+                                       <j:remove var="artifactId"/>
+                                       <j:remove var="version"/>
+                               </j:if>
+                       </j:if>
+               </j:forEach>
+       </goal>
+
+
+  <!--==================================================================-->
+  <!-- Download single source                                 -->
+  <!--==================================================================-->
+
+       <goal name="eclipse:source:download">
+               <!--
+                       param: groupId
+                       param: artifactId
+                       param: version
+               -->
+               <echo>Checking sources for ${groupId}:${artifactId} 
ver.${version}</echo>
+           <util:file var="localSrcFile" 
name="${maven.repo.local}/${groupId}/src/${artifactId}-${version}.zip" />
+        <j:if test="${!localSrcFile.exists()}">
+               <mkdir dir="${maven.repo.local}/${groupId}/src" />
+               <j:set var="repoList">${maven.repo.remote}</j:set>
+                       <util:tokenize var="repos" 
delim=",">${repoList.trim()}</util:tokenize>
+                       <j:forEach var="repo" items="${repos}">
+                       <echo>repo is '${repo}'</echo>
+                       <j:set var="remoteFile" 
value="${repo}/${groupId}/src/${artifactId}-${version}.zip" />
+                       <echo>trying to download ${remoteFile}</echo>
+                       <j:catch var="ex">
+                         <j:invokeStatic var="dummy" method="getFile" 
className="org.apache.maven.util.HttpUtils">
+                           <j:arg type="java.lang.String" 
value="${remoteFile}" />
+                           <j:arg type="java.io.File" value="${localSrcFile}"/>
+                           <j:arg type="boolean" value="false"/>
+                           <j:arg type="boolean" value="true"/>
+                           <j:arg type="java.lang.String" 
value="${maven.proxy.host}" />
+                           <j:arg type="java.lang.String" 
value="${maven.proxy.port}" />
+                           <j:arg type="java.lang.String" 
value="${maven.proxy.username}" />
+                           <j:arg type="java.lang.String" 
value="${maven.proxy.password}" />
+                           <j:arg type="boolean" value="false"/>
+                         </j:invokeStatic>
+                       </j:catch>
+                       <j:remove var="remoteFile"/>
+                       <j:break test="${localSrcFile.exists()}"/>
+                       </j:forEach>
+                       <j:if test="${!localSrcFile.exists()}">
+                               <echo>WARN: Could not download sources for 
${groupId}:${artifactId} ver.${version}</echo>
+                   </j:if>
+                   <j:remove var="repoList"/>
+           </j:if>                 
+           <j:remove var="localSrcFile"/>
+       </goal>
+
 
 </project>



---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to