Skip to content

maven to maven-publish #635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Apr 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 72 additions & 46 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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"
Expand All @@ -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)
}
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)
}
103 changes: 61 additions & 42 deletions mode/libraries/ar/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"
Expand All @@ -69,7 +75,7 @@ task javadocJar(type: Jar, dependsOn: javadoc) {

artifacts {
// archives javadocJar
archives sourcesJar
archives sourceJar
}

jar.doLast { task ->
Expand All @@ -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(),
Expand All @@ -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);
}
Files.copy(file("${buildDir}/publications/arPublication/pom-default.xml").toPath(),
file("dist/processing-ar-${arLibVersion}.pom").toPath(), REPLACE_EXISTING)
}
Loading