Skip to content

Instantly share code, notes, and snippets.

@deathcap
Last active August 29, 2015 14:01
Show Gist options
  • Save deathcap/b6d787435b560b281b03 to your computer and use it in GitHub Desktop.
Save deathcap/b6d787435b560b281b03 to your computer and use it in GitHub Desktop.
Gradle vs Maven, >2x faster build times
(note: mostly fixed by removing 'clean' from gradle defaultTasks)
Junket $ time ./gradlew
:clean UP-TO-DATE
:compileJava
:processResources UP-TO-DATE
:classes
:jar
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build
:copySignedLibs UP-TO-DATE
:shadowJar
BUILD SUCCESSFUL
Total time: 6.156 secs
real 0m6.562s
user 0m9.662s
sys 0m0.846s
Junket $ time ./gradlew
:clean
:compileJava
:processResources UP-TO-DATE
:classes
:jar
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build
:copySignedLibs UP-TO-DATE
:shadowJar
BUILD SUCCESSFUL
Total time: 5.574 secs
real 0m5.977s
user 0m9.251s
sys 0m0.721s
Junket $ time ./gradlew
:clean
:compileJava
:processResources UP-TO-DATE
:classes
:jar
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build
:copySignedLibs UP-TO-DATE
:shadowJar
BUILD SUCCESSFUL
Total time: 5.554 secs
real 0m5.955s
user 0m9.010s
sys 0m0.720s
Junket $ mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Junket 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ junket ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/admin/games/voxeljs/Junket/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ junket ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ junket ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/admin/games/voxeljs/Junket/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ junket ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ junket ---
[INFO] No tests to run.
[INFO] Surefire report directory: /Users/admin/games/voxeljs/Junket/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ junket ---
[INFO] Building jar: /Users/admin/games/voxeljs/Junket/target/junket-0.0.1.jar
[INFO]
[INFO] --- maven-shade-plugin:2.3:shade (default) @ junket ---
[INFO] Including org.bukkit:bukkit:jar:1.7.9-R0.2-SNAPSHOT in the shaded jar.
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing /Users/admin/games/voxeljs/Junket/target/junket-0.0.1.jar with /Users/admin/games/voxeljs/Junket/target/junket-0.0.1-shaded.jar
[INFO] Dependency-reduced POM written at: /Users/admin/games/voxeljs/Junket/dependency-reduced-pom.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.322s
[INFO] Finished at: Fri May 16 19:00:08 PDT 2014
[INFO] Final Memory: 8M/27M
[INFO] ------------------------------------------------------------------------
Junket $ mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Junket 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ junket ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/admin/games/voxeljs/Junket/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ junket ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ junket ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/admin/games/voxeljs/Junket/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ junket ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ junket ---
[INFO] No tests to run.
[INFO] Surefire report directory: /Users/admin/games/voxeljs/Junket/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ junket ---
[INFO]
[INFO] --- maven-shade-plugin:2.3:shade (default) @ junket ---
[INFO] Including org.bukkit:bukkit:jar:1.7.9-R0.2-SNAPSHOT in the shaded jar.
[WARNING] junket-0.0.1.jar, bukkit-1.7.9-R0.2-SNAPSHOT.jar define 3655 overlappping classes:
[WARNING] - com.avaje.ebeaninternal.server.reflect.EnhanceBeanReflect
[WARNING] - com.avaje.ebeaninternal.server.core.DefaultServer
[WARNING] - org.bukkit.plugin.PluginAwareness
[WARNING] - com.google.common.collect.MapEvictionListener
[WARNING] - com.google.common.collect.Iterators$12
[WARNING] - com.google.common.collect.CustomConcurrentHashMap$2
[WARNING] - com.avaje.ebeaninternal.server.persist.dmlbind.BindableUnidirectional
[WARNING] - com.avaje.ebeaninternal.server.type.ImmutableCompoundTypeBuilder$1
[WARNING] - org.yaml.snakeyaml.constructor.Construct
[WARNING] - org.bukkit.plugin.SimpleServicesManager
[WARNING] - 3645 more...
[WARNING] maven-shade-plugin has detected that some .class files
[WARNING] are present in two or more JARs. When this happens, only
[WARNING] one single version of the class is copied in the uberjar.
[WARNING] Usually this is not harmful and you can skeep these
[WARNING] warnings, otherwise try to manually exclude artifacts
[WARNING] based on mvn dependency:tree -Ddetail=true and the above
[WARNING] output
[WARNING] See http://docs.codehaus.org/display/MAVENUSER/Shade+Plugin
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing /Users/admin/games/voxeljs/Junket/target/junket-0.0.1.jar with /Users/admin/games/voxeljs/Junket/target/junket-0.0.1-shaded.jar
[INFO] Dependency-reduced POM written at: /Users/admin/games/voxeljs/Junket/dependency-reduced-pom.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.510s
[INFO] Finished at: Fri May 16 19:00:21 PDT 2014
[INFO] Final Memory: 8M/31M
[INFO] ------------------------------------------------------------------------
Junket $ cat build.gradle
apply plugin: 'java'
apply plugin: 'shadow'
version = '0.0.1'
defaultTasks 'clean', 'build', 'shadow'
repositories {
mavenLocal()
mavenCentral()
// see https://github.com/simplyianm/bukkit-bootstrap/blob/master/build.gradle
maven {
url 'http://repo.md-5.net/content/groups/public/'
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:0.8'
}
}
dependencies {
compile group: 'org.bukkit', name: 'bukkit', version: '1.7.9-R0.2-SNAPSHOT'
}
jar {
manifest {
attributes 'Main-Class': 'deathcap.junket.Main'
}
}
Junket $ cat pom.xml
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- The Basics -->
<groupId>deathcap.junket</groupId>
<artifactId>junket</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.7.9-R0.2-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
<!-- use Bukkit snapshots from https://github.com/Bukkit/Bukkit/blob/master/pom.xml -->
<distributionManagement>
<repository>
<id>repobo-rel</id>
<name>repo.bukkit.org Releases</name>
<url>http://repo.bukkit.org/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>repobo-snap</id>
<name>repo.bukkit.org Snapshots</name>
<url>http://repo.bukkit.org/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<!-- include dependencies into uberjar
https://maven.apache.org/plugins/maven-shade-plugin/examples/includes-excludes.html -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<!-- http://maven.apache.org/shared/maven-archiver/index.html -->
<archive>
<manifest>
<mainClass>deathcap.junket.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<!-- More Project Information -->
<name>Junket</name>
<url>https://github.com/deathcap/Junket</url>
<inceptionYear>2014</inceptionYear>
</project>
Junket $ mvn -version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 05:51:28-0800)
Maven home: /Users/admin/.m2
Java version: 1.7.0_17, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9.2", arch: "x86_64", family: "mac"
Junket $ ./gradlew -version
------------------------------------------------------------
Gradle 1.12
------------------------------------------------------------
Build time: 2014-04-29 09:24:31 UTC
Build number: none
Revision: a831fa866d46cbee94e61a09af15f9dd95987421
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
Ivy: 2.2.0
JVM: 1.7.0_17 (Oracle Corporation 23.7-b01)
OS: Mac OS X 10.9.2 x86_64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment