1+ import org.apache.tools.ant.Project
12import java.nio.file.Files
2- import static java.nio.file.StandardCopyOption.REPLACE_EXISTING
3+ import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
34
45apply plugin : ' aar'
5- apply plugin : ' maven'
6+ apply plugin : ' maven-publish '
67
78dependencies {
89 implementation name : " android"
9-
1010 implementationAar " androidx.legacy:legacy-support-v4:${ v4legacyVersion} "
11- implementationAar " com.google.android.support:wearable:${ wearVersion} "
12- }
13-
14- task createPom {
15- pom {
16- project {
17- groupId " org.p5android"
18- artifactId " processing-core"
19- version " ${ modeVersion} "
20- packaging " jar"
21- licenses {
22- license {
23- name " GNU Lesser General Public License, version 2.1"
24- url " https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt"
25- distribution " repo"
26- }
27- }
28- dependencies {
29- dependency {
30- groupId " androidx.legacy"
31- artifactId " legacy-support-v4"
32- version " ${ v4legacyVersion} "
33- scope " implementation"
34- }
35- dependency {
36- groupId " com.google.android.support"
37- artifactId " wearable"
38- version " ${ wearVersion} "
39- scope " implementation"
40- }
41- }
42- }
43- }. writeTo(" dist/processing-core-${ modeVersion} .pom" )
11+ implementationAar " com.google.android.support:wearable:${ wearVersion} "
4412}
4513
4614sourceSets {
@@ -59,6 +27,51 @@ task sourcesJar(type: Jar, dependsOn: classes) {
5927 from sourceSets. main. allSource
6028}
6129
30+ publishing {
31+ publications {
32+ corePublication(MavenPublication ) {
33+ from components. java
34+ artifact sourcesJar
35+ pom {
36+ groupId = " org.p5android"
37+ artifactId = " processing-core"
38+ version = " ${ modeVersion} "
39+ packaging = " jar"
40+ // description = "Processing Android Core"
41+ // url = "http://www.example.com/project"
42+ licenses {
43+ license {
44+ name = " GNU Lesser General Public License, version 2.1"
45+ url = " https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt"
46+ distribution = " repo"
47+ }
48+ }
49+ }
50+ pom. withXml { // Only one dependency is added under dependancies node
51+ asNode(). remove(asNode(). get(" dependencies" )) // removing dependencies node
52+ // inserting the dependencies node
53+ def dependenciesNode = asNode(). appendNode(' dependencies' )
54+ // start adding dependency nodes inside dependencies node
55+ def androidLegacyDependancyNode = dependenciesNode. appendNode(' dependency' )
56+ androidLegacyDependancyNode. appendNode(' groupId' , ' androidx.legacy' )
57+ androidLegacyDependancyNode. appendNode(' artifactId' , ' legacy-support-v4' )
58+ androidLegacyDependancyNode. appendNode(' version' , " ${ v4legacyVersion} " )
59+ androidLegacyDependancyNode. appendNode(' scope' , ' implementation' )
60+
61+ def wearableDependencyNode = dependenciesNode. appendNode(' dependency' )
62+ wearableDependencyNode. appendNode(' groupId' , ' com.google.android.support' )
63+ wearableDependencyNode. appendNode(' artifactId' , ' wearable' )
64+ wearableDependencyNode. appendNode(' version' , " ${ wearVersion} " )
65+ wearableDependencyNode. appendNode(' scope' , ' implementation' )
66+
67+ def androidRuntimeDependencyNode = dependenciesNode. appendNode(' dependency' )
68+ androidRuntimeDependencyNode. appendNode(' artifactId' , ' android' )
69+ androidRuntimeDependencyNode. appendNode(' scope' , ' runtime' )
70+ }
71+ }
72+ }
73+ }
74+
6275// Does not work because of Processing-specific tags in source code, such as @webref
6376task javadocJar (type : Jar , dependsOn : javadoc) {
6477 classifier = " javadoc"
@@ -80,25 +93,38 @@ clean.doFirst {
8093}
8194
8295compileJava. doFirst {
83- String [] deps = [" wearable.jar" ]
96+ String [] deps = [" wearable.jar" ]
8497 for (String fn : deps) {
8598 Files . copy(file(" ${ rootDir} /build/libs/" + fn). toPath(),
86- file(" ${ rootDir} /mode/mode/" + fn). toPath(), REPLACE_EXISTING )
99+ file(" ${ rootDir} /mode/mode/" + fn). toPath(), REPLACE_EXISTING )
87100 }
88101}
89102
90103build. doLast {
91- // Copying core jar as zip inside the mode folder
104+ // If xml doesn't exist
105+ def pomfile = file(" ${ buildDir} /publications/corePublication/pom-default.xml" )
106+ if (! pomfile. exists()) {
107+ println (" ***************************************************************************************\n " +
108+ " * *\n " +
109+ " * File not found: root/core/build/publications/corePublication/pom-default.xml *\n " +
110+ " * First execute the following command to generate the file: *\n " +
111+ " * gradle generatePomFileForcorePublicationPublication *\n " +
112+ " * *\n " +
113+ " ***************************************************************************************"
114+ )
115+ }
116+ // // Copying core jar as zip inside the mode folder
92117 Files . copy(file(" ${ buildDir} /libs/core.jar" ). toPath(),
93- file(" ${ coreZipPath} " ). toPath(), REPLACE_EXISTING )
94-
95- // Copying the files for release on JCentral
118+ file(" ${ coreZipPath} " ). toPath(), REPLACE_EXISTING )
119+ // // Copying the files for release on JCentral
96120 File distFolder = file(" dist" )
97121 distFolder. mkdirs()
98122 Files . copy(file(" ${ buildDir} /libs/core.jar" ). toPath(),
99- file(" dist/processing-core-${ modeVersion} .jar" ). toPath(), REPLACE_EXISTING )
123+ file(" dist/processing-core-${ modeVersion} .jar" ). toPath(), REPLACE_EXISTING )
100124 Files . copy(file(" ${ buildDir} /libs/core-sources.jar" ). toPath(),
101- file(" dist/processing-core-${ modeVersion} -sources.jar" ). toPath(), REPLACE_EXISTING )
125+ file(" dist/processing-core-${ modeVersion} -sources.jar" ). toPath(), REPLACE_EXISTING )
102126 Files . copy(file(" ${ buildDir} /libs/core.jar.MD5" ). toPath(),
103- file(" dist/processing-core-${ modeVersion} .jar.md5" ). toPath(), REPLACE_EXISTING )
104- }
127+ file(" dist/processing-core-${ modeVersion} .jar.md5" ). toPath(), REPLACE_EXISTING )
128+ Files . copy(file(" ${ buildDir} /publications/corePublication/pom-default.xml" ). toPath(),
129+ file(" dist/processing-core-${ modeVersion} .pom" ). toPath(), REPLACE_EXISTING )
130+ }
0 commit comments