jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
Signup
Maven 1.x Eclipse Plugin
  • Maven 1.x Eclipse Plugin
  • MPECLIPSE-60

Downloading source zips

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: New Feature New Feature
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.9
  • Fix Version/s: 1.11
  • Labels:
    None
  • Number of attachments :
    2

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>

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Text File
    MPECLIPSE-60.patch
    09/Jan/06 1:18 PM
    14 kB
    Stéphane Nicoll
  2. Text File
    plugin.jelly.patch
    06/Dec/04 3:19 AM
    4 kB
    Krystian Nowak

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Krystian Nowak added a comment - 06/Dec/04 3:19 AM

plugin.jelly patch as a file

Show
Krystian Nowak added a comment - 06/Dec/04 3:19 AM plugin.jelly patch as a file
Hide
Permalink
Stephane Nicoll added a comment - 21/Dec/04 6:42 AM

Are you planning to include this patch in 1.10?

Show
Stephane Nicoll added a comment - 21/Dec/04 6:42 AM Are you planning to include this patch in 1.10?
Hide
Permalink
Krystian Nowak added a comment - 21/Dec/04 7:42 AM

Hmmm... I hope that maven-plugins commiters will do that, if they found it valuable. It's only a proposal. If you want, you can use the patch yourself, but I don't know plans for maven-eclipse-plugin future.

Show
Krystian Nowak added a comment - 21/Dec/04 7:42 AM Hmmm... I hope that maven-plugins commiters will do that, if they found it valuable. It's only a proposal. If you want, you can use the patch yourself, but I don't know plans for maven-eclipse-plugin future.
Hide
Permalink
Stephane Nicoll added a comment - 22/Dec/04 9:44 AM

I don't agree with

<j:if test="$

{depItem.getType().equalsIgnoreCase('jar')}

">

What if I have an ejb-jar module in my dependencies? The type is ejb, not jar but still I want to include it in my eclipse sources.

Show
Stephane Nicoll added a comment - 22/Dec/04 9:44 AM I don't agree with <j:if test="$ {depItem.getType().equalsIgnoreCase('jar')} "> What if I have an ejb-jar module in my dependencies? The type is ejb, not jar but still I want to include it in my eclipse sources.
Hide
Permalink
Scott D. Ryan added a comment - 27/Dec/04 1:27 PM

This has proven very useful. I modified it to use the maven dist plug-in. This allows us to use the dist plug-in to generate the source code in a Maven standard way but also use this extension to download the code onto the local repository.

I hope this gets into the plugin soon.,

Scott

Show
Scott D. Ryan added a comment - 27/Dec/04 1:27 PM This has proven very useful. I modified it to use the maven dist plug-in. This allows us to use the dist plug-in to generate the source code in a Maven standard way but also use this extension to download the code onto the local repository. I hope this gets into the plugin soon., Scott
Hide
Permalink
Krystian Nowak added a comment - 10/Jan/05 4:26 AM

to http://jira.codehaus.org/browse/MPECLIPSE-60#action_28273 (by Stephane Nicoll)

OK. EJB could be included. In my project I just didn't use any EJB dependencies. Conclusion - GOOD IDEA.

Show
Krystian Nowak added a comment - 10/Jan/05 4:26 AM to http://jira.codehaus.org/browse/MPECLIPSE-60#action_28273 (by Stephane Nicoll) OK. EJB could be included. In my project I just didn't use any EJB dependencies. Conclusion - GOOD IDEA.
Hide
Permalink
Krystian Nowak added a comment - 10/Jan/05 4:30 AM

to http://jira.codehaus.org/browse/MPECLIPSE-60#action_28350 (by Scott D. Ryan)

If you could, please, include diff/patch file in JIRA issue/comment.

Show
Krystian Nowak added a comment - 10/Jan/05 4:30 AM to http://jira.codehaus.org/browse/MPECLIPSE-60#action_28350 (by Scott D. Ryan) If you could, please, include diff/patch file in JIRA issue/comment.
Hide
Permalink
Stephane Nicoll added a comment - 11/Jan/05 5:22 AM

Unfortunately, this patch does not handle SNAPSHOT dependencies. We have regular problems here with this patch.

If we depend on XXX-SNAPSHOT, the jelly code does not download the sources again.

The only solution so far is to clear our local cache and reinvoke the plugin. I think we could use maven standard dependencie's mechanism, right?

I can assist on this if necessary (Let me know)

Show
Stephane Nicoll added a comment - 11/Jan/05 5:22 AM Unfortunately, this patch does not handle SNAPSHOT dependencies. We have regular problems here with this patch. If we depend on XXX-SNAPSHOT, the jelly code does not download the sources again. The only solution so far is to clear our local cache and reinvoke the plugin. I think we could use maven standard dependencie's mechanism, right? I can assist on this if necessary (Let me know)
Hide
Permalink
Krystian Nowak added a comment - 11/Jan/05 7:30 AM

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.

Show
Krystian Nowak added a comment - 11/Jan/05 7:30 AM 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.
Hide
Permalink
Jörg Schaible added a comment - 06/May/05 9:22 AM

Just wonder, if the property should really be named "eclipse.source", since IDEA has the same functionality. "sourceCode" or "IDE.source" might be more appropriate.

Show
Jörg Schaible added a comment - 06/May/05 9:22 AM Just wonder, if the property should really be named "eclipse.source", since IDEA has the same functionality. "sourceCode" or "IDE.source" might be more appropriate.
Hide
Permalink
Krystian Nowak added a comment - 09/May/05 4:12 AM

to http://jira.codehaus.org/browse/MPECLIPSE-60#action_38644 (by Joerg Schaible)

Hmmm... since it is a eclipse plugin, and there was already a property called eclipse.dependency I've just added eclipse.source. There is nothing more general e.g. IDE.dependency, so there is neither IDE.source. It's an architectural issue. If there would be a general plugin core and more specific plugins to this plugin () for given IDEs there we could change the name to IDE.* and then filter it in (where?) some specific configuration file for given IDE (e.g. idea.properties or eclipse.properties). But for simplicity let's let it as it is - just eclipse.*

Show
Krystian Nowak added a comment - 09/May/05 4:12 AM to http://jira.codehaus.org/browse/MPECLIPSE-60#action_38644 (by Joerg Schaible) Hmmm... since it is a eclipse plugin, and there was already a property called eclipse.dependency I've just added eclipse.source. There is nothing more general e.g. IDE.dependency, so there is neither IDE.source. It's an architectural issue. If there would be a general plugin core and more specific plugins to this plugin ( ) for given IDEs there we could change the name to IDE.* and then filter it in (where?) some specific configuration file for given IDE (e.g. idea.properties or eclipse.properties). But for simplicity let's let it as it is - just eclipse.*
Hide
Permalink
Jörg Schaible added a comment - 09/May/05 5:53 AM

Its not just IDEs. Think about the javadoc URL. That can be used by eclipse plugin, but also by the javadoc plugin, that has nothing to do with IDEs. At our location, we have people working with different IDEs for the same project. So it seems quite silly to add the same information twice.

Show
Jörg Schaible added a comment - 09/May/05 5:53 AM Its not just IDEs. Think about the javadoc URL. That can be used by eclipse plugin, but also by the javadoc plugin, that has nothing to do with IDEs. At our location, we have people working with different IDEs for the same project. So it seems quite silly to add the same information twice.
Hide
Permalink
Milos Kleint added a comment - 09/May/05 6:10 AM

I've added an enhancement to maven-dist-plugin for creation and upload of source file distributions that are similar to javadoc distributions - MPDIST-21.
it allows to upload the source artifact to repository/$

{groupId}/src.jars/${artifactid}-{$version}.src.jar which is consistent with the javadoc plugin.
It allows me to check for the src jar in mevenide and download it if it exists. The repository/${groupId}

/src/<name>.zip location seems lessconsistent and doesn't have a countepart on the upload side.

I don't think a dependency property is necessary, this can be trasparently checked for any dependency. Once we have a standard location and format of the source artifact.

Show
Milos Kleint added a comment - 09/May/05 6:10 AM I've added an enhancement to maven-dist-plugin for creation and upload of source file distributions that are similar to javadoc distributions - MPDIST-21 . it allows to upload the source artifact to repository/$ {groupId}/src.jars/${artifactid}-{$version}.src.jar which is consistent with the javadoc plugin. It allows me to check for the src jar in mevenide and download it if it exists. The repository/${groupId} /src/<name>.zip location seems lessconsistent and doesn't have a countepart on the upload side. I don't think a dependency property is necessary, this can be trasparently checked for any dependency. Once we have a standard location and format of the source artifact.
Hide
Permalink
Stephane Nicoll added a comment - 09/May/05 6:14 AM

> I don't think a dependency property is necessary, this can be trasparently checked for any dependency. Once we have a standard location and format of the source artifact.

Well, it could be. However, I think you might need to disable the behavior somehow (if I am not interested, the plugin should not check the repository for something I don't want).

Show
Stephane Nicoll added a comment - 09/May/05 6:14 AM > I don't think a dependency property is necessary, this can be trasparently checked for any dependency. Once we have a standard location and format of the source artifact. Well, it could be. However, I think you might need to disable the behavior somehow (if I am not interested, the plugin should not check the repository for something I don't want).
Hide
Permalink
Milos Kleint added a comment - 09/May/05 2:04 PM

maybe a separate goal or a goal parameter property could do?

do you have a usecase when you want to check for one dependency and not for another one? (if yes, a dependency property is probably necessary but I can't imagine the usecase)

Show
Milos Kleint added a comment - 09/May/05 2:04 PM maybe a separate goal or a goal parameter property could do? do you have a usecase when you want to check for one dependency and not for another one? (if yes, a dependency property is probably necessary but I can't imagine the usecase)
Hide
Permalink
Stéphane Nicoll added a comment - 10/Nov/05 6:31 AM

No, I don't have such use case. If it could be disabled globally (property) that's fine with me.

Show
Stéphane Nicoll added a comment - 10/Nov/05 6:31 AM No, I don't have such use case. If it could be disabled globally (property) that's fine with me.
Hide
Permalink
Stéphane Nicoll added a comment - 28/Dec/05 3:26 AM

Guys,

We need to include this in 1.11 I think. I don't think that M1 has a "java source" artifact right? Even if the patch sounds like a workaround, it's really needed. Without it, the source inclusion does not make much sense.

Show
Stéphane Nicoll added a comment - 28/Dec/05 3:26 AM Guys, We need to include this in 1.11 I think. I don't think that M1 has a "java source" artifact right? Even if the patch sounds like a workaround, it's really needed. Without it, the source inclusion does not make much sense.
Hide
Permalink
Stéphane Nicoll added a comment - 08/Jan/06 3:22 AM

OK. So maven one has now a source plugin which is currently available in the plugins-sandbox.

The plugin deploys/installs the source archive in a location with maven2 legacy mode (i.e. java-sources/$

{artifactId}

-$

{version}

-sources.jar).

We now need to include download of such artifact. Milos Kleint has a solution for the mevenide plugin which I am gonna mimic.

Show
Stéphane Nicoll added a comment - 08/Jan/06 3:22 AM OK. So maven one has now a source plugin which is currently available in the plugins-sandbox . The plugin deploys/installs the source archive in a location with maven2 legacy mode (i.e. java-sources/$ {artifactId} -$ {version} -sources.jar). We now need to include download of such artifact. Milos Kleint has a solution for the mevenide plugin which I am gonna mimic.
Hide
Permalink
Stéphane Nicoll added a comment - 09/Jan/06 1:18 PM

A patch which allows to download java source archives from the repository. Only support the location handled by the maven source plugin.

handles SNAPSHOT artifacts.

Show
Stéphane Nicoll added a comment - 09/Jan/06 1:18 PM A patch which allows to download java source archives from the repository. Only support the location handled by the maven source plugin. handles SNAPSHOT artifacts.
Hide
Permalink
Stéphane Nicoll added a comment - 13/Jan/06 4:42 PM

OK ; It is resolved (finally!).

The plugin downloads source archives from the remote repository. This could be disabled, see the doc for more details.

Show
Stéphane Nicoll added a comment - 13/Jan/06 4:42 PM OK ; It is resolved (finally!). The plugin downloads source archives from the remote repository. This could be disabled, see the doc for more details.

People

  • Assignee:
    Stéphane Nicoll
    Reporter:
    Krystian Nowak
Vote (8)
Watch (6)

Dates

  • Created:
    06/Dec/04 3:18 AM
    Updated:
    13/Jan/06 4:42 PM
    Resolved:
    13/Jan/06 4:42 PM

Time Tracking

Estimated:
30m
Original Estimate - 30 minutes
Remaining:
30m
Remaining Estimate - 30 minutes
Logged:
Not Specified
Time Spent - Not Specified
  • Atlassian JIRA (v5.2.7#850-sha1:b2af0c8)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.