diff --git a/core/build.gradle b/core/build.gradle index 3bbae4b1..1e6ee872 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,46 +1,14 @@ +import org.apache.tools.ant.Project import java.nio.file.Files -import static java.nio.file.StandardCopyOption.REPLACE_EXISTING +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; apply plugin: 'aar' -apply plugin: 'maven' +apply plugin: 'maven-publish' dependencies { implementation name: "android" - implementationAar "androidx.legacy:legacy-support-v4:${v4legacyVersion}" - implementationAar "com.google.android.support:wearable:${wearVersion}" -} - -task createPom { - pom { - project { - groupId "org.p5android" - artifactId "processing-core" - version "${modeVersion}" - packaging "jar" - licenses { - license { - name "GNU Lesser General Public License, version 2.1" - url "https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt" - distribution "repo" - } - } - dependencies { - dependency { - groupId "androidx.legacy" - artifactId "legacy-support-v4" - version "${v4legacyVersion}" - scope "implementation" - } - dependency { - groupId "com.google.android.support" - artifactId "wearable" - version "${wearVersion}" - scope "implementation" - } - } - } - }.writeTo("dist/processing-core-${modeVersion}.pom") + implementationAar "com.google.android.support:wearable:${wearVersion}" } sourceSets { @@ -59,6 +27,51 @@ task sourcesJar(type: Jar, dependsOn: classes) { from sourceSets.main.allSource } +publishing { + publications { + corePublication(MavenPublication) { + from components.java + artifact sourcesJar + pom { + groupId = "org.p5android" + artifactId = "processing-core" + version = "${modeVersion}" + packaging = "jar" + // description = "Processing Android Core" + // url = "http://www.example.com/project" + licenses { + license { + name = "GNU Lesser General Public License, version 2.1" + url = "https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt" + distribution = "repo" + } + } + } + pom.withXml { // Only one dependency is added under dependancies node + asNode().remove(asNode().get("dependencies")) // removing dependencies node + // inserting the dependencies node + def dependenciesNode = asNode().appendNode('dependencies') + // start adding dependency nodes inside dependencies node + def androidLegacyDependancyNode = dependenciesNode.appendNode('dependency') + androidLegacyDependancyNode.appendNode('groupId', 'androidx.legacy') + androidLegacyDependancyNode.appendNode('artifactId', 'legacy-support-v4') + androidLegacyDependancyNode.appendNode('version', "${v4legacyVersion}") + androidLegacyDependancyNode.appendNode('scope', 'implementation') + + def wearableDependencyNode = dependenciesNode.appendNode('dependency') + wearableDependencyNode.appendNode('groupId', 'com.google.android.support') + wearableDependencyNode.appendNode('artifactId', 'wearable') + wearableDependencyNode.appendNode('version', "${wearVersion}") + wearableDependencyNode.appendNode('scope', 'implementation') + + def androidRuntimeDependencyNode = dependenciesNode.appendNode('dependency') + androidRuntimeDependencyNode.appendNode('artifactId', 'android') + androidRuntimeDependencyNode.appendNode('scope', 'runtime') + } + } + } +} + // Does not work because of Processing-specific tags in source code, such as @webref task javadocJar(type: Jar, dependsOn: javadoc) { classifier = "javadoc" @@ -80,25 +93,38 @@ clean.doFirst { } compileJava.doFirst { - String[] deps = ["wearable.jar"] + String[] deps = ["wearable.jar"] for (String fn : deps) { Files.copy(file("${rootDir}/build/libs/" + fn).toPath(), - file("${rootDir}/mode/mode/" + fn).toPath(), REPLACE_EXISTING) + file("${rootDir}/mode/mode/" + fn).toPath(), REPLACE_EXISTING) } } build.doLast { - // Copying core jar as zip inside the mode folder + // If xml doesn't exist + def pomfile = file("${buildDir}/publications/corePublication/pom-default.xml") + if (!pomfile.exists()) { + println("***************************************************************************************\n" + + "* *\n" + + "* File not found: root/core/build/publications/corePublication/pom-default.xml *\n" + + "* First execute the following command to generate the file: *\n" + + "* gradle generatePomFileForcorePublicationPublication *\n" + + "* *\n" + + "***************************************************************************************" + ) + } + // // Copying core jar as zip inside the mode folder Files.copy(file("${buildDir}/libs/core.jar").toPath(), - file("${coreZipPath}").toPath(), REPLACE_EXISTING) - - // Copying the files for release on JCentral + file("${coreZipPath}").toPath(), REPLACE_EXISTING) + // // Copying the files for release on JCentral File distFolder = file("dist") distFolder.mkdirs() Files.copy(file("${buildDir}/libs/core.jar").toPath(), - file("dist/processing-core-${modeVersion}.jar").toPath(), REPLACE_EXISTING) + file("dist/processing-core-${modeVersion}.jar").toPath(), REPLACE_EXISTING) Files.copy(file("${buildDir}/libs/core-sources.jar").toPath(), - file("dist/processing-core-${modeVersion}-sources.jar").toPath(), REPLACE_EXISTING) + file("dist/processing-core-${modeVersion}-sources.jar").toPath(), REPLACE_EXISTING) Files.copy(file("${buildDir}/libs/core.jar.MD5").toPath(), - file("dist/processing-core-${modeVersion}.jar.md5").toPath(), REPLACE_EXISTING) -} \ No newline at end of file + file("dist/processing-core-${modeVersion}.jar.md5").toPath(), REPLACE_EXISTING) + Files.copy(file("${buildDir}/publications/corePublication/pom-default.xml").toPath(), + file("dist/processing-core-${modeVersion}.pom").toPath(), REPLACE_EXISTING) +} diff --git a/mode/libraries/ar/build.gradle b/mode/libraries/ar/build.gradle index 9616907c..6bb5b9c0 100644 --- a/mode/libraries/ar/build.gradle +++ b/mode/libraries/ar/build.gradle @@ -2,47 +2,58 @@ import java.nio.file.Files import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; apply plugin: 'aar' -apply plugin: 'maven' +apply plugin: 'maven-publish' dependencies { compileOnly name: "android" - compileOnly "org.p5android:processing-core:${modeVersion}" - implementationAar "com.google.ar:core:${garVersion}" } -task createPom { - pom { - project { - groupId "org.p5android" - artifactId "processing-ar" - version "${arLibVersion}" - packaging "jar" - licenses { - license { - name "GNU Lesser General Public License, version 2.1" - url "https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt" - distribution "repo" - } - } - dependencies { - dependency { - groupId "org.p5android" - artifactId "processing-core" - version "${modeVersion}" - scope "implementation" - } +task sourceJar(type: Jar) { + from sourceSets.main.allJava + archiveClassifier = "sources" +} + +publishing { + publications { + arPublication(MavenPublication) { + from components.java + artifact sourceJar + pom { + groupId = "org.p5android" + artifactId = "processing-ar" + version = "${arLibVersion}" + packaging = "jar" + // description = "Processing Android Core" + // url = "http://www.example.com/project" + licenses { + license { + name = "GNU Lesser General Public License, version 2.1" + url = "https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt" + distribution = "repo" + } + } + } + + pom.withXml { + // inserting the dependencies node + def dependenciesNode = asNode().appendNode('dependencies') + // start adding dependency nodes inside dependencies node + def processingCoreDependencyNode = dependenciesNode.appendNode('dependency') + processingCoreDependencyNode.appendNode('groupId', 'org.p5android') + processingCoreDependencyNode.appendNode('artifactId', 'processing-core') + processingCoreDependencyNode.appendNode('version', "${modeVersion}") + processingCoreDependencyNode.appendNode('scope', 'implementation') - dependency { - groupId "com.google.ar" - artifactId "core" - version "${garVersion}" - scope "implementation" - } - } + def googleARDependencyNode = dependenciesNode.appendNode('dependency') + googleARDependencyNode.appendNode('groupId', 'com.google.ar') + googleARDependencyNode.appendNode('artifactId', 'core') + googleARDependencyNode.appendNode('version', "${garVersion}") + googleARDependencyNode.appendNode('scope', 'implementation') + } } - }.writeTo("dist/processing-ar-${arLibVersion}.pom") + } } sourceSets { @@ -56,11 +67,6 @@ sourceSets { } } -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = "sources" - from sourceSets.main.allSource -} - // Does not work because of Processing-specific tags in source code, such as @webref task javadocJar(type: Jar, dependsOn: javadoc) { classifier = "javadoc" @@ -69,7 +75,7 @@ task javadocJar(type: Jar, dependsOn: javadoc) { artifacts { // archives javadocJar - archives sourcesJar + archives sourceJar } jar.doLast { task -> @@ -92,13 +98,24 @@ compileJava.doFirst { } build.doLast { + // If xml doesn't exist + def pomfile = file("${buildDir}/publications/arPublication/pom-default.xml") + if (!pomfile.exists()) { + println("**********************************************************************************************\n" + + "* *\n" + + "* File not found: root/mode/libraries/ar/build/publications/arPublication/pom-default.xml *\n" + + "* First execute the following command to generate the file: *\n" + + "* gradle generatePomFileForarPublicationPublication *\n" + + "* *\n" + + "**********************************************************************************************" + ) + } // Copying ar jar to library folder File arJar = file("library/ar.jar") arJar.mkdirs(); Files.copy(file("$buildDir/libs/ar.jar").toPath(), - arJar.toPath(), REPLACE_EXISTING); - - // // Copying the files for release on JCentral + arJar.toPath(), REPLACE_EXISTING); + // Copying the files for release on JCentral File distFolder = file("dist"); distFolder.mkdirs(); Files.copy(file("$buildDir/libs/ar.jar").toPath(), @@ -107,4 +124,6 @@ build.doLast { file("dist/processing-ar-${arLibVersion}-sources.jar").toPath(), REPLACE_EXISTING); Files.copy(file("$buildDir/libs/ar.jar.MD5").toPath(), file("dist/processing-ar-${arLibVersion}.jar.md5").toPath(), REPLACE_EXISTING); -} \ No newline at end of file + Files.copy(file("${buildDir}/publications/arPublication/pom-default.xml").toPath(), + file("dist/processing-ar-${arLibVersion}.pom").toPath(), REPLACE_EXISTING) +} diff --git a/mode/libraries/vr/build.gradle b/mode/libraries/vr/build.gradle index c086225c..9204ea64 100644 --- a/mode/libraries/vr/build.gradle +++ b/mode/libraries/vr/build.gradle @@ -1,8 +1,8 @@ import java.nio.file.Files -import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING apply plugin: 'aar' -apply plugin: 'maven' +apply plugin: 'maven-publish' dependencies { compileOnly name: "android" @@ -13,43 +13,54 @@ dependencies { implementationAar "com.google.vr:sdk-base:${gvrVersion}" } -task createPom { - pom { - project { - groupId "org.p5android" - artifactId "processing-vr" - version "${vrLibVersion}" - packaging "jar" - licenses { - license { - name "GNU Lesser General Public License, version 2.1" - url "https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt" - distribution "repo" - } - } - dependencies { - dependency { - groupId "org.p5android" - artifactId "processing-core" - version "${modeVersion}" - scope "implementation" - } - - dependency { - groupId "com.google.vr" - artifactId "sdk-base" - version "${gvrVersion}" - scope "implementation" - } - dependency { - groupId "com.google.vr" - artifactId "sdk-audio" - version "${gvrVersion}" - scope "implementation" - } - } +task sourceJar(type: Jar, dependsOn: classes) { + classifier = "sources" + from sourceSets.main.allSource +} + +publishing { + publications { + vrPublication(MavenPublication) { + from components.java + artifact sourceJar + pom { + groupId = "org.p5android" + artifactId = "processing-vr" + version = "${vrLibVersion}" + packaging = "jar" + licenses { + license { + name = "GNU Lesser General Public License, version 2.1" + url = "https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt" + distribution = "repo" + } + } + } + + pom.withXml { + // inserting the dependencies node + def dependenciesNode = asNode().appendNode('dependencies') + // start adding dependency nodes inside dependencies node + def processingCoreDependencyNode = dependenciesNode.appendNode('dependency') + processingCoreDependencyNode.appendNode('groupId', 'org.p5android') + processingCoreDependencyNode.appendNode('artifactId', 'processing-core') + processingCoreDependencyNode.appendNode('version', "${modeVersion}") + processingCoreDependencyNode.appendNode('scope', 'implementation') + + def googleVRDependencyNode = dependenciesNode.appendNode('dependency') + googleVRDependencyNode.appendNode('groupId', 'com.google.vr') + googleVRDependencyNode.appendNode('artifactId', 'sdk-base') + googleVRDependencyNode.appendNode('version', "${gvrVersion}") + googleVRDependencyNode.appendNode('scope', 'implementation') + + def googleVRAudioDependencyNode = dependenciesNode.appendNode('dependency') + googleVRAudioDependencyNode.appendNode('groupId', 'com.google.vr') + googleVRAudioDependencyNode.appendNode('artifactId', 'sdk-audio') + googleVRAudioDependencyNode.appendNode('version', "${gvrVersion}") + googleVRAudioDependencyNode.appendNode('scope', 'implementation') + } } - }.writeTo("dist/processing-vr-${vrLibVersion}.pom") + } } sourceSets { @@ -60,10 +71,6 @@ sourceSets { } } -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = "sources" - from sourceSets.main.allSource -} // Does not work because of Processing-specific tags in source code, such as @webref task javadocJar(type: Jar, dependsOn: javadoc) { @@ -73,7 +80,7 @@ task javadocJar(type: Jar, dependsOn: javadoc) { artifacts { // archives javadocJar - archives sourcesJar + archives sourceJar } jar.doLast { task -> @@ -100,6 +107,18 @@ compileJava.doFirst { build.doLast { + // If xml doesn't exist + def pomfile = file("${buildDir}/publications/vrPublication/pom-default.xml") + if (!pomfile.exists()) { + println("************************************************************************************************\n" + + "* *\n" + + "* File not found: root/mode/libraries/vr/build/publications/corePublication/pom-default.xml *\n" + + "* First execute the following command to generate the file: *\n" + + "* gradle generatePomFileForvrPublicationPublication *\n" + + "* *\n" + + "************************************************************************************************" + ) + } // // Copying vr jar to library folder File vrJar = file("library/vr.jar") vrJar.mkdirs(); @@ -115,4 +134,6 @@ build.doLast { file("dist/processing-vr-${vrLibVersion}-sources.jar").toPath(), REPLACE_EXISTING); Files.copy(file("$buildDir/libs/vr.jar.MD5").toPath(), file("dist/processing-vr-${vrLibVersion}.jar.md5").toPath(), REPLACE_EXISTING); -} \ No newline at end of file + Files.copy(file("$buildDir/publications/vrPublication/pom-default.xml").toPath(), + file("dist/processing-vr-${vrLibVersion}.pom").toPath(), REPLACE_EXISTING); +}