From 11f02128e6cea13729166e54dbed0454e77f0ad5 Mon Sep 17 00:00:00 2001 From: Emux Date: Tue, 19 Jul 2016 20:15:12 +0300 Subject: [PATCH] Jar with dependencies, closes #82 --- vtm-android-gdx/build.gradle | 17 ++++++++++++++++- vtm-android/build.gradle | 15 +++++++++++++++ vtm-desktop/build.gradle | 10 +++++++++- vtm-ios/build.gradle | 9 +++++++++ 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/vtm-android-gdx/build.gradle b/vtm-android-gdx/build.gradle index 5eb1a45b..2ab0c4f4 100644 --- a/vtm-android-gdx/build.gradle +++ b/vtm-android-gdx/build.gradle @@ -3,7 +3,6 @@ apply plugin: 'com.github.dcendents.android-maven' dependencies { compile project(':vtm-gdx') - compile project(':vtm-themes') compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion" compile 'com.caverock:androidsvg:1.2.2-beta-1' compile 'com.noveogroup.android:android-logger:1.3.6' @@ -66,6 +65,22 @@ android.applicationVariants.all { variant -> artifacts.add('archives', task); } +android.applicationVariants.all { variant -> + def name = variant.buildType.name + if (name.equals("debug")) { + print "Skipping debug jar" + return; // Skip debug builds. + } + def task = project.tasks.create "fatJar${name.capitalize()}", Jar + task.classifier = 'jar-with-dependencies' + task.dependsOn variant.javaCompile + task.from variant.javaCompile.destinationDir + task.from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } + task.from("${rootProject.projectDir}/vtm-android/natives") + task.from('natives') + artifacts.add('archives', task); +} + afterEvaluate { configurations.archives.artifacts.removeAll { it.file =~ 'apk' } } diff --git a/vtm-android/build.gradle b/vtm-android/build.gradle index 8cdec00d..18a9a585 100644 --- a/vtm-android/build.gradle +++ b/vtm-android/build.gradle @@ -60,6 +60,21 @@ android.libraryVariants.all { variant -> artifacts.add('archives', task); } +android.libraryVariants.all { variant -> + def name = variant.buildType.name + if (name.equals("debug")) { + print "Skipping debug jar" + return; // Skip debug builds. + } + def task = project.tasks.create "fatJar${name.capitalize()}", Jar + task.classifier = 'jar-with-dependencies' + task.dependsOn variant.javaCompile + task.from variant.javaCompile.destinationDir + task.from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } + task.from('natives') + artifacts.add('archives', task); +} + // Automated Gradle project deployment to Sonatype OSSRH if (isReleaseVersion && project.hasProperty("SONATYPE_USERNAME")) { afterEvaluate { diff --git a/vtm-desktop/build.gradle b/vtm-desktop/build.gradle index dbfa4e9d..eea899d0 100644 --- a/vtm-desktop/build.gradle +++ b/vtm-desktop/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'application' dependencies { compile project(':vtm-gdx') - compile project(':vtm-themes') compile files('natives') compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" compile "com.badlogicgames.gdx:gdx-backend-jglfw:$gdxVersion" @@ -23,8 +22,17 @@ task nativesJar(type: Jar) { from('natives') } +task fatJar(type: Jar, dependsOn: classes) { + classifier = 'jar-with-dependencies' + from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } + from('natives') + exclude 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.SF' + with jar +} + artifacts { archives nativesJar + archives fatJar } mainClassName = 'org.oscim.gdx.GdxMapApp' diff --git a/vtm-ios/build.gradle b/vtm-ios/build.gradle index fdde1f0b..c97afe0d 100644 --- a/vtm-ios/build.gradle +++ b/vtm-ios/build.gradle @@ -62,8 +62,17 @@ task nativesJar(type: Jar) { from('natives') } +task fatJar(type: Jar, dependsOn: classes) { + classifier = 'jar-with-dependencies' + from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } + from('natives') + exclude 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.SF' + with jar +} + artifacts { archives nativesJar + archives fatJar } // Automated Gradle project deployment to Sonatype OSSRH