Skip to content

Commit 9ac5869

Browse files
authored
Merge pull request #635 from rupesh-kumar-lpu/mavenPublish
maven to maven-publish
2 parents e39526b + 440f57f commit 9ac5869

File tree

3 files changed

+198
-132
lines changed

3 files changed

+198
-132
lines changed

core/build.gradle

Lines changed: 72 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,14 @@
1+
import org.apache.tools.ant.Project
12
import java.nio.file.Files
2-
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING
3+
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
34

45
apply plugin: 'aar'
5-
apply plugin: 'maven'
6+
apply plugin: 'maven-publish'
67

78
dependencies {
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

4614
sourceSets {
@@ -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
6376
task javadocJar(type: Jar, dependsOn: javadoc) {
6477
classifier = "javadoc"
@@ -80,25 +93,38 @@ clean.doFirst {
8093
}
8194

8295
compileJava.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

90103
build.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+
}

mode/libraries/ar/build.gradle

Lines changed: 61 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,58 @@ import java.nio.file.Files
22
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
33

44
apply plugin: 'aar'
5-
apply plugin: 'maven'
5+
apply plugin: 'maven-publish'
66

77
dependencies {
88
compileOnly name: "android"
9-
109
compileOnly "org.p5android:processing-core:${modeVersion}"
11-
1210
implementationAar "com.google.ar:core:${garVersion}"
1311
}
1412

15-
task createPom {
16-
pom {
17-
project {
18-
groupId "org.p5android"
19-
artifactId "processing-ar"
20-
version "${arLibVersion}"
21-
packaging "jar"
22-
licenses {
23-
license {
24-
name "GNU Lesser General Public License, version 2.1"
25-
url "https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt"
26-
distribution "repo"
27-
}
28-
}
29-
dependencies {
30-
dependency {
31-
groupId "org.p5android"
32-
artifactId "processing-core"
33-
version "${modeVersion}"
34-
scope "implementation"
35-
}
13+
task sourceJar(type: Jar) {
14+
from sourceSets.main.allJava
15+
archiveClassifier = "sources"
16+
}
17+
18+
publishing {
19+
publications {
20+
arPublication(MavenPublication) {
21+
from components.java
22+
artifact sourceJar
23+
pom {
24+
groupId = "org.p5android"
25+
artifactId = "processing-ar"
26+
version = "${arLibVersion}"
27+
packaging = "jar"
28+
// description = "Processing Android Core"
29+
// url = "http://www.example.com/project"
30+
licenses {
31+
license {
32+
name = "GNU Lesser General Public License, version 2.1"
33+
url = "https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt"
34+
distribution = "repo"
35+
}
36+
}
37+
}
38+
39+
pom.withXml {
40+
// inserting the dependencies node
41+
def dependenciesNode = asNode().appendNode('dependencies')
42+
// start adding dependency nodes inside dependencies node
43+
def processingCoreDependencyNode = dependenciesNode.appendNode('dependency')
44+
processingCoreDependencyNode.appendNode('groupId', 'org.p5android')
45+
processingCoreDependencyNode.appendNode('artifactId', 'processing-core')
46+
processingCoreDependencyNode.appendNode('version', "${modeVersion}")
47+
processingCoreDependencyNode.appendNode('scope', 'implementation')
3648

37-
dependency {
38-
groupId "com.google.ar"
39-
artifactId "core"
40-
version "${garVersion}"
41-
scope "implementation"
42-
}
43-
}
49+
def googleARDependencyNode = dependenciesNode.appendNode('dependency')
50+
googleARDependencyNode.appendNode('groupId', 'com.google.ar')
51+
googleARDependencyNode.appendNode('artifactId', 'core')
52+
googleARDependencyNode.appendNode('version', "${garVersion}")
53+
googleARDependencyNode.appendNode('scope', 'implementation')
54+
}
4455
}
45-
}.writeTo("dist/processing-ar-${arLibVersion}.pom")
56+
}
4657
}
4758

4859
sourceSets {
@@ -56,11 +67,6 @@ sourceSets {
5667
}
5768
}
5869

59-
task sourcesJar(type: Jar, dependsOn: classes) {
60-
classifier = "sources"
61-
from sourceSets.main.allSource
62-
}
63-
6470
// Does not work because of Processing-specific tags in source code, such as @webref
6571
task javadocJar(type: Jar, dependsOn: javadoc) {
6672
classifier = "javadoc"
@@ -69,7 +75,7 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
6975

7076
artifacts {
7177
// archives javadocJar
72-
archives sourcesJar
78+
archives sourceJar
7379
}
7480

7581
jar.doLast { task ->
@@ -92,13 +98,24 @@ compileJava.doFirst {
9298
}
9399

94100
build.doLast {
101+
// If xml doesn't exist
102+
def pomfile = file("${buildDir}/publications/arPublication/pom-default.xml")
103+
if (!pomfile.exists()) {
104+
println("**********************************************************************************************\n" +
105+
"* *\n" +
106+
"* File not found: root/mode/libraries/ar/build/publications/arPublication/pom-default.xml *\n" +
107+
"* First execute the following command to generate the file: *\n" +
108+
"* gradle generatePomFileForarPublicationPublication *\n" +
109+
"* *\n" +
110+
"**********************************************************************************************"
111+
)
112+
}
95113
// Copying ar jar to library folder
96114
File arJar = file("library/ar.jar")
97115
arJar.mkdirs();
98116
Files.copy(file("$buildDir/libs/ar.jar").toPath(),
99-
arJar.toPath(), REPLACE_EXISTING);
100-
101-
// // Copying the files for release on JCentral
117+
arJar.toPath(), REPLACE_EXISTING);
118+
// Copying the files for release on JCentral
102119
File distFolder = file("dist");
103120
distFolder.mkdirs();
104121
Files.copy(file("$buildDir/libs/ar.jar").toPath(),
@@ -107,4 +124,6 @@ build.doLast {
107124
file("dist/processing-ar-${arLibVersion}-sources.jar").toPath(), REPLACE_EXISTING);
108125
Files.copy(file("$buildDir/libs/ar.jar.MD5").toPath(),
109126
file("dist/processing-ar-${arLibVersion}.jar.md5").toPath(), REPLACE_EXISTING);
110-
}
127+
Files.copy(file("${buildDir}/publications/arPublication/pom-default.xml").toPath(),
128+
file("dist/processing-ar-${arLibVersion}.pom").toPath(), REPLACE_EXISTING)
129+
}

0 commit comments

Comments
 (0)