9 Replies Latest reply on Jul 23, 2012 6:03 PM by erce

    How to get ALL sources for a JBoss AS 7 release, including external deps?

    ringerc

      Hi all

       

      I'm debugging an ... interesting ... issue that's taking me deep into JBoss AS 7, mainly into the code for Mojarra, Weld, and Coyote. I'm increasingly finding that I want a way to fetch <i>all</i> the sources for everything in the JBoss AS 7.1.2.Final release, whether they're directly a part of the JBoss AS 7 project or not.

       

      This must be a common need for people working on JBoss AS 7, but I've struggled to find out how to do it. Is it so obvious everyone just knows? Or do I just have to go delving through the SCMs for each of the used packages, checking out the appropriate tags and doing a local maven build to install the source archives? Many of the artifacts used in JBoss AS 7.1.2.Final don't seem to have their sources published in Central (grr!) or in JBoss's nexus, so asking Maven to fetch them with:

       

      git clone git://github.com/jbossas/jboss-as.git
      cd jboss-as
      git checkout 7.1.2.Final
      mvn dependency:sources
      mvn dependency:resolve -Dclassifier=javadoc
      

       

      doesn't seem to do much good; it downloads the pom files for most dependencies, but doesn't seem to find sources for much before failing with:

       

      [ERROR] Failed to execute goal on project jboss-as-parent: Could not resolve dependencies for project org.jboss.as:jboss-as-parent:pom:7.1.2.Final: Failure to find org.jboss.as:jboss-as-build-config:jar:7.1.2.Final in http://repository.jboss.org/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of jboss-public-repository-group has elapsed or updates are forced -> [Help 1]
      

       

      Update: Using --fail-never convinces the Maven reactor to keep trying to fetch dependencies after the failed module, and helps in that it gets me sources for those dependencies for which the artifact publisher bothered to upload sources. This doesn't help with the of modules for which sources are missing from Central and JBoss Public Nexus, but I suspect I'm going to be stuck with a manual SCM pull for those.

       

      I'm a bit confused here. I'm used to working with Maven on simple projects and on reactor projects with a few modules, but nothing AS7's size and never with the apparently mandatory build wrapper shell script.

       

      There must be a better way than a manual download and build of every dependency, surely?

       

      (See also comment on https://community.jboss.org/wiki/HackingOnAS7#comment-9998 )

        • 1. Re: How to get ALL sources for a JBoss AS 7 release, including external deps?
          ctomc

          Hi,

           

          you are trying to resolve sources for 7.1.2 version that wasn't published to maven repository.

          that is why it fails for 7.1.2 source/javadoc artifcats.

          you get source artifacts of 7.1.2 by building it

           

          so you should do:

           

          git clone git://github.com/jbossas/jboss-as.git
          cd jboss-as
          git checkout 7.1.2.Final

          mvn clean install
          mvn dependency:sources
          mvn dependency:resolve -Dclassifier=javadoc

           

          and that will work as it should.

          As far as how others do it, I just select "download sources" in intellj and it does it for me.

          for now i have not found any source artifact missing, if you do find it, let us know so we can fix it.

           

           

          --

          tomaz

          • 2. Re: How to get ALL sources for a JBoss AS 7 release, including external deps?
            sfcoy

            You probably also want to have a look at AS7 projects.

             

            At the moment , JBoss "trunk" builds OK for me using an ordinary:

             

            {code}mvn clean install{code}

             

            My local maven is setup to point at a Nexus instance which has the public JBoss repository linked to it.

             

            (I've not tried 7.1.2 yet)

            1 of 1 people found this helpful
            • 3. Re: How to get ALL sources for a JBoss AS 7 release, including external deps?
              ringerc

              Well, that was dumb on my part. For some reason I thought I was using 7.1.2.Final not 7.1.1.Final. Fail.

               

              Fetching sources for 7.1.1.Final works much better, as you'd expect when it's actually been released.

               

              That said, it'd be very nice if JBoss Tools had an option to fetch sources for an AS7 server in the server context menu and/or on-demand in the debugger perspective, as:

               

              • Ideally you shouldn't need to check AS7 out from git to fetch sources for the release version you're running; and
              • When debugging a project running on AS7, the JBoss Tools / m2e integration doesn't automatically find JBoss AS 7 sources in the local maven repository, the sources have to be manually added to the source search path or JBoss AS 7 has to be imported as a project. That's kind of clunky, especially as importing AS7 as a project here crashes JBoss Developer Studio. Manually listing each source artifact shouldn't be necessary.

               

              If you're working on AS7 its self you'll have the project open and the sources accessible, but if you're working on an app that just happens to run on AS7 you won't. Support for auto-discovery of the sources for the appserver would _rock_.

              Currently JBoss Developer Studio / JBoss Tools has all the knowledge required to find the correct source archive in the local Maven repo, in that it knows the class name and the jar it's in, but it doesn't look for it and offer to add it to the source path, so I still have to delve through my .m2 and add source archives manually. Still: progress. Fetching the sources with Maven at least gets me the source archives.

               

              Thanks for pointing out my stupid mistake.

              • 4. Re: How to get ALL sources for a JBoss AS 7 release, including external deps?
                jaikiran

                I've moved this to the JBoss Tools forum. I'm sure they would be interested in your feedback and might even be able to point you to better ways of dealing with this.

                • 5. Re: How to get ALL sources for a JBoss AS 7 release, including external deps?
                  ctomc

                  Yeah i would agree that having this in IDE as auto-download option is a must.

                   

                  Personaly i am using Intellij and know that downling app server resources is painles even if you need them even later on when debugging some classes.

                   

                  but from my quick search around the web i have found that eclipse has this capability as part of m2eclipse integration.

                  https://docs.sonatype.org/display/M2ECLIPSE/Resolving+artifact+sources

                   

                  hope this helps in any way.

                  More help on this subject can be provided by tools guys.

                   

                   

                  --

                  tomaz

                  • 6. Re: How to get ALL sources for a JBoss AS 7 release, including external deps?
                    maxandersen

                    we can't provide better source than is available in mvn - so if it is not available there its AS that need fixing

                     

                    But see https://community.jboss.org/en/tools/blog/2012/01/24/jboss-source-lookup for how we provide it for debugging of AS servers.

                    • 7. Re: How to get ALL sources for a JBoss AS 7 release, including external deps?
                      jaikiran

                      Max Rydahl Andersen wrote:

                       

                       

                      But see https://community.jboss.org/en/tools/blog/2012/01/24/jboss-source-lookup for how we provide it for debugging of AS servers.

                      Given my lack of Eclipse usage for some time now, I don't fully understand that blog but I think this statement in that blog summarizes where the source files are looked for:

                       

                      The Source Lookup plugin finds source for a mavenized archive as follows:

                       

                          using the m2e API

                          using the archive's metadata (META-INF/maven)

                          using nexus repositories that can be defined using the Source Lookup preferences page

                      Now in Craig's case, the JBoss AS7 sources were published to local maven repository (on his filesystem) after he built the server. They weren't available in any of the remote maven repos. So does the source lookup plugin take into consideration the local maven repository for looking up the sources?

                       

                      I think that's one of the points that Craig's bringing up:

                      Craig Ringer wrote:

                       

                      • When debugging a project running on AS7, the JBoss Tools / m2e integration doesn't automatically find JBoss AS 7 sources in the local maven repository, the sources have to be manually added to the source search path or JBoss AS 7 has to be imported as a project. That's kind of clunky, especially as importing AS7 as a project here crashes JBoss Developer Studio. Manually listing each source artifact shouldn't be necessary.
                      • 8. Re: How to get ALL sources for a JBoss AS 7 release, including external deps?
                        maxandersen

                        if the AS7 sources are in your local repository and their GAV coordinates match what is in the binary jars found by the maven source lookup integration then it will use that.

                        • 9. Re: How to get ALL sources for a JBoss AS 7 release, including external deps?
                          erce

                          To debug in Eclipse, it is nice to create a simple project which depends on all your sources + JBoss build:

                           

                          <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

                                    <modelVersion>4.0.0</modelVersion>

                                      <parent>

                                              <groupId>yourgroup</groupId>

                                              <artifactId>yourparent</artifactId>

                                              <version>yourversion</version>

                                    </parent>

                                    <artifactId>yourapp-jboss-debug</artifactId>

                                    <name>yourproject: JBoss Debug Project</name>

                                    <description>yourproject: JBoss Debug Project</description>

                                    <packaging>jar</packaging>

                                    <!-- Dependency list -->

                                    <dependencies>

                                              <!-- Dependency to JBoss build which brings all jars and sources -->

                                              <dependency>

                                                        <groupId>org.jboss.as</groupId>

                                                        <artifactId>jboss-as-build</artifactId>

                                                        <version>7.1.1.Final</version>

                                                        <type>pom</type>

                                              </dependency>

                                              <!-- Dependency to yourapp build which brings all jars and sources -->

                                              <dependency>

                                                        <groupId>yourgroup</groupId>

                                                        <artifactId>yourproject which builds all the sources and gets deployed - probably the ear</artifactId>

                                                        <version>${project.version}</version>

                                                        <type>pom</type>

                                              </dependency>

                                    </dependencies>

                          </project>

                           

                          Then you do "mvn clean install eclipse:eclipse -DdownloadSources=true" (of course with maven repo http://repository.jboss.org/nexus/content/groups/public configured in maven settings) and configure your debug configuration in Eclipse to run in with this project and voila, there it is, all the JBoss sources are attached!