Skip to content

Commit

Permalink
Move jfrog publish script to 'circleindicator/build.gradle' and add '…
Browse files Browse the repository at this point in the history
…androidSourcesJar' task to publish source code
  • Loading branch information
saini2sandeep committed Jun 24, 2022
1 parent feea850 commit 259cc20
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 59 deletions.
116 changes: 58 additions & 58 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,61 +22,61 @@ allprojects {
}
}

ext.versionName = { ->
def currentTag = 'git tag --points-at HEAD'.execute().in.text.toString().trim()
def currentBranch = 'git rev-parse --abbrev-ref HEAD'.execute().in.text.toString().trim()
def tagRegex = "[0-9.]*[0-9]"
if (!currentTag.isEmpty() && currentTag.matches(tagRegex)) {// is not empty and is in following format 8.0
return currentTag
} else {
return currentBranch + '-SNAPSHOT'
}
}

def libraryGroupId = 'com.meesho.android'
def libraryVersion = versionName()

project('circleindicator') {
artifactoryPublish.dependsOn('build')
publishing {
publications {
aar(MavenPublication) {
groupId = libraryGroupId
artifactId = 'circle-indicator'
version = libraryVersion
// Tell maven to prepare the generated "*.aar" file for publishing
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")

pom.withXml {
def dependencies = asNode().appendNode('dependencies')
configurations.getByName("releaseCompileClasspath").getResolvedConfiguration().getFirstLevelModuleDependencies().each {
def dependency = dependencies.appendNode('dependency')
dependency.appendNode('groupId', it.moduleGroup)
dependency.appendNode('artifactId', it.moduleName)
dependency.appendNode('version', it.moduleVersion)
}
}
}
}
}
}
artifactory {

//The base Artifactory URL if not overridden by the publisher/resolver
contextUrl = project.properties["JFROG_ARTIFACTORY_URL"]
publish {
repository {
repoKey = libraryVersion.endsWith('-SNAPSHOT') ? project.properties["SNAPSHOT_REPO_NAME"] :
project.properties["RELEASE_REPO_NAME"]
username = project.properties["JFROG_ARTIFACTORY_USERNAME"]
password = project.properties["JFROG_ARTIFACTORY_KEY"]
}
defaults {
// Tell the Artifactory Plugin which artifacts should be published to Artifactory.
publications('aar')
publishArtifacts = true
// Publish generated POM files to Artifactory (true by default)
publishPom = true
}
}
}
//ext.versionName = { ->
// def currentTag = 'git tag --points-at HEAD'.execute().in.text.toString().trim()
// def currentBranch = 'git rev-parse --abbrev-ref HEAD'.execute().in.text.toString().trim()
// def tagRegex = "[0-9.]*[0-9]"
// if (!currentTag.isEmpty() && currentTag.matches(tagRegex)) {// is not empty and is in following format 8.0
// return currentTag
// } else {
// return currentBranch + '-SNAPSHOT'
// }
//}
//
//def libraryGroupId = 'com.meesho.android'
//def libraryVersion = versionName()
//
//project('circleindicator') {
// artifactoryPublish.dependsOn('build')
// publishing {
// publications {
// aar(MavenPublication) {
// groupId = libraryGroupId
// artifactId = 'circle-indicator'
// version = libraryVersion
// // Tell maven to prepare the generated "*.aar" file for publishing
// artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
//
// pom.withXml {
// def dependencies = asNode().appendNode('dependencies')
// configurations.getByName("releaseCompileClasspath").getResolvedConfiguration().getFirstLevelModuleDependencies().each {
// def dependency = dependencies.appendNode('dependency')
// dependency.appendNode('groupId', it.moduleGroup)
// dependency.appendNode('artifactId', it.moduleName)
// dependency.appendNode('version', it.moduleVersion)
// }
// }
// }
// }
// }
//}
//artifactory {
//
// //The base Artifactory URL if not overridden by the publisher/resolver
// contextUrl = project.properties["JFROG_ARTIFACTORY_URL"]
// publish {
// repository {
// repoKey = libraryVersion.endsWith('-SNAPSHOT') ? project.properties["SNAPSHOT_REPO_NAME"] :
// project.properties["RELEASE_REPO_NAME"]
// username = project.properties["JFROG_ARTIFACTORY_USERNAME"]
// password = project.properties["JFROG_ARTIFACTORY_KEY"]
// }
// defaults {
// // Tell the Artifactory Plugin which artifacts should be published to Artifactory.
// publications('aar')
// publishArtifacts = true
// // Publish generated POM files to Artifactory (true by default)
// publishPom = true
// }
// }
//}
67 changes: 66 additions & 1 deletion circleindicator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,69 @@ dependencies {
}

//apply from: "upload-jcenter.gradle"
//apply from: "upload-maven.gradle"
//apply from: "upload-maven.gradle"

ext.versionName = { ->
def currentTag = 'git tag --points-at HEAD'.execute().in.text.toString().trim()
def currentBranch = 'git rev-parse --abbrev-ref HEAD'.execute().in.text.toString().trim()
def tagRegex = "[0-9.]*[0-9]"
if (!currentTag.isEmpty() && currentTag.matches(tagRegex)) {
// is not empty and is in following format 8.0
return currentTag
} else {
return currentBranch + '-SNAPSHOT'
}
}

def libraryGroupId = 'com.meesho.android'
def libraryVersion = versionName()

task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
from android.sourceSets.main.java.srcDirs
}

artifactoryPublish.dependsOn('build')
publishing {
publications {
aar(MavenPublication) {
groupId = libraryGroupId
artifactId = 'circle-indicator'
version = libraryVersion
// Tell maven to prepare the generated "*.aar" file for publishing
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
artifact androidSourcesJar

pom.withXml {
def dependencies = asNode().appendNode('dependencies')
configurations.getByName("releaseCompileClasspath").getResolvedConfiguration().getFirstLevelModuleDependencies().each {
def dependency = dependencies.appendNode('dependency')
dependency.appendNode('groupId', it.moduleGroup)
dependency.appendNode('artifactId', it.moduleName)
dependency.appendNode('version', it.moduleVersion)
}
}
}
}
}

artifactory {

//The base Artifactory URL if not overridden by the publisher/resolver
contextUrl = project.properties["JFROG_ARTIFACTORY_URL"]
publish {
repository {
repoKey = libraryVersion.endsWith('-SNAPSHOT') ? project.properties["SNAPSHOT_REPO_NAME"] :
project.properties["RELEASE_REPO_NAME"]
username = project.properties["JFROG_ARTIFACTORY_USERNAME"]
password = project.properties["JFROG_ARTIFACTORY_KEY"]
}
defaults {
// Tell the Artifactory Plugin which artifacts should be published to Artifactory.
publications('aar')
publishArtifacts = true
// Publish generated POM files to Artifactory (true by default)
publishPom = true
}
}
}

0 comments on commit 259cc20

Please sign in to comment.