Results 1 to 5 of 5

Thread: Packaging flaw breaks ability to view Spring source in Eclipse

  1. #1
    Join Date
    Sep 2006
    Location
    Work in New York City
    Posts
    127

    Default Packaging flaw breaks ability to view Spring source in Eclipse

    It looks to me like the Spring folks have inadvertently made it difficult and perhaps even impossible to view the Spring Framework source code from within Eclipse when maven is being used.

    The reason is that the source code of Spring Framework provided in the spring-framework-3.0.2.RELEASE download looks as follows:

    Code:
    org.springframework.aop-sources-3.0.2.RELEASE.jar
    org.springframework.asm-sources-3.0.2.RELEASE.jar
    org.springframework.aspects-sources-3.0.2.RELEASE.jar
    org.springframework.beans-sources-3.0.2.RELEASE.jar
    org.springframework.context-sources-3.0.2.RELEASE.jar
    org.springframework.context.support-sources-3.0.2.RELEASE.jar
    org.springframework.core-sources-3.0.2.RELEASE.jar
    org.springframework.expression-sources-3.0.2.RELEASE.jar
    org.springframework.instrument-sources-3.0.2.RELEASE.jar
    org.springframework.instrument.tomcat-sources-3.0.2.RELEASE.jar
    org.springframework.jdbc-sources-3.0.2.RELEASE.jar
    org.springframework.jms-sources-3.0.2.RELEASE.jar
    org.springframework.orm-sources-3.0.2.RELEASE.jar
    org.springframework.oxm-sources-3.0.2.RELEASE.jar
    org.springframework.test-sources-3.0.2.RELEASE.jar
    org.springframework.transaction-sources-3.0.2.RELEASE.jar
    org.springframework.web-sources-3.0.2.RELEASE.jar
    org.springframework.web.portlet-sources-3.0.2.RELEASE.jar
    org.springframework.web.servlet-sources-3.0.2.RELEASE.jar
    org.springframework.web.struts-sources-3.0.2.RELEASE.jar
    However, the Spring Framework jar files containing the class files in the Maven repository look like the following. Notice that the jar files of classes in Maven do not match one-for-one with the jar files in the download containing the Spring Framework source code :

    Code:
    batch
    build
    security
    spring
    spring-aop
    spring-asm
    spring-beans
    spring-context
    spring-context-support
    spring-core
    spring-dao
    spring-expression
    spring-jdbc
    spring-mock
    spring-orm
    spring-oxm
    spring-parent
    spring-struts
    spring-support
    spring-test
    spring-tx
    spring-web
    spring-webmvc
    spring-webmvc-struts
    webflow
    Because there is not a consistent one-for-one match between the class jar files and the source jar files, it is not at all apparent how in eclipse to associate the source code to the class files. Even if there were a one-to-one correspondence, it is a long, dreary process configuring the source to match the class files in eclipse--- but that's a subject for another post.


    I hope I'm wrong about this. Has anybody else noticed this besides me?
    Java Developer with all the usual Sun Java certifications.

  2. #2
    Join Date
    Sep 2006
    Location
    Work in New York City
    Posts
    127

    Default workaround

    I found a workaround that is not sufficiently painful to rule it out as a viable workaround. I took fifteen minutes out of my workday to one-by-one unzip each and every jar file of SpringFramework source code, into the same directory.
    Then I went into eclipse....project..properties...Jave Build Path...Maven Dependencies... and therein set the "Source Attachment" of each of the many SpringFramework jar files to point to that single directory where I unzipped all of the SpringFramework source.

    I wonder if this is the "recommended" way to see the SpringFramework source code... or if someone knows a better way?
    Java Developer with all the usual Sun Java certifications.

  3. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    The download is a different package then the jars in the CENTRAL maven repositories, they take another naming convention. Why not let maven download the sources?! Why mess/hack around yourself.

    Code:
    mvn eclipse:clean eclipse:eclipse -DdownloadSources=true
    Or if you use m2eclipse simply check the checkbox to download the sources and presto...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  4. #4
    Join Date
    Sep 2006
    Location
    Work in New York City
    Posts
    127

    Default

    I tried my best to use your solution but it did not work for me. I wonder if it is because the repository I point at

    Code:
    http://mvnrepository.com/artifact/org.springframework/spring-parent/3.0.2.RELEASE
    
    ... for example ....
    
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>3.0.2.RELEASE</version>
    </dependency>
    does not have the Spring source code. Maybe the Spring source code is only kept in that other maven repository that Spring privately owns?

    My first attempt at running
    Code:
    mvn eclipse:clean eclipse:eclipse  -DeclipseDownloadSources=true
    resulted in:

    Code:
    Scanning for projects...
    Searching repository for plugin with prefix: 'eclipse'.
    ------------------------------------------------------------------------
    Building UESS
       task-segment: [eclipse:clean, eclipse:eclipse]
    ------------------------------------------------------------------------
    [eclipse:clean]
    Deleting file: .project
    Deleting file: .classpath
    Deleting file: .wtpmodules
    Deleting file: .component
    Deleting file: org.eclipse.wst.common.component
    Deleting file: org.eclipse.wst.common.project.facet.core.xml
    Deleting file: org.eclipse.jdt.core.prefs
    Preparing eclipse:eclipse
    No goals needed for project - skipping
    [eclipse:eclipse]
    Adding support for WTP version 1.5.
    Using source status cache: C:\icd\ews\uesm_2010_02_25\UESS\target\mvn-eclipse-cache.properties
    Wrote settings to C:\icd\ews\uesm_2010_02_25\UESS\.settings\org.eclipse.jdt.core.prefs
    Wrote Eclipse project for "UESS" to C:\icd\ews\uesm_2010_02_25\UESS.
    
    ------------------------------------------------------------------------
    BUILD SUCCESSFUL
    ------------------------------------------------------------------------
    Total time: 1 second
    Finished at: Tue Apr 27 09:33:47 EDT 2010
    Final Memory: 9M/508M
    ------------------------------------------------------------------------

    Well of course the source did not download in 1 second, the time it took for that build.

    So, I looked at
    Code:
    http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html
    and found this documentation for "downloadSources" :

    Code:
    Enables/disables the downloading of source attachments.
     Defaults to false. When this flag is true remote repositories are 
    checked for sources: in order to avoid repeated check for
     unavailable source archives, a status cache is mantained. 
    With versions 2.6+ of the plugin to reset this cache run
     mvn eclipse:remove-cache, or use the forceRecheck option 
    with versions. With older versions delete the file mvn-eclipse-cache.properties 
    in the target directory.
    I tried both suggestion above (deleting mvn-eclipse-cache.properties) and running "mvn eclipse:remove-cache".

    Neither helped. The Spring source code did not download into my local Maven Repository (assuming that's where it would be placed).

    I am using m2Eclipse but I could not find any option to check that indicated it would download source. The eclipse version is 3.4.1.
    Looking at the "About Eclipse Platform Plug-ins", the Sonatype m2eclipse seems to be version 0.9.7.
    Java Developer with all the usual Sun Java certifications.

  5. #5
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    1) it is -DdownloadSources=true NOT -DeclipseDownloadSources=true
    2) Learn your environmet Window->Preferences->Maven There is a checkbox download artifact sources

    3) The sources are there link

    does not have the Spring source code. Maybe the Spring source code is only kept in that other maven repository that Spring privately owns?
    They are publicly available they are
    1. Maven central
    2. SpringSource hosted maven repository
    3. SpringSource hosted bundle repository


    So trust me they are there, it is what I use everyday...
    Last edited by Marten Deinum; Apr 27th, 2010 at 09:38 AM.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •