//ant.importBuild 'build.xml'
import groovy.xml.MarkupBuilder
import java.util.zip.ZipFile
if (!hasProperty('mainClass')) {
ext.mainClass = ''
}
configurations {
corelibs
optlibs
}
dependencies {
corelibs project(':jme3-blender')
corelibs project(':jme3-core')
corelibs project(':jme3-desktop')
corelibs project(':jme3-effects')
corelibs project(':jme3-jbullet')
corelibs project(':jme3-jogg')
corelibs project(':jme3-lwjgl')
corelibs project(':jme3-networking')
corelibs project(':jme3-niftygui')
corelibs project(':jme3-plugins')
corelibs project(':jme3-terrain')
testdatalibs project(':jme3-testdata')
optlibs project(':jme3-bullet')
optlibs project(':jme3-jogl')
}
//task copyToLib << {
// configurations.opt.resolvedConfiguration.resolvedArtifacts.each { artifact ->
// copy {
// from artifact.file
// into '../dist/opt'
// if(artifact.classifier != null){
// rename { "${artifact.name}-${artifact.classifier}.${artifact.extension}" }
// } else{
// rename { "${artifact.name}.${artifact.extension}" }
// }
// }
// }
//}
//build.dependsOn copyToLib
artifacts {
// jar null
}
//
//
//
//
//
//configurations {
// antlibs
//}
//dependencies {
// antlibs filetree(dir: 'ant-lib', include: '*.jar')
//}
//
//ant.taskdef(resource: 'net/sf/antcontrib/antcontrib.properties', classpath: configurations.antlibs.asPath)
//ant.taskdef(name: 'deb', classname: 'com.googlecode.ant_deb_task.Deb', classpath: configurations.antlibs.asPath)
//ant.taskdef(name: 'gcupload', classname: 'net.bluecow.googlecode.ant.GoogleCodeUploadTask', classpath: configurations.antlibs.asPath)
//ant.taskdef(name: 'desktopentry', classname: 'com.googlecode.ant_deb_task.DesktopEntry', classpath: configurations.antlibs.asPath)
//ant.importBuild 'build.xml'
ant.properties['plugins.version'] = jmeVersion
ant.properties['app.version']= jmeMainVersion + jmeVersionSuffix
//ant.properties.buildDir = buildDir
//ant.properties['buildDir'] = buildDir
//ant.property(name: 'buildDir', location: buildDir)
//ant.taskdef(resource: 'checkstyletask.properties') {
// classpath {
// fileset(dir: 'ant-lib', includes: '*.jar')
// }
//}
//ant.checkstyle(config: 'checkstyle.xml') {
// fileset(dir: 'src')
//}
//task copyFiles(type: Copy) {
// from 'src/files'
// into "$buildDir/files"
// rename '(.*)-(.*).html', '$2/$1.html'
// rename ~/(.*).template.(.*)/, '$1.$2'
// rename { filename ->
// filename.replace 'java', 'groovy'
// }
//}
//task copyTaskWithPatterns(type: Copy) {
// from 'src/main/webapp'
// into 'build/explodedWar'
// include '**/*.html'
// include '**/*.jsp'
// exclude { details -> details.file.name.endsWith('.html') && details.file.text.contains('staging') }
//}
task copyBaseLibs{
description "Copies the library files needed to run the SDK to "+
"jme3-core-baselibs and jme3-core-libraries"
dependsOn configurations.corelibs
dependsOn configurations.optlibs
// for each dependency in corelibs..
project.configurations.corelibs.dependencies.each {dep ->
// copy built jme3 jar files to jme3-core-baselibs
dep.dependencyProject.configurations.archives.allArtifacts.each{ artifact->
if(artifact.classifier == "sources"){
} else if(artifact.classifier == "javadoc"){
} else{
copy {
from artifact.file
into "jme3-core-baselibs/release/modules/ext/"
}
}
}
// copy external jar files to jme3-core-libraries
copy {
from dep.dependencyProject.configurations.compile.copyRecursive({ !(it instanceof ProjectDependency); }).resolve()
into "jme3-core-libraries/release/modules/ext/"
}
}
}
task createBaseXml{
description "Creates the project.xml files for "+
"jme3-core-baselibs and jme3-core-libraries"
def depJars = [] // jme3 jar files
def depExtJars = [] // external jar files
// collect jar files
project.configurations.corelibs.dependencies.each {dep ->
// collect external jar files
dep.dependencyProject.configurations.compile.copyRecursive({ !(it instanceof ProjectDependency); }).resolve().each{ file->
depExtJars.add(file)
}
// collect internal jar files (classes, sources and javadoc)
dep.dependencyProject.configurations.archives.allArtifacts.each{ artifact->
if(artifact.classifier == "sources"){
} else if(artifact.classifier == "javadoc"){
} else{
if(!depJars.contains(artifact.file)){
depJars.add(artifact.file)
}
}
}
}
// collect base packages
def packages = []
depJars.each{jarFile ->
ZipFile file = new ZipFile(jarFile)
file.entries().each { entry ->
if(entry.name.endsWith('.class')){
// TODO: "/" works on windows?
def pathPart = entry.name.substring(0,entry.name.lastIndexOf('/'))
def classPath = pathPart.replace('/','.');
if(!packages.contains(classPath)){
packages.add(classPath)
}
}
}
}
// collect library packages
def extPackages = []
depExtJars.each{jarFile ->
ZipFile file = new ZipFile(jarFile)
file.entries().each { entry ->
if(entry.name.endsWith('.class')){
// TODO: "/" works on windows?
def pathPart = entry.name.substring(0,entry.name.lastIndexOf('/'))
def classPath = pathPart.replace('/','.');
if(!extPackages.contains(classPath)){
extPackages.add(classPath)
}
}
}
}
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
xml.xmlDeclaration(version:'1.0')
xml.project(xmlns:"http://www.netbeans.org/ns/project/1"){
type "org.netbeans.modules.apisupport.project"
configuration {
data(xmlns:"http://www.netbeans.org/ns/nb-module-project/3") {
"code-name-base" "com.jme3.gde.core.baselibs"
"suite-component"{}
"module-dependencies"{
dependency{
"code-name-base" "com.jme3.gde.core.libraries"
"build-prerequisite"{}
"compile-dependency"{}
"run-dependency"{
"release-version" "1"
"specification-version" "3.0.0"
}
}
}
"public-packages"{
packages.each{
"package" it
}
}
depJars.each{jarFile ->
"class-path-extension"{
"runtime-relative-path" "ext/${jarFile.name}"
"binary-origin" "release/modules/ext/${jarFile.name}"
}
}
}
}
}
// write XML file
File baselibsProjectFile = file("jme3-core-baselibs/nbproject/project.xml");
baselibsProjectFile.write(writer.toString())
def extWriter = new StringWriter()
def extXml = new MarkupBuilder(extWriter)
extXml.xmlDeclaration(version:'1.0')
extXml.project(xmlns:"http://www.netbeans.org/ns/project/1"){
type "org.netbeans.modules.apisupport.project"
configuration {
data(xmlns:"http://www.netbeans.org/ns/nb-module-project/3") {
"code-name-base" "com.jme3.gde.core.libraries"
"suite-component"{}
"module-dependencies"{}
"public-packages"{
extPackages.each{
"package" it
}
}
depExtJars.each{jarFile ->
"class-path-extension"{
"runtime-relative-path" "ext/${jarFile.name}"
"binary-origin" "release/modules/ext/${jarFile.name}"
}
}
}
}
}
// write XML file
File librariesProjectFile = file("jme3-core-libraries/nbproject/project.xml");
librariesProjectFile.write(extWriter.toString())
}
// workaround method to add a tag with the name "name" and "file" to an XML MarkupBuilder
def makeName(builder, nameR) { builder.name nameR }
def makeFile(builder, nameR) { builder.file(name:nameR, url:nameR) }
task createProjectXml{
description "Creates needed J2SE library and layer XML files in jme3-project-baselibs"
def eol = System.properties.'line.separator'
def j2seLibraries = [] // created J2SE library descriptors
// for each dependency in corelibs..
project.configurations.corelibs.dependencies.each {dep ->
def depJars = [] // jme3 jar files
def depSources = [] // jme3 sources
def depJavadocs = [] // jme3 javadoc
def depExtJars = [] // external jar files
j2seLibraries.add(dep.dependencyProject.name+".xml")
// collect external jar files
dep.dependencyProject.configurations.compile.copyRecursive({ !(it instanceof ProjectDependency); }).resolve().each{ file->
depExtJars.add(file.name)
}
// collect internal jar files (classes, sources and javadoc)
dep.dependencyProject.configurations.archives.allArtifacts.each{ artifact->
if(artifact.classifier == "sources"){
depSources.add(artifact.file.name)
} else if(artifact.classifier == "javadoc"){
depJavadocs.add(artifact.file.name)
} else{
if(!depJars.contains(artifact.file.name)){
depJars.add(artifact.file.name)
}
}
}
// create J2SE library descriptor xml file
def libraryWriter = new StringWriter()
def libraryXml = new MarkupBuilder(libraryWriter)
// xml.xmlDeclaration(version:'1.0')
libraryWriter << '' << eol
libraryWriter << '' << eol
libraryXml.library(version:"1.0", encoding: "UTF-8"){
makeName(libraryXml, "${dep.dependencyProject.name}.xml")
type "j2se"
"localizing-bundle" "com.jme3.gde.project.baselibs.Bundle"
volume{
type "classpath"
depJars.each{jar ->
resource "jar:nbinst://com.jme3.gde.project.baselibs/libs/${jar}!/"
}
depExtJars.each{jar ->
resource "jar:nbinst://com.jme3.gde.project.libraries/libs/${jar}!/"
}
}
volume{
type "src"
depSources.each{jar ->
resource "jar:nbinst://com.jme3.gde.project.baselibs/libs/${jar}!/"
}
}
volume{
type "javadoc"
depJavadocs.each{jar ->
resource "jar:nbinst://com.jme3.gde.project.baselibs/libs/${jar}!/"
}
}
}
// write XML file
File libraryXmlFile = file("jme3-project-baselibs/src/com/jme3/gde/project/baselibs/${dep.dependencyProject.name}.xml");
libraryXmlFile.write(libraryWriter.toString())
}
// create layer.xml file with entries of library xml files
def layerWriter = new StringWriter()
def layerXml = new MarkupBuilder(layerWriter)
// layerXml.xmlDeclaration(version:'1.0')
layerWriter << '' << eol
layerWriter << '' << eol
layerXml.filesystem{
folder(name:"org-netbeans-api-project-libraries"){
folder(name:"Libraries"){
j2seLibraries.each{lib ->
makeFile(layerXml, lib)
}
}
}
}
File layerXmlFile = file("jme3-project-baselibs/src/com/jme3/gde/project/baselibs/layer.xml");
layerXmlFile.write(layerWriter.toString())
}
task copyProjectLibs{
description "Copies the jar files needed to supply the J2SE Libraries in the "+
"SDK to jme3-project-baselibs and jme3-project-libraries"
dependsOn configurations.corelibs
dependsOn configurations.optlibs
// for each dependency in corelibs..
project.configurations.corelibs.dependencies.each {dep ->
// copy jme3 jar files, sources and javadocs to jme3-project-baselibs
dep.dependencyProject.configurations.archives.allArtifacts.each{ artifact->
if(artifact.classifier == "sources"){
copy {
from artifact.file
into "jme3-project-baselibs/release/libs/"
}
} else if(artifact.classifier == "javadoc"){
copy {
from artifact.file
into "jme3-project-baselibs/release/libs/"
}
} else{
copy {
from artifact.file
into "jme3-project-baselibs/release/libs/"
}
}
}
// copy external jar files to jme3-project-libraries
copy {
from dep.dependencyProject.configurations.compile.copyRecursive({ !(it instanceof ProjectDependency); }).resolve()
into "jme3-project-libraries/release/libs/"
}
}
}
task buildSdk(){
// ant.ant(dir: ".", antfile: "build.xml", target: "hudson-stable")
}
task cleanSdk(){
// ant.ant(dir: ".", antfile: "build.xml", target: "clean")
}
jar.dependsOn([copyBaseLibs, copyProjectLibs, createProjectXml, createBaseXml, buildSdk])
clean.dependsOn(cleanSdk);
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
// Clearing old files
//
//
//
//
//
//
//
// Copying jMonkeyPlatform jME3 libs
//
//
//
//
//
//
// Copying jMonkeyPlatform external libraries
//
//
//
//
// Copying Project jME3 libs
//
//
//
//
//
// Copying Project external libraries
//
//
//
//
//
//
// Copying Test Project Data
//
//
//
//
// Copying Javadoc
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
// Copying Test Examples
//
//
//
//
//
//
//
//
//
//
//