A talk by torstein at escenic.com
…but let’s slow down a bit and think about Maven
src/main/java
//depot/main/io/lib/FTPProtocol.jar#2 - delete change 41404 (binary)
//depot/main/io/lib/JAI.jar#2 - delete change 17647 (binary)
//depot/main/io/lib/MRJClasses.jar#2 - delete change 41854 (binary)
//depot/main/io/lib/PDFBox.jar#2 - delete change 77300 (binary)
package md;
public class Main {
public static void main(String[] args) {
}
}
Dependency tree:
md:md-app:war:0.1
Short and sweet 😃
Let’s add log4j to it:
package md;
import org.apache.log4j.*;
public class Main {
Logger mLogger = Logger.getLogger(getClass());
public static void main(String[] args) {
mLogger.debug("Hello world from " + Main.class.getName());
}
}
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
md:md-app:war:0.1
\- log4j:log4j:jar:1.2.16:compile
Nice!
package md;
import org.apache.log4j.*;
import nu.xom.*;
public class Main {
Logger mLogger = Logger.getLogger(getClass());
public static void main(String[] args) {
mLogger.debug("Hello world from " + Main.class.getName());
Element element = new Element("content-type");
}
}
<dependency>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
<version>1.2.5</version>
</dependency>
md:md-app:war:0.1
+- log4j:log4j:jar:1.2.16:compile
\- xom:xom:jar:1.2.5:compile
+- xml-apis:xml-apis:jar:1.3.03:compile
+- xerces:xercesImpl:jar:2.8.0:compile
\- xalan:xalan:jar:2.7.0:compile
WOT?!
Nature of a Maven project
compile
test
provided
You aim for a certain minor version of ECE
But need a few new features
<dependency>
<groupId>com.escenic.engine</groupId>
<artifactId>engine-core</artifactId>
<version>5.7.unstable-VF-6294.168099</version>
</dependency>
$ mvn dependency:tree
$ mvn dependency:analyze
Unused declared dependencies found:
commons-lang:commons-lang:jar:2.3:compile
$ ls -l /opt/escenic/engine/lib
$ ls -l /opt/escenic/engine/template/WEB-INF/lib
$ ls -l /opt/tomcat-engine1/escenic/lib
<dependency>
<groupId>com.escenic.engine</groupId>
<artifactId>engine-core</artifactId>
<version>${engine.version}</version>
<scope>provided</scope>
</dependency>
engine-core
engine-core
provided
and runtime
scope mean:I trust the runtime environment to be the same as what I’ve run my JUnit tests on
Benefits of having a firm grip of project dependencies:
com.escenic.MyClass
on the class path.