123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285 |
- import java.nio.file.Files;
- import java.nio.file.StandardCopyOption;
- buildscript {
- repositories {
- mavenCentral()
- google()
- maven {
- url "https://plugins.gradle.org/m2/"
- }
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:4.2.0'
- classpath 'me.tatarka:gradle-retrolambda:3.7.1'
- classpath "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.5.1"
- }
- }
- allprojects {
- repositories {
- mavenCentral()
- google()
- }
- tasks.withType(Jar) {
- duplicatesStrategy = 'include'
- }
- }
- // Set the license for IDEs that understand this
- ext.license = file("$rootDir/license.txt")
- apply plugin: 'base'
- apply plugin: 'com.github.spotbugs'
- apply from: file('version.gradle')
- apply plugin: 'me.tatarka.retrolambda'
- // This is applied to all sub projects
- subprojects {
- if(!project.name.equals('jme3-android-examples')) {
- apply from: rootProject.file('common.gradle')
- } else {
- apply from: rootProject.file('common-android-app.gradle')
- }
- if (!project.name.endsWith("-native") && enableSpotBugs != "false" ) {
- apply plugin: 'com.github.spotbugs'
- // Currently we only warn about issues and try to fix them as we go, but those aren't mission critical.
- spotbugs {
- ignoreFailures = true
- }
- tasks.withType(com.github.spotbugs.snom.SpotBugsTask ) {
- reports {
- html.enabled = !project.hasProperty("xml-reports")
- xml.enabled = project.hasProperty("xml-reports")
- }
- }
- }
- }
- task run(dependsOn: ':jme3-examples:run') {
- description = 'Run the jME3 examples'
- }
- defaultTasks 'run'
- task libDist(dependsOn: subprojects.build, description: 'Builds and copies the engine binaries, sources and javadoc to build/libDist') {
- doLast {
- File libFolder = mkdir("$buildDir/libDist/lib")
- File sourceFolder = mkdir("$buildDir/libDist/sources")
- File javadocFolder = mkdir("$buildDir/libDist/javadoc")
- subprojects.each {project ->
- if(!project.hasProperty('mainClassName')){
- project.tasks.withType(Jar).each {archiveTask ->
- if(archiveTask.classifier == "sources"){
- copy {
- from archiveTask.archivePath
- into sourceFolder
- rename {project.name + '-' + archiveTask.classifier +'.'+ archiveTask.extension}
- }
- } else if(archiveTask.classifier == "javadoc"){
- copy {
- from archiveTask.archivePath
- into javadocFolder
- rename {project.name + '-' + archiveTask.classifier +'.'+ archiveTask.extension}
- }
- } else{
- copy {
- from archiveTask.archivePath
- into libFolder
- rename {project.name + '.' + archiveTask.extension}
- }
- }
- }
- }
- }
- }
- }
- task createZipDistribution(type:Zip,dependsOn:["dist","libDist"], description:"Package the nightly zip distribution"){
- archiveFileName = provider {
- "jME" + jmeFullVersion + ".zip"
- }
- into("/") {
- from {"./dist"}
- }
- into("/sources") {
- from {"$buildDir/libDist/sources"}
- }
- }
- task copyLibs(type: Copy){
- // description 'Copies the engine dependencies to build/libDist'
- from {
- subprojects*.configurations*.compile*.copyRecursive({ !(it instanceof ProjectDependency); })*.resolve()
- }
- into "$buildDir/libDist/lib-ext" //buildDir.path + '/' + libsDirName + '/lib'
- }
- task dist(dependsOn: [':jme3-examples:dist', 'mergedJavadoc']){
- description 'Creates a jME3 examples distribution with all jme3 binaries, sources, javadoc and external libraries under ./dist'
- }
- task mergedJavadoc(type: Javadoc, description: 'Creates Javadoc from all the projects.') {
- title = 'jMonkeyEngine3'
- destinationDir = mkdir("dist/javadoc")
- options.encoding = 'UTF-8'
- // Allows Javadoc to be generated on Java 8 despite doclint errors.
- if (JavaVersion.current().isJava8Compatible()) {
- options.addStringOption('Xdoclint:none', '-quiet')
- }
- options.overview = file("javadoc-overview.html")
- // Note: The closures below are executed lazily.
- source subprojects.collect {project ->
- project.sourceSets.main.allJava // main only, exclude tests
- }
- classpath = files(subprojects.collect {project ->
- project.sourceSets*.compileClasspath})
- classpath.from {
- subprojects*.configurations*.compile*.copyRecursive({ !(it instanceof ProjectDependency); })*.resolve()
- }
- }
- clean.dependsOn('cleanMergedJavadoc')
- task cleanMergedJavadoc(type: Delete) {
- delete file('dist/javadoc')
- }
- task mergedSource(type: Copy){
- }
- ext {
- ndkCommandPath = ""
- ndkExists = false
- }
- task configureAndroidNDK {
- def ndkBuildFile = "ndk-build"
- // if windows, use ndk-build.cmd instead
- if (System.properties['os.name'].toLowerCase().contains('windows')) {
- ndkBuildFile = "ndk-build.cmd"
- }
- // ndkPath is defined in the root project gradle.properties file
- String ndkBuildPath = ndkPath + File.separator + ndkBuildFile
- //Use the environment variable for the NDK location if defined
- if (System.env.ANDROID_NDK != null) {
- ndkBuildPath = System.env.ANDROID_NDK + File.separator + ndkBuildFile
- }
- if (new File(ndkBuildPath).exists()) {
- ndkExists = true
- ndkCommandPath = ndkBuildPath
- }
- }
- gradle.rootProject.ext.set("usePrebuildNatives", buildNativeProjects!="true");
- if (skipPrebuildLibraries != "true" && buildNativeProjects != "true") {
- String rootPath = rootProject.projectDir.absolutePath
- Properties nativesSnapshotProp = new Properties()
- File nativesSnapshotPropF = new File("${rootPath}/natives-snapshot.properties");
- if (nativesSnapshotPropF.exists()) {
- nativesSnapshotPropF.withInputStream { nativesSnapshotProp.load(it) }
- String nativesSnapshot = nativesSnapshotProp.getProperty("natives.snapshot");
- String nativesUrl = PREBUILD_NATIVES_URL.replace('${natives.snapshot}', nativesSnapshot)
- println "Use natives snapshot: " + nativesUrl
- String nativesZipFile = "${rootPath}" + File.separator + "build" + File.separator + nativesSnapshot + "-natives.zip"
- String nativesPath = "${rootPath}" + File.separator + "build" + File.separator + "native"
- task getNativesZipFile {
- outputs.file nativesZipFile
- doFirst {
- File target = file(nativesZipFile);
- println("Download natives from " + nativesUrl + " to " + nativesZipFile);
- target.getParentFile().mkdirs();
- ant.get(src: nativesUrl, dest: target);
- }
- }
- task extractPrebuiltNatives {
- inputs.file nativesZipFile
- outputs.dir nativesPath
- dependsOn getNativesZipFile
- doFirst {
- for (File src : zipTree(nativesZipFile)) {
- String srcRel = src.getAbsolutePath().substring((int) (nativesZipFile.length() + 1));
- srcRel = srcRel.substring(srcRel.indexOf(File.separator) + 1);
- File dest = new File(nativesPath + File.separator + srcRel);
- boolean doCopy = !(dest.exists() && dest.lastModified() > src.lastModified())
- if (doCopy) {
- println("Copy " + src + " " + dest);
- dest.getParentFile().mkdirs();
- Files.copy(src.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING);
- }
- }
- }
- }
- assemble.dependsOn extractPrebuiltNatives
- }
- }
- //class IncrementalReverseTask extends DefaultTask {
- // @InputDirectory
- // def File inputDir
- //
- // @OutputDirectory
- // def File outputDir
- //
- // @Input
- // def inputProperty
- //
- // @TaskAction
- // void execute(IncrementalTaskInputs inputs) {
- // println inputs.incremental ? "CHANGED inputs considered out of date" : "ALL inputs considered out of date"
- // inputs.outOfDate { change ->
- // println "out of date: ${change.file.name}"
- // def targetFile = new File(outputDir, change.file.name)
- // targetFile.text = change.file.text.reverse()
- // }
- //
- // inputs.removed { change ->
- // println "removed: ${change.file.name}"
- // def targetFile = new File(outputDir, change.file.name)
- // targetFile.delete()
- // }
- // }
- //}
- //allprojects {
- // tasks.withType(JavaExec) {
- // enableAssertions = true // false by default
- // }
- // tasks.withType(Test) {
- // enableAssertions = true // true by default
- // }
- //}
- wrapper {
- gradleVersion = '6.9.1'
- }
- retrolambda {
- javaVersion JavaVersion.VERSION_1_7
- incremental true
- jvmArgs '-noverify'
- }
|