Skip to content

Commit 82f915b

Browse files
VR maven to maven-publish
1 parent 6273182 commit 82f915b

File tree

1 file changed

+71
-7
lines changed

1 file changed

+71
-7
lines changed

mode/libraries/vr/build.gradle

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ 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"
@@ -13,6 +13,7 @@ dependencies {
1313
implementationAar "com.google.vr:sdk-base:${gvrVersion}"
1414
}
1515

16+
/*
1617
task createPom {
1718
pom {
1819
project {
@@ -52,6 +53,59 @@ task createPom {
5253
}.writeTo("dist/processing-vr-${vrLibVersion}.pom")
5354
}
5455
56+
57+
*/
58+
59+
task sourceJar(type: Jar, dependsOn: classes) {
60+
classifier = "sources"
61+
from sourceSets.main.allSource
62+
}
63+
64+
publishing {
65+
publications {
66+
vrPublication(MavenPublication) {
67+
from components.java
68+
artifact sourceJar
69+
pom {
70+
groupId = "org.p5android"
71+
artifactId = "processing-vr"
72+
version = "${vrLibVersion}"
73+
packaging = "jar"
74+
licenses {
75+
license {
76+
name = "GNU Lesser General Public License, version 2.1"
77+
url = "https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt"
78+
distribution = "repo"
79+
}
80+
}
81+
}
82+
83+
pom.withXml {
84+
// inserting the dependencies node
85+
def dependenciesNode = asNode().appendNode('dependencies')
86+
// start adding dependency nodes inside dependencies node
87+
def dependencyNode = dependenciesNode.appendNode('dependency')
88+
dependencyNode.appendNode('groupId', 'org.p5android')
89+
dependencyNode.appendNode('artifactId', 'processing-core')
90+
dependencyNode.appendNode('version', '4.2.0')
91+
dependencyNode.appendNode('scope', 'implementation')
92+
93+
def dependencyNode2 = dependenciesNode.appendNode('dependency')
94+
dependencyNode2.appendNode('groupId', 'com.google.vr')
95+
dependencyNode2.appendNode('artifactId', 'sdk-base')
96+
dependencyNode2.appendNode('version', '1.180.0')
97+
dependencyNode2.appendNode('scope', 'implementation')
98+
99+
def dependencyNode3 = dependenciesNode.appendNode('dependency')
100+
dependencyNode3.appendNode('groupId', 'com.google.vr')
101+
dependencyNode3.appendNode('artifactId', 'sdk-audio')
102+
dependencyNode3.appendNode('version', '1.180.0')
103+
dependencyNode3.appendNode('scope', 'implementation')
104+
}
105+
}
106+
}
107+
}
108+
55109
sourceSets {
56110
main {
57111
java {
@@ -60,10 +114,6 @@ sourceSets {
60114
}
61115
}
62116

63-
task sourcesJar(type: Jar, dependsOn: classes) {
64-
classifier = "sources"
65-
from sourceSets.main.allSource
66-
}
67117

68118
// Does not work because of Processing-specific tags in source code, such as @webref
69119
task javadocJar(type: Jar, dependsOn: javadoc) {
@@ -73,7 +123,7 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
73123

74124
artifacts {
75125
// archives javadocJar
76-
archives sourcesJar
126+
archives sourceJar
77127
}
78128

79129
jar.doLast { task ->
@@ -100,6 +150,18 @@ compileJava.doFirst {
100150

101151

102152
build.doLast {
153+
// If xml doesn't exist
154+
def pomfile = file("${buildDir}/publications/corePublication/pom-default.xml")
155+
if (!pomfile.exists()) {
156+
println("************************************************************************************************\n" +
157+
"* *\n" +
158+
"* File not found: root/mode/libraries/vr/build/publications/corePublication/pom-default.xml *\n" +
159+
"* First execute the following command to generate the file: *\n" +
160+
"* gradle generatePomFileForvrPublicationPublication *\n" +
161+
"* *\n" +
162+
"************************************************************************************************"
163+
)
164+
}
103165
// // Copying vr jar to library folder
104166
File vrJar = file("library/vr.jar")
105167
vrJar.mkdirs();
@@ -115,4 +177,6 @@ build.doLast {
115177
file("dist/processing-vr-${vrLibVersion}-sources.jar").toPath(), REPLACE_EXISTING);
116178
Files.copy(file("$buildDir/libs/vr.jar.MD5").toPath(),
117179
file("dist/processing-vr-${vrLibVersion}.jar.md5").toPath(), REPLACE_EXISTING);
118-
}
180+
Files.copy(file("$buildDir/publications/corePublication/pom-default.xml").toPath(),
181+
file("dist/processing-vr-${vrLibVersion}.pom").toPath(), REPLACE_EXISTING);
182+
}

0 commit comments

Comments
 (0)