You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "David J. Biesack" <Da...@sas.com> on 2007/10/17 21:48:52 UTC

debug vs. non debug jar builds

I'm trying to configure maven profiles to build a debug jar (one that contains
**/*.java source, compile debug flags, etc.) vs. non-debug or "release" jars
that do not contain source.

All of our pom files use a common parent pom which configures the maven build
(i.e. fits our source management standard, etc.)

The profiles defined in parent pom are shown below.

However, when I install the parent pom into the repo, our CruiseControl builds (which
do not specify a profile, so the debug profile should be used) fail.
The build for a library jar succeeds, but the builds which depends
on the library fail with a mysterious "duplicate class" error for a class that
is in the library jar.

    compiler:compile
    [INFO] Compiling 4 source files to /var/local/cc/checkout/tornado-console/Research/AdvancedComputing/tornado-console/target/classes
    [INFO] ------------------------------------------------------------------------
    [ERROR] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Compilation failure
    /u/acladmin/.m2/repository/com/sas/acl/tornado/tornado/0.1-SNAPSHOT/tornado-0.1-SNAPSHOT.jar(com/sas/acl/tornado/jms/AbstractTornadoSession.java):[19,16] duplicate class: com.sas.acl.tornado.support.AbstractTornadoSession
    /u/acladmin/.m2/repository/com/sas/acl/tornado/tornado/0.1-SNAPSHOT/tornado-0.1-SNAPSHOT.jar(com/sas/acl/tornado/jms/TornadoQueueSession.java):[9,-1] cannot access com.sas.acl.tornado.jms.AbstractTornadoSession
    bad class file: /u/acladmin/.m2/repository/com/sas/acl/tornado/tornado/0.1-SNAPSHOT/tornado-0.1-SNAPSHOT.jar(com/sas/acl/tornado/jms/AbstractTornadoSession.java)
    file does not contain class com.sas.acl.tornado.jms.AbstractTornadoSession
    [INFO] ------------------------------------------------------------------------
    [INFO] For more information, run Maven with the -e switch
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 10 seconds
    [INFO] Finished at: Wed Oct 17 14:01:45 EDT 2007
    [INFO] Final Memory: 38M/484M
    [INFO] ------------------------------------------------------------------------

The following shows that the class exists as expected:

# javap -classpath /u/acladmin/.m2/repository/com/sas/acl/tornado/tornado/0.1-SNAPSHOT/tornado-0.1-SNAPSHOT.jar com.sas.acl.tornado.support.AbstractTornadoSession 
Compiled from "AbstractTornadoSession.java"
public abstract class com.sas.acl.tornado.support.AbstractTornadoSession extends java.lang.Object implements com.sas.acl.tornado.core.TornadoSession{
    public com.sas.acl.tornado.support.AbstractTornadoSession(java.lang.String);
    public java.lang.String getId();
    public java.lang.Object getAttribute(java.lang.Object);
    public java.util.Set getAttributeKeys();
    protected void removeAllAttributes();
    public java.lang.Object removeAttribute(java.lang.Object);
    public java.lang.Object setAttribute(java.lang.Object, java.lang.Object);
}


Here is the excerpt from the parent pom. (Note: we store resources, i.e. **/*.properties, **/*.xml, etc.
in the Source/Java folder, which is also where the source is.)

  <project>
   ...
  <profiles>
      <profile>
         <id>debug</id>
         <activation>
            <activeByDefault>true</activeByDefault>
         </activation>
         <build>
            <resources>
               <resource>
                  <directory>Source/Java</directory>
                  <excludes>
                     <exclude>build.properties</exclude>
                     <exclude>build.xml</exclude>
                  </excludes>
                  <filtering>true</filtering>
               </resource>
               <resource>
                  <directory>Source/JavaNLS</directory>
               </resource>
            </resources>
         </build>
      </profile>
      <profile>
         <id>release</id> <!-- activate with mvn -P release -->
         <build>
            <resources>
               <resource>
                  <directory>Source/Java</directory>
                  <excludes>
                     <exclude>build.properties</exclude>
                     <exclude>build.xml</exclude>
                     <exclude>**/*.java</exclude>
                  </excludes>
                  <filtering>true</filtering>
               </resource>
               <resource>
                  <directory>Source/JavaNLS</directory>
               </resource>
            </resources>
         </build>
      </profile>
   </profiles>

  </project>

It seems like the use of <resources> results in duplicate resources, but
the jar does not seem to contain duplicates.

Local builds seem to work fine; i.e. I get well formed jar files if I run

  mvn -P debug clean package
or
  mvn -P release clean package

If I remove the profiles from the paren pom and simply list the <resources> in the main <build>
section of the parent pom, all the projects build correctly.

Any ideas on how to solve this? What is the best way to be able to configure
one profile to include *.java in the jar and another to exclude?

(Optionally, having a single Maven build create the jar as well as a *-sources.zip
with just the **/*.java files, is also acceptable, but less desirable.)

thanks

-- 
David J. Biesack     SAS Institute Inc.
(919) 531-7771       SAS Campus Drive
http://www.sas.com   Cary, NC 27513


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org