Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 74 additions & 63 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;

buildscript {
repositories {
mavenCentral()
google()
maven {
url "https://plugins.gradle.org/m2/"
url = "https://plugins.gradle.org/m2/"
}
}
dependencies {
Expand All @@ -15,6 +12,14 @@ buildscript {
}
}

import org.gradle.api.file.RelativePath

// Set the license for IDEs that understand this
ext.license = file("$rootDir/source-file-header-template.txt")

apply plugin: 'base'
apply from: file('version.gradle')

allprojects {
repositories {
mavenCentral()
Expand All @@ -25,13 +30,6 @@ allprojects {
}
}

// Set the license for IDEs that understand this
ext.license = file("$rootDir/source-file-header-template.txt")

apply plugin: 'base'
apply plugin: 'com.github.spotbugs'
apply from: file('version.gradle')

// This is applied to all sub projects
subprojects {
if(!project.name.equals('jme3-android-examples')) {
Expand All @@ -58,13 +56,17 @@ subprojects {
}
}

task run(dependsOn: ':jme3-examples:run') {
tasks.register('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') {
def libDist = tasks.register('libDist') {
dependsOn(subprojects.collect { it.tasks.named('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")
Expand All @@ -74,21 +76,22 @@ task libDist(dependsOn: subprojects.build, description: 'Builds and copies the e
project.tasks.withType(Jar).each {archiveTask ->
String classifier = archiveTask.archiveClassifier.get()
String ext = archiveTask.archiveExtension.get()
File archiveFile = archiveTask.archiveFile.get().asFile
if (classifier == "sources") {
copy {
from archiveTask.archivePath
from archiveFile
into sourceFolder
rename {project.name + '-' + classifier + '.' + ext}
}
} else if (classifier == "javadoc") {
copy {
from archiveTask.archivePath
from archiveFile
into javadocFolder
rename {project.name + '-' + classifier + '.' + ext}
}
} else{
copy {
from archiveTask.archivePath
from archiveFile
into libFolder
rename {project.name + '.' + ext}
}
Expand All @@ -99,7 +102,9 @@ task libDist(dependsOn: subprojects.build, description: 'Builds and copies the e
}
}

task createZipDistribution(type:Zip,dependsOn:["dist","libDist"], description:"Package the nightly zip distribution"){
tasks.register('createZipDistribution', Zip) {
dependsOn(tasks.named('dist'), libDist)
description = 'Package the nightly zip distribution'
archiveFileName = provider {
"jME" + jmeFullVersion + ".zip"
}
Expand All @@ -111,7 +116,7 @@ task createZipDistribution(type:Zip,dependsOn:["dist","libDist"], description:"P
}
}

task copyLibs(type: Copy){
tasks.register('copyLibs', Copy) {
// description 'Copies the engine dependencies to build/libDist'
from {
subprojects*.configurations*.implementation*.copyRecursive({ !(it instanceof ProjectDependency); })*.resolve()
Expand All @@ -120,8 +125,9 @@ task copyLibs(type: Copy){
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'
tasks.register('dist') {
dependsOn ':jme3-examples:dist', tasks.named('mergedJavadoc')
description = 'Creates a jME3 examples distribution with all jme3 binaries, sources, javadoc and external libraries under ./dist'
}

def mergedJavadocSubprojects = [
Expand All @@ -139,13 +145,12 @@ def mergedJavadocSubprojects = [
":jme3-plugins",
":jme3-terrain",
]
task mergedJavadoc(type: Javadoc, description: 'Creates Javadoc from all the projects.') {
tasks.register('mergedJavadoc', Javadoc) {
description = 'Creates Javadoc from all the projects.'
title = 'jMonkeyEngine3'
destinationDir = mkdir("dist/javadoc")
destinationDir = file("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')
}
Expand All @@ -155,13 +160,12 @@ task mergedJavadoc(type: Javadoc, description: 'Creates Javadoc from all the pro
classpath = files(mergedJavadocSubprojects.collect { project(it).sourceSets.main.compileClasspath })
}

clean.dependsOn('cleanMergedJavadoc')
task cleanMergedJavadoc(type: Delete) {
def cleanMergedJavadoc = tasks.register('cleanMergedJavadoc', Delete) {
delete file('dist/javadoc')
}

task mergedSource(type: Copy){

tasks.named('clean') {
dependsOn cleanMergedJavadoc
}

ext {
Expand Down Expand Up @@ -192,54 +196,61 @@ task configureAndroidNDK {
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");
File nativesSnapshotPropF = file('natives-snapshot.properties')

if (nativesSnapshotPropF.exists()) {
def readNativesConfig = {
Properties nativesSnapshotProp = new Properties()
nativesSnapshotPropF.withInputStream { nativesSnapshotProp.load(it) }

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 nativesSnapshot = nativesSnapshotProp.getProperty("natives.snapshot")
if (!nativesSnapshot) {
throw new GradleException("Missing 'natives.snapshot' in ${nativesSnapshotPropF}")
}

String nativesZipFile = "${rootPath}" + File.separator + "build" + File.separator + nativesSnapshot + "-natives.zip"
String nativesPath = "${rootPath}" + File.separator + "build" + File.separator + "native"
[
snapshot: nativesSnapshot,
url: PREBUILD_NATIVES_URL.replace('${natives.snapshot}', nativesSnapshot),
zipFile: layout.buildDirectory.file("${nativesSnapshot}-natives.zip"),
nativeDir: layout.buildDirectory.dir("native"),
]
}

def nativesZipFile = providers.provider { readNativesConfig().zipFile.get().asFile }
def nativesPath = layout.buildDirectory.dir("native")

task getNativesZipFile {
outputs.file nativesZipFile
def getNativesZipFile = tasks.register('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);
def nativesConfig = readNativesConfig()
File target = nativesConfig.zipFile.get().asFile
println("Use natives snapshot: ${nativesConfig.url}")
println("Download natives from ${nativesConfig.url} to ${target}")
target.getParentFile().mkdirs()
ant.get(src: nativesConfig.url, 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);
def extractPrebuiltNatives = tasks.register('extractPrebuiltNatives', Sync) {
dependsOn(getNativesZipFile)
into(nativesPath)
from({
zipTree(readNativesConfig().zipFile.get().asFile)
}) {
eachFile { details ->
def segments = details.relativePath.segments
if (segments.length <= 1) {
details.exclude()
} else {
details.relativePath = new RelativePath(details.isDirectory(), segments[1..-1] as String[])
}
}
includeEmptyDirs = false
}
}

assemble.dependsOn extractPrebuiltNatives
tasks.named('assemble') {
dependsOn extractPrebuiltNatives
}
}
}
}
11 changes: 7 additions & 4 deletions common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ javadoc {
options.use = "true"
options.charSet = "UTF-8"
options.encoding = "UTF-8"
if (JavaVersion.current().isJava8Compatible()) {
options.addStringOption('Xdoclint:none', '-quiet')
}
source = sourceSets.main.allJava // main only, exclude tests
}

Expand Down Expand Up @@ -154,7 +157,7 @@ publishing {
}
url = POM_URL
}
version project.version
version = project.version
}
}

Expand Down Expand Up @@ -209,8 +212,8 @@ tasks.withType(Sign) {
}

checkstyle {
toolVersion libs.versions.checkstyle.get()
configFile file("${gradle.rootProject.rootDir}/config/checkstyle/checkstyle.xml")
toolVersion = libs.versions.checkstyle.get()
configFile = file("${gradle.rootProject.rootDir}/config/checkstyle/checkstyle.xml")
}

checkstyleMain {
Expand All @@ -227,4 +230,4 @@ tasks.withType(Checkstyle) {
html.required.set(true)
}
include("**/com/jme3/renderer/**/*.java")
}
}
4 changes: 1 addition & 3 deletions jme3-android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
apply plugin: 'java'

dependencies {
//added annotations used by JmeSurfaceView.
compileOnly libs.androidx.annotation
compileOnly libs.androidx.lifecycle.common
api project(':jme3-core')
compileOnly 'android:android'
compileOnly files(rootProject.file('lib/android.jar'))
}

compileJava {
Expand Down
13 changes: 8 additions & 5 deletions jme3-examples/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
ext.mainClassName = 'jme3test.TestChooser'

def androidProject = project(':jme3-android')
def androidNativeProject = project(':jme3-android-native')

task run(dependsOn: 'build', type:JavaExec) {
mainClass = mainClassName
classpath = sourceSets.main.runtimeClasspath
Expand Down Expand Up @@ -69,21 +72,21 @@ task dist (dependsOn: ['build', ':jme3-android:jar', ':jme3-android-native:jar']
}
}
copy {
from jar.archivePath
from tasks.named('jar').flatMap { it.archiveFile }
into '../dist'
rename { "jMonkeyEngine3.jar" }
}

// Copy android packages, remove version
copy {
from project(':jme3-android').jar.archivePath
from androidProject.tasks.named('jar').flatMap { it.archiveFile }
into '../dist/opt/android'
rename {project(':jme3-android').name+".jar"}
rename { androidProject.name + ".jar" }
}
copy {
from project(':jme3-android-native').jar.archivePath
from androidNativeProject.tasks.named('jar').flatMap { it.archiveFile }
into '../dist/opt/android'
rename {project(':jme3-android-native').name+".jar"}
rename { androidNativeProject.name + ".jar" }
}
}
}
18 changes: 10 additions & 8 deletions jme3-ios-native/build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
import org.apache.tools.ant.taskdefs.condition.Os

task deleteXcframework(type: Delete) {
def deleteXcframework = tasks.register('deleteXcframework', Delete) {
delete 'template/META-INF/robovm/ios/libs/jme3-ios-native.xcframework'
}

task buildNativeLibIos(type: Exec) {
def buildNativeLibIos = tasks.register('buildNativeLibIos', Exec) {
executable "xcodebuild"
args 'archive', '-project', 'jme3-ios-native.xcodeproj', '-scheme', 'jme3-ios-native', '-configuration', 'release', '-destination', 'generic/platform=iOS', '-archivePath', 'build/archives/jme3-ios-native_iOS', 'SKIP_INSTALL=NO', 'BUILD_LIBRARY_FOR_DISTRIBUTION=YES'
}

task buildNativeLibSimulator(type: Exec) {
def buildNativeLibSimulator = tasks.register('buildNativeLibSimulator', Exec) {
executable "xcodebuild"
args 'archive', '-project', 'jme3-ios-native.xcodeproj', '-scheme', 'jme3-ios-native', '-configuration', 'release', '-destination', 'generic/platform=iOS Simulator', '-archivePath', 'build/archives/jme3-ios-native_iOS-Simulator', 'SKIP_INSTALL=NO', 'BUILD_LIBRARY_FOR_DISTRIBUTION=YES'
}

task buildNativeLib(type: Exec) {
dependsOn 'deleteXcframework'
dependsOn 'buildNativeLibIos'
dependsOn 'buildNativeLibSimulator'
def buildNativeLib = tasks.register('buildNativeLib', Exec) {
dependsOn deleteXcframework
dependsOn buildNativeLibIos
dependsOn buildNativeLibSimulator
executable "xcodebuild"
args '-create-xcframework', '-framework', 'build/archives/jme3-ios-native_iOS.xcarchive/Products/Library/Frameworks/jme3_ios_native.framework', '-framework', 'build/archives/jme3-ios-native_iOS-Simulator.xcarchive/Products/Library/Frameworks/jme3_ios_native.framework', '-output', 'template/META-INF/robovm/ios/libs/jme3-ios-native.xcframework'
}

// buildNativeProjects is a string set to "true"
if (Os.isFamily(Os.FAMILY_MAC) && buildNativeProjects == "true") {
// build native libs and update stored pre-compiled libs to commit
compileJava.dependsOn { buildNativeLib }
tasks.named('compileJava') {
dependsOn buildNativeLib
}
} else {
// TODO: (like android natives?) use pre-compiled native libs (not building new ones)
// compileJava.dependsOn { copyPreCompiledLibs }
Expand Down
Loading
Loading