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>

      1. MPECLIPSE-60.patch
        14 kB
        Stéphane Nicoll
      2. plugin.jelly.patch
        4 kB
        Krystian Nowak

        Activity

        Hide
        Stéphane Nicoll added a comment -

        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 - No, I don't have such use case. If it could be disabled globally (property) that's fine with me.
        Hide
        Stéphane Nicoll added a comment -

        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 - 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
        Stéphane Nicoll added a comment -

        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 - 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
        Stéphane Nicoll added a comment -

        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 - 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
        Stéphane Nicoll added a comment -

        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 - 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
          • Votes:
            8 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 30 minutes
              30m
              Remaining:
              Remaining Estimate - 30 minutes
              30m
              Logged:
              Time Spent - Not Specified
              Not Specified