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 9 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 dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', 'androidx.legacy')
dependencyNode.appendNode('artifactId', 'legacy-support-v4')
dependencyNode.appendNode('version', "${v4legacyVersion}")
dependencyNode.appendNode('scope', 'implementation')

def dependencyNode2 = dependenciesNode.appendNode('dependency')
Copy link
Member

@ranaaditya ranaaditya Jan 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should follow proper naming of variables !

ex - instead of dependencyNode you can use something like androidLegacyDependancyNode
and instead of dependencyNode2 you can use wearableDependencyNode

Proper naming of variables is very important in any OpenSource project !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected variable names in Core build.gradle file, Thanks for providing a clear example!

dependencyNode2.appendNode('groupId', 'com.google.android.support')
dependencyNode2.appendNode('artifactId', 'wearable')
dependencyNode2.appendNode('version', "${wearVersion}")
dependencyNode2.appendNode('scope', 'implementation')

def dependencyNode3 = dependenciesNode.appendNode('dependency')
dependencyNode3.appendNode('artifactId', 'android')
dependencyNode3.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)
}
105 changes: 63 additions & 42 deletions mode/libraries/ar/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,60 @@ 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 dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', 'org.p5android')
dependencyNode.appendNode('artifactId', 'processing-core')
dependencyNode.appendNode('version', "${modeVersion}")
dependencyNode.appendNode('scope', 'implementation')

def dependencyNode2 = dependenciesNode.appendNode('dependency')
dependencyNode2.appendNode('groupId', 'com.google.ar')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use proper names for the variables !

PS: as mentioned above about the naming of variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected variable names in AR build.gradle

dependencyNode2.appendNode('artifactId', 'core')
dependencyNode2.appendNode('version', "${garVersion}")
dependencyNode2.appendNode('scope', 'implementation')
}


dependency {
groupId "com.google.ar"
artifactId "core"
version "${garVersion}"
scope "implementation"
}
}
}
}.writeTo("dist/processing-ar-${arLibVersion}.pom")
}
}

sourceSets {
Expand All @@ -56,11 +69,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 +77,7 @@ task javadocJar(type: Jar, dependsOn: javadoc) {

artifacts {
// archives javadocJar
archives sourcesJar
archives sourceJar
}

jar.doLast { task ->
Expand All @@ -92,13 +100,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 +126,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