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} "
11+ implementationAar " com.google.android.support:wearable:${ wearVersion} "
12+ }
13+
14+ task sourceJar (type : Jar ) {
15+ from sourceSets. main. allJava
16+ archiveClassifier = " sources"
1217}
1318
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- }
19+ publishing {
20+ publications {
21+ corePublication(MavenPublication ) {
22+ from components. java
23+ artifact sourceJar
24+ pom {
25+ groupId = " org.p5android"
26+ artifactId = " processing-core"
27+ version = " ${ modeVersion} "
28+ packaging = " jar"
29+ // description = "Processing Android Core"
30+ // url = "http://www.example.com/project"
31+ licenses {
32+ license {
33+ name = " GNU Lesser General Public License, version 2.1"
34+ url = " https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt"
35+ distribution = " repo"
36+ }
37+ }
38+ }
39+ pom. withXml { // Only one dependency is added under dependancies node
40+ asNode(). remove(asNode(). get(" dependencies" )) // removing dependencies node
41+ // inserting the dependencies node
42+ def dependenciesNode = asNode(). appendNode(' dependencies' )
43+ // start adding dependency nodes inside dependencies node
44+ def dependencyNode = dependenciesNode. appendNode(' dependency' )
45+ dependencyNode. appendNode(' groupId' , ' androidx.legacy' )
46+ dependencyNode. appendNode(' artifactId' , ' legacy-support-v4' )
47+ dependencyNode. appendNode(' version' , ' 1.0.0' )
48+ dependencyNode. appendNode(' scope' , ' implementation' )
49+
50+ def dependencyNode2 = dependenciesNode. appendNode(' dependency' )
51+ dependencyNode2. appendNode(' groupId' , ' com.google.android.support' )
52+ dependencyNode2. appendNode(' artifactId' , ' wearable' )
53+ dependencyNode2. appendNode(' version' , ' 2.8.1' )
54+ dependencyNode2. appendNode(' scope' , ' implementation' )
55+
56+ def dependencyNode3 = dependenciesNode. appendNode(' dependency' )
57+ dependencyNode3. appendNode(' artifactId' , ' android' )
58+ dependencyNode3. appendNode(' scope' , ' runtime' )
59+ }
4260 }
43- }. writeTo( " dist/processing-core- ${ modeVersion } .pom " )
61+ }
4462}
4563
4664sourceSets {
@@ -80,25 +98,38 @@ clean.doFirst {
8098}
8199
82100compileJava. doFirst {
83- String [] deps = [" wearable.jar" ]
101+ String [] deps = [" wearable.jar" ]
84102 for (String fn : deps) {
85103 Files . copy(file(" ${ rootDir} /build/libs/" + fn). toPath(),
86- file(" ${ rootDir} /mode/mode/" + fn). toPath(), REPLACE_EXISTING )
104+ file(" ${ rootDir} /mode/mode/" + fn). toPath(), REPLACE_EXISTING )
87105 }
88106}
89107
90108build. doLast {
91- // Copying core jar as zip inside the mode folder
109+ // If xml doesn't exist
110+ def pomfile = file(" ${ buildDir} /publications/corePublication/pom-default.xml" )
111+ if (! pomfile. exists()) {
112+ println (" ***************************************************************************************\n " +
113+ " * *\n " +
114+ " * File not found: root/core/build/publications/corePublication/pom-default.xml *\n " +
115+ " * First execute the following command to generate the file: *\n " +
116+ " * gradle generatePomFileForcorePublicationPublication *\n " +
117+ " * *\n " +
118+ " ***************************************************************************************"
119+ )
120+ }
121+ // // Copying core jar as zip inside the mode folder
92122 Files . copy(file(" ${ buildDir} /libs/core.jar" ). toPath(),
93- file(" ${ coreZipPath} " ). toPath(), REPLACE_EXISTING )
94-
95- // Copying the files for release on JCentral
123+ file(" ${ coreZipPath} " ). toPath(), REPLACE_EXISTING )
124+ // // Copying the files for release on JCentral
96125 File distFolder = file(" dist" )
97126 distFolder. mkdirs()
98127 Files . copy(file(" ${ buildDir} /libs/core.jar" ). toPath(),
99- file(" dist/processing-core-${ modeVersion} .jar" ). toPath(), REPLACE_EXISTING )
128+ file(" dist/processing-core-${ modeVersion} .jar" ). toPath(), REPLACE_EXISTING )
100129 Files . copy(file(" ${ buildDir} /libs/core-sources.jar" ). toPath(),
101- file(" dist/processing-core-${ modeVersion} -sources.jar" ). toPath(), REPLACE_EXISTING )
130+ file(" dist/processing-core-${ modeVersion} -sources.jar" ). toPath(), REPLACE_EXISTING )
102131 Files . copy(file(" ${ buildDir} /libs/core.jar.MD5" ). toPath(),
103- file(" dist/processing-core-${ modeVersion} .jar.md5" ). toPath(), REPLACE_EXISTING )
104- }
132+ file(" dist/processing-core-${ modeVersion} .jar.md5" ). toPath(), REPLACE_EXISTING )
133+ Files . copy(file(" ${ buildDir} /publications/corePublication/pom-default.xml" ). toPath(),
134+ file(" dist/processing-core-${ modeVersion} .pom" ). toPath(), REPLACE_EXISTING )
135+ }
0 commit comments