From dac9b8adad75be55e651512854a16c62d7845f71 Mon Sep 17 00:00:00 2001 From: Hannes Janetzek Date: Sun, 23 Feb 2014 18:50:17 +0100 Subject: [PATCH] gradle cleanups --- build.gradle | 14 ++++- jdee.gradle | 72 +++++++++++++++++++++++ settings.gradle | 1 + vtm-android-app | 2 +- vtm-android-example/build.gradle | 39 ++----------- vtm-android/build.gradle | 98 ++++++++++++++++---------------- vtm-ext-libs | 2 +- vtm-extras/build.gradle | 14 ++--- vtm-gdx-android/build.gradle | 13 ++--- vtm-gdx-html/build.gradle | 64 ++++++--------------- vtm-gdx/build.gradle | 5 +- vtm/build.gradle | 17 ++++-- 12 files changed, 185 insertions(+), 156 deletions(-) create mode 100644 jdee.gradle diff --git a/build.gradle b/build.gradle index 4ff9cfa2..c29723dd 100644 --- a/build.gradle +++ b/build.gradle @@ -9,9 +9,9 @@ buildscript { } } -allprojects { - apply plugin: 'idea' +apply from:'jdee.gradle' +allprojects { group = 'org.oscim' version = '0.5.9-SNAPSHOT' @@ -19,11 +19,16 @@ allprojects { repositories { mavenCentral() + //maven { url 'https://github.com/hjanetzek/maven-repo/raw/master/' } mavenLocal() } + + // create IntelliJ project settings - untested + apply plugin: 'idea' } subprojects { + // create eclipse project settings apply plugin: 'eclipse' task copySettings(type: Copy) { @@ -33,4 +38,9 @@ subprojects { } eclipseProject.dependsOn copySettings + + // create emacs JDEE project settings + // http://ignatyev-dev.blogspot.de/2013/07/gradle-projects-in-jdee.html + apply from:'../jdee.gradle' } + diff --git a/jdee.gradle b/jdee.gradle new file mode 100644 index 00000000..f53208d9 --- /dev/null +++ b/jdee.gradle @@ -0,0 +1,72 @@ +def prj = { project -> + + "(jde-project-file-version" (["1.0"]) + "(jde-set-variables" { + "'(jde-compile-option-directory" ([project.sourceSets.main.output.classesDir]) + "'(jde-junit-working-directory" ([project.projectDir]) + + "'(jde-compile-option-source" { + "'(" (["default"]) + } + + "'(jde-compile-option-target" { + "'(" (["default"]) + } + + "'(jde-compile-option-command-line-args" { + "'(" (["-${project.sourceCompatibility}"]) + } + + "'(jde-sourcepath" { + "'(" ( + project.sourceSets.main.allSource.srcDirs + + project.sourceSets.test.allSource.srcDirs) + } + + "'(jde-global-classpath" { + "'(" ( + [] + project.sourceSets.main.output.classesDir + + project.sourceSets.test.output.classesDir + + project.sourceSets.main.allSource.srcDirs + + project.sourceSets.test.allSource.srcDirs + + (([] as Set) + project.configurations.compile.getFiles() + + project.configurations.testCompile.getFiles())) + } + } +} + +subprojects { + task("jdee") << { + def output = new File(project.projectDir, "prj.el").newPrintWriter() + try { + prj.delegate = new NodeBuilder() { + def lev = 0 + + def write = { Object file -> + output.print '\n' + ''.padRight(lev, ' ') + "\"${file}\"".tr('\\', '/') + } + + Object createNode(Object name) { + output.print '\n' + ''.padRight(lev++, ' ') + name + return name + } + + Object createNode(Object name, Object value) { + createNode(name) + value.each write + return name + } + + void nodeCompleted(Object parent, Object child) { + output.print ")" + lev-- + } + } + prj(project) + output.close() + } finally { + output.flush() + } + } +} + diff --git a/settings.gradle b/settings.gradle index 4f439899..56789157 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,3 +8,4 @@ include ':vtm-gdx-html' include ':vtm-gdx-android' include ':vtm-android-app' include ':vtm-themes' +//include ':vtm-ext-libs' diff --git a/vtm-android-app b/vtm-android-app index 2fc23ee2..92d16812 160000 --- a/vtm-android-app +++ b/vtm-android-app @@ -1 +1 @@ -Subproject commit 2fc23ee26b0eb99e13fba3c65177c761f3b6cdf1 +Subproject commit 92d16812200c396536bbfd5a5aa34ee08084e26c diff --git a/vtm-android-example/build.gradle b/vtm-android-example/build.gradle index d01fa468..a637d7c1 100644 --- a/vtm-android-example/build.gradle +++ b/vtm-android-example/build.gradle @@ -10,20 +10,12 @@ buildscript { apply plugin: 'android' dependencies { - //compile fileTree(dir: 'libs', include: '*.jar') + //compile 'org.oscim:vtm-android:0.5.9-SNAPSHOT' + //compile 'org.oscim:vtm-themes:0.5.9-SNAPSHOT' compile project(':vtm-android') compile project(':vtm-themes') } -// task copyAssets(type: Copy) { -// from "$rootDir/vtm/assets" -// into "assets" -// include '**/*' -// } - -// tasks.withType(JavaCompile) { compileTask -> -// compileTask.dependsOn copyAssets } - android { compileSdkVersion 19 buildToolsVersion '19.0.1' @@ -31,10 +23,8 @@ android { sourceSets { main { manifest.srcFile 'AndroidManifest.xml' - java.srcDirs = ['src', 'assets'] + java.srcDirs = ['src'] resources.srcDirs = ['src', 'assets'] - aidl.srcDirs = ['src', 'assets'] - renderscript.srcDirs = ['src', 'assets'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } @@ -45,38 +35,23 @@ android { } // Including configurations into Eclipse -eclipse.classpath.plusConfigurations += configurations.compile -eclipse.jdt{ +eclipse.jdt { sourceCompatibility = 1.6 targetCompatibility = 1.6 } // Configuring Eclipse classpath eclipse.classpath { - //customizing the classes output directory: + plusConfigurations += configurations.compile + defaultOutputDir = file('bin/classes') file { - - // Manipulation of the classpath XML before merging local - // and generated copies - // beforeMerged { classpath -> - // // Remove all source entries to avoid overlap - // classpath.entries.removeAll() { c -> - // c.kind == 'src' - // } - // } - // Direct manipulation of the generated classpath XML withXml { - // Since non-default source directories are used - // they need to be manually added to the classpath XML def node = it.asNode() - - // Main source directory node.appendNode('classpathentry kind="src" path="src"') - // Generated code directory node.appendNode('classpathentry kind="src" path="gen"') } } @@ -90,6 +65,4 @@ eclipse.project { buildCommand 'com.android.ide.eclipse.adt.PreCompilerBuilder' buildCommand 'com.android.ide.eclipse.adt.ApkBuilder' - linkedResource name: 'assets', type: '2', - locationUri: 'PARENT-1-PROJECT_LOC/vtm-themes/resources/assets' } diff --git a/vtm-android/build.gradle b/vtm-android/build.gradle index d087fdb3..ce3f44b5 100644 --- a/vtm-android/build.gradle +++ b/vtm-android/build.gradle @@ -4,7 +4,6 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:0.8.+' - // for aar/maven stuff // https://github.com/dcendents/android-maven-plugin classpath 'com.github.dcendents:android-maven-plugin:1.0' @@ -15,15 +14,20 @@ apply plugin: 'android-library' apply plugin: 'android-maven' dependencies { + //compile 'org.oscim:vtm:0.5.9-SNAPSHOT' compile project(':vtm') - compile files("${rootDir}/vtm-ext-libs/native-libs.jar") + compile 'com.android.support:support-v4:19.0.1' compile 'org.slf4j:slf4j-android:1.7.6' + + // local jars will be packaged into the aar + compile files("${rootDir}/vtm-ext-libs/native-libs.jar") } android { compileSdkVersion 19 buildToolsVersion '19.0.1' + sourceSets { main { manifest.srcFile 'AndroidManifest.xml' @@ -35,62 +39,58 @@ android { debug.setRoot('build-types/debug') release.setRoot('build-types/release') } + + lintOptions.abortOnError false } +eclipse { + classpath { + plusConfigurations += configurations.compile + //customizing the classes output directory: + defaultOutputDir = file('bin/classes') -// Including configurations into Eclipse -eclipse.classpath.plusConfigurations += configurations.compile + file { + // Manipulation of the classpath XML before merging local + // and generated copies + beforeMerged { classpath -> + // Remove all source entries to avoid overlap + classpath.entries.removeAll() { c -> + c.kind == 'src' + } + } -eclipse.jdt{ - sourceCompatibility = 1.6 - targetCompatibility = 1.6 -} + // only used to explode jni .so into aar + whenMerged { classpath -> + classpath.entries.findAll { entry -> + entry.path.contains('native-libs') }*.exported = false + } -eclipse.classpath { + // Direct manipulation of the generated classpath XML + withXml { + // Since non-default source directories are used + // they need to be manually added to the classpath XML + def node = it.asNode() + // Main source directory and generated code directory + node.appendNode('classpathentry kind="src" path="src"') + node.appendNode('classpathentry kind="src" path="gen"') - //customizing the classes output directory: - defaultOutputDir = file('bin/classes') - - file { - // Manipulation of the classpath XML before merging local - // and generated copies - beforeMerged { classpath -> - // Remove all source entries to avoid overlap - classpath.entries.removeAll() { c -> - c.kind == 'src' } } + } + jdt { + sourceCompatibility = 1.6 + targetCompatibility = 1.6 + } + project { + natures = ['com.android.ide.eclipse.adt.AndroidNature', + 'org.eclipse.jdt.core.javanature'] + buildCommand 'com.android.ide.eclipse.adt.ResourceManagerBuilder' + buildCommand 'com.android.ide.eclipse.adt.PreCompilerBuilder' + buildCommand 'com.android.ide.eclipse.adt.ApkBuilder' - // only used to explode jni .so into aar - whenMerged { classpath -> - classpath.entries.findAll { entry -> - entry.path.contains('native-libs') }*.exported = false - } - - // Direct manipulation of the generated classpath XML - withXml { - // Since non-default source directories are used - // they need to be manually added to the classpath XML - def node = it.asNode() - // Main source directory and generated code directory - node.appendNode('classpathentry kind="src" path="src"') - node.appendNode('classpathentry kind="src" path="gen"') - - } + // use extracted jni .so in eclipse + linkedResource name: 'libs', type: '2', + locationUri: 'PARENT-1-PROJECT_LOC/vtm-ext-libs/vtm-android' } } - -eclipse.project { - - natures = ['com.android.ide.eclipse.adt.AndroidNature', - 'org.eclipse.jdt.core.javanature'] - buildCommand 'com.android.ide.eclipse.adt.ResourceManagerBuilder' - buildCommand 'com.android.ide.eclipse.adt.PreCompilerBuilder' - buildCommand 'com.android.ide.eclipse.adt.ApkBuilder' - - // use extracted jni .so in eclipse - linkedResource name: 'libs', type: '2', - locationUri: 'PARENT-1-PROJECT_LOC/vtm-ext-libs/vtm-android' -} - diff --git a/vtm-ext-libs b/vtm-ext-libs index 416f8e79..a033354f 160000 --- a/vtm-ext-libs +++ b/vtm-ext-libs @@ -1 +1 @@ -Subproject commit 416f8e79e2128394575d3b302d5178cb56fd1d25 +Subproject commit a033354f0355e7d717547275ff3aebad46074e5b diff --git a/vtm-extras/build.gradle b/vtm-extras/build.gradle index 15b47d72..86171d21 100644 --- a/vtm-extras/build.gradle +++ b/vtm-extras/build.gradle @@ -2,15 +2,15 @@ apply plugin: 'java' apply plugin: 'maven' sourceSets { - main.java.srcDirs = ['src'] - main.resources.srcDirs = ['src'] + main.java.srcDirs = ['src'] + main.resources.srcDirs = ['src'] } dependencies { - compile project(':vtm') - compile 'com.google.protobuf:protobuf-java:2.4.1' - compile 'org.openstreetmap.osmosis:osmosis-osm-binary:0.43.1' - compile 'com.fasterxml.jackson.core:jackson-core:2.3.0' - compile 'com.vividsolutions:jts:1.13' + compile project(':vtm') + compile 'com.google.protobuf:protobuf-java:2.4.1' + compile 'org.openstreetmap.osmosis:osmosis-osm-binary:0.43.1' + compile 'com.fasterxml.jackson.core:jackson-core:2.3.0' + compile 'com.vividsolutions:jts:1.13' } diff --git a/vtm-gdx-android/build.gradle b/vtm-gdx-android/build.gradle index 018bafbc..b54995fb 100644 --- a/vtm-gdx-android/build.gradle +++ b/vtm-gdx-android/build.gradle @@ -8,7 +8,7 @@ buildscript { } repositories { - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } } apply plugin: 'android' @@ -16,15 +16,15 @@ apply plugin: 'android' dependencies { compile project(':vtm-gdx') compile project(':vtm-themes') - compile files('../vtm-ext-libs/gdx/gdx-backend-android.jar') + compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion" //natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi" //natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a" - //compile fileTree(dir: 'libs', include: '*.jar') + compile files("${rootDir}/vtm-ext-libs/native-libs.jar") } -// task copyAssets(type: Copy) { -// from "$rootDir/vtm/assets" -// into "assets" +// task copyLibs(type: Copy) { +// from "$rootDir/vtm-ext-libs/vtm-gdx-android" +// into "libs" // include '**/*' // } @@ -105,4 +105,3 @@ eclipse.project { locationUri: 'PARENT-1-PROJECT_LOC/vtm-ext-libs/vtm-gdx-android' } - diff --git a/vtm-gdx-html/build.gradle b/vtm-gdx-html/build.gradle index a4481965..d6f87369 100644 --- a/vtm-gdx-html/build.gradle +++ b/vtm-gdx-html/build.gradle @@ -2,9 +2,7 @@ buildscript { repositories { mavenLocal() mavenCentral() - maven { - url 'https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/' - } + maven { url 'https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/' } } dependencies { classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.3' @@ -12,7 +10,7 @@ buildscript { } repositories { - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } } apply plugin: 'war' @@ -22,33 +20,17 @@ apply plugin: 'eclipse' sourceSets { main.java.srcDirs = ['src', 'src/org/oscim/gdx/emu'] - //main.resources.srcDirs = ['src'] - //main.resources.srcDirs = ['resources'] - //output.resourcesDir = 'war' } - dependencies { providedCompile project(':vtm-gdx') providedCompile "com.badlogicgames.gdx:gdx:$gdxVersion:sources" providedCompile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources" providedCompile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion" - //providedCompile files('../vtm-ext-libs/gdx/gdx-sources.jar') - //providedCompile files('../vtm-ext-libs/gdx/gdx-backend-gwt-sources.jar') - //providedCompile files('../vtm-ext-libs/gdx/gdx-backend-gwt.jar') providedCompile 'ru.finam:slf4j-gwt:1.2.1' providedCompile 'org.slf4j:slf4j-api:1.7.5' } -// task copyAssets(type: Copy) { -// from "$rootDir/vtm/assets" -// into "$buildDir/gwt/draftOut/assets" -// include '**/*' -// } - -//compileGwt.dependsOn copyAssets -//draftCompileGwt.dependsOn copyAssets - gwt { gwtVersion='2.6.0' modules 'org.oscim.gdx.GwtDefinition' @@ -64,34 +46,22 @@ gwt { src += files(project(':vtm-gdx').sourceSets.main.allJava.srcDirs) } -// Configuring Eclipse classpath -eclipse.classpath { - //customizing the classes output directory: - defaultOutputDir = file('war/WEB-INF/classes') - - file { - - whenMerged { classpath -> - classpath.entries.findAll { entry -> - entry.path == 'src' }*.excludes = ['main','org/oscim/gdx/emu/'] - } - // Direct manipulation of the generated classpath XML - //withXml { - // Since non-default source directories are used - // they need to be manually added to the classpath XML - // def node = it.asNode() - //node.remove - // Main source directory - // node.appendNode('classpathentry excluding="main/|org/oscim/gdx/emu/" kind="src" path="src"') - // Generated code directory - //node.appendNode('classpathentry kind="src" path="gen"') - // } - } -} - - +// Run jetty with draft compiled war task jettyDraftWar(type: JettyRunWar) { dependsOn draftWar dependsOn.remove('war') webApp=draftWar.archivePath -} \ No newline at end of file +} + +// Configuring Eclipse classpath +eclipse.classpath { + + defaultOutputDir = file('war/WEB-INF/classes') + + file { + whenMerged { classpath -> + classpath.entries.findAll { entry -> + entry.path == 'src' }*.excludes = ['main','org/oscim/gdx/emu/'] + } + } +} diff --git a/vtm-gdx/build.gradle b/vtm-gdx/build.gradle index 7d8c22d5..b10f91f5 100644 --- a/vtm-gdx/build.gradle +++ b/vtm-gdx/build.gradle @@ -1,7 +1,5 @@ repositories { - mavenCentral() - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } - mavenLocal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } } apply plugin: 'java' @@ -16,5 +14,4 @@ dependencies { compile project(':vtm') compile project(':vtm-themes') compile "com.badlogicgames.gdx:gdx:$gdxVersion" - //compile files('../vtm-ext-libs/gdx/gdx.jar') } diff --git a/vtm/build.gradle b/vtm/build.gradle index fc977d56..e8f71e00 100644 --- a/vtm/build.gradle +++ b/vtm/build.gradle @@ -1,18 +1,25 @@ apply plugin: 'java' apply plugin: 'maven' +configurations { providedCompile } + dependencies { compile 'org.slf4j:slf4j-api:1.7.6' - compile 'com.google.code.findbugs:annotations:2.0.1' + providedCompile 'com.google.code.findbugs:annotations:2.0.1' } sourceSets { main.java.srcDirs = ['src'] + main.compileClasspath += configurations.providedCompile //main.resources.srcDirs = ['assets'] } //... there is probably a better way -eclipse.classpath.file.whenMerged { classpath -> - classpath.entries.findAll { entry -> - entry.path.contains('annotations') }*.exported = false -} +eclipse.classpath { + plusConfigurations += configurations.providedCompile + + file.whenMerged { classpath -> + classpath.entries.findAll { entry -> + entry.path.contains('annotations') }*.exported = false + } +} \ No newline at end of file