Hi guys,
We should actively notify/teach each other about tips and tricks.
There's a lot we can learn from each other.
I'll start with a build tip:
The problem
========
- How bloated is the dependency tree of my module? This affects the
download zip size, but also the minimal jars needed to run.
- Are there dead dependency left in my module?
The solution
========
- First thing to understand is that it has to reviewed module by
module
(focus on end-user modules such as drools-compiler,
drools-camel-server, guvnor-webapp, ...).
- Use the command
mvn dependency:tree
Example
=====
Here's the output on drools-compiler.
I've annotated a couple of possible incidents which might or might
not be a problem.
It's hard to tell without someone with extensive drools-compiler
experience looking further into it.
drools-compiler [master] $ mvn dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building Drools :: Compiler 5.3.0-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.2:tree (default-cli) @
drools-compiler ---
[INFO] org.drools:drools-compiler:jar:5.3.0-SNAPSHOT
[INFO] +- org.drools:drools-core:jar:5.3.0-SNAPSHOT:compile
[INFO] | \- org.drools:knowledge-api:jar:5.3.0-SNAPSHOT:compile
[INFO] +- org.drools:drools-core:test-jar:tests:5.3.0-SNAPSHOT:test
[INFO] +- org.apache.felix:org.osgi.core:jar:1.4.0:provided
[INFO] +- org.apache.felix:org.osgi.compendium:jar:1.4.0:provided
[INFO] +- org.antlr:
antlr-runtime:jar:3.3:compile
[INFO] +- org.antlr:
antlr:jar:3.3:compile
Incident 1: maybe org.antlr:antlr-runtime:jar:3.3 is a
subset of org.antlr:antlr-runtime:jar:3.3 ? (antlr is wierd IIRC -
so this is probably not in this case)
[INFO] +- org.antlr:stringtemplate:jar:3.2.1:compile
[INFO] +- antlr:
antlr:jar:2.7.7:compile
Incident 2: maybe antlr:antlr:jar:2.7.7 is a subset of
org.antlr:antlr-runtime:jar:3.3 ? (antlr is wierd IIRC - so this is
probably not in this case)
In general, dependencies with a non-namespaced groupId need to be
upgraded if possible.
[INFO] +- org.antlr:gunit:jar:3.3:test
[INFO] +- org.eclipse.jdt.core.compiler:ecj:jar:3.5.1:compile
[INFO] +- janino:janino:jar:2.5.15:compile
Note that janino is optional (output doesn't show that :( ) - no
problem here
[INFO] +- org.mvel:mvel2:jar:2.1-SNAPSHOT:compile
[INFO] +- com.thoughtworks.xstream:xstream:jar:1.3.1:test
[INFO] | \- xpp3:xpp3_min:jar:1.1.4c:test
[INFO] +- org.mortbay.
jetty:jetty-embedded:jar:6.1.15:test
Incident 3: Wierd that drools-compiler would need jetty
to test something?
[INFO] | +- org.mortbay.jetty:jetty:jar:6.1.15:test
[INFO] | | +- org.mortbay.jetty:jetty-util:jar:6.1.15:test
[INFO] | | \- org.mortbay.jetty:servlet-api:jar:2.5-20081211:test
[INFO] | \- javax.servlet.jsp:jsp-api:jar:2.1:test
[INFO] +- org.opensymphony.quartz:quartz:jar:1.6.1:test
[INFO] +- com.sun.xml.bind:jaxb-xjc:jar:2.2.1.1:provided
[INFO] +- com.sun.xml.bind:jaxb-impl:jar:2.2.1.1:provided
[INFO] +- javax.xml.bind:jaxb-api:jar:2.2.1:provided
[INFO] +- javax.xml.stream:stax-api:jar:1.0-2:provided
[INFO] +- javax.activation:activation:jar:1.1:provided
[INFO] +- net.java.dev.
glazedlists:glazedlists_java15:jar:1.8.0:test
Incident 4: Wierd that drools-compiler would need a swing
framework to test something?
[INFO] +- junit:junit:jar:4.8.1:test
[INFO] \- org.mockito:mockito-all:jar:1.8.2:test
[INFO]
------------------------------------------------------------------------
[INFO] BUILD
SUCCESS
[INFO]
------------------------------------------------------------------------
[INFO] Total time:
1.951s
[INFO] Finished at: Wed May 11 15:09:09 CEST
2011
[INFO] Final Memory:
10M/309M
[INFO]
------------------------------------------------------------------------
Here's another example showing another type of incident:
drools-camel-server [master] $ mvn dependency:tree
...
[INFO] +- org.drools:drools-grid-impl:jar:5.3.0-SNAPSHOT:compile
[INFO] | +- org.apache.mina:mina-core:jar:2.0.1:compile (version
managed from 2.0.0-M6)
[INFO] | \- com.hazelcast:hazelcast:jar:1.8.5:compile
...
[INFO] +- org.apache.camel:camel-cxf:jar:2.4.0:compile
[INFO] | \- org.apache.cxf:
cxf-rt-frontend-jaxrs:jar:2.2.9:compile
[INFO] | +-
org.apache.cxf:cxf-common-utilities:jar:2.2.9:compile
[INFO] | +-
org.apache.cxf:cxf-rt-transports-http:jar:2.2.9:compile
[INFO] | +-
org.apache.cxf:cxf-rt-databinding-aegis:jar:2.2.9:compile
[INFO] | +- jaxen:jaxen:jar:1.1.1:compile
[INFO] | \- org.apache.xmlbeans:xmlbeans:jar:2.4.0:compile
...
[INFO] +- org.apache.cxf:
cxf-bundle-jaxrs:jar:2.2.9:compile
Incident A: This cxf-bundle-jaxrs is an uber jar.
Uber
jars (as dependencies) are evil.
An uber jar extracts the classes from other jars and zips them
(=aggregate) in itself.
This effectively kills maven's ability to only have 1 class of
something in your classpath.
It turns your classpath into box of chocolates:
you never
know what version of class file you'll get.
Also, it bloats the classpath with things you don't need (like
jetty in this case)
and those cause havoc if you deploy it to some app servers.
[INFO] | +- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +-
org.apache.geronimo.specs:geronimo-annotation_1.0_spec:jar:1.1.1:compile
[INFO] | +-
org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0.1:compile
[INFO] | +- wsdl4j:wsdl4j:jar:1.6.2:compile
[INFO] | +-
org.apache.ws.commons.schema:XmlSchema:jar:1.4.5:compile
[INFO] | +- commons-lang:commons-lang:jar:2.4:compile
[INFO] | +-
org.apache.geronimo.specs:geronimo-activation_1.1_spec:jar:1.0.2:compile
[INFO] | +- org.codehaus.woodstox:wstx-asl:jar:3.2.9:compile
[INFO] | +- org.apache.neethi:neethi:jar:2.0.4:compile
[INFO] | +-
org.apache.geronimo.specs:geronimo-javamail_1.4_spec:jar:1.6:compile
[INFO] | +- org.springframework:spring-web:jar:2.5.6:compile
[INFO] | +- org.mortbay.jetty:
jetty:jar:6.1.21:compile
[INFO] | +- org.mortbay.jetty:jetty-util:jar:6.1.21:compile
[INFO] | +- javax.ws.rs:jsr311-api:jar:1.0:compile
[INFO] | +- org.apache.abdera:abdera-core:jar:1.0:compile
[INFO] | +- org.apache.abdera:abdera-i18n:jar:1.0:compile
[INFO] | +- commons-codec:commons-codec:jar:1.3:compile
[INFO] | +- org.apache.abdera:abdera-parser:jar:1.0:compile
[INFO] | +-
org.apache.ws.commons.axiom:axiom-impl:jar:1.2.7:compile
[INFO] | +- org.apache.ws.commons.axiom:axiom-api:jar:1.2.7:compile
[INFO] | +-
org.apache.abdera:abdera-extensions-json:jar:1.0:compile
[INFO] | \-
org.apache.abdera:abdera-extensions-main:jar:1.0:compile
...
Also, if you're trying to solve such things on master, try upgrading
the dependencies first (not on a release branch - upgrading is
risky!):
many issues in the poms tend to be identified and fixed in newer
versions.
--
With kind regards,
Geoffrey De Smet