Skip to content

Commit

Permalink
Add jfrog publish script
Browse files Browse the repository at this point in the history
  • Loading branch information
saini2sandeep committed Jun 24, 2022
1 parent 3324ab0 commit c7a78cd
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 5 deletions.
71 changes: 70 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,81 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.28.3"
}
}

allprojects {
apply plugin: "com.jfrog.artifactory"
apply plugin: "maven-publish"
apply plugin: 'java-library'
repositories {
google()
jcenter()
mavenCentral()
}
}

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 sourceSets.main.java.srcDirs
}

project('time') {
artifactoryPublish.dependsOn('build')
publishing {
publications {
mavenJava(MavenPublication) {
groupId = libraryGroupId
artifactId = 'time'
version = libraryVersion
// Tell maven to prepare the generated "*.jar" file for publishing
artifact("$buildDir/libs/time.jar")
artifact androidSourcesJar

pom.withXml {
def dependencies = asNode().appendNode('dependencies')
configurations.implementation.allDependencies.each {
def dependency = dependencies.appendNode('dependency')
dependency.appendNode('groupId', it.group)
dependency.appendNode('artifactId', it.name)
dependency.appendNode('version', it.version)
}
}
}
}
}
}
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('mavenJava')
publishArtifacts = true
// Publish generated POM files to Artifactory (true by default)
publishPom = true
}
}
}
5 changes: 1 addition & 4 deletions time/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ apply plugin: 'kotlin'
group = 'com.github.kizitonwose'

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// This is a false positive, documented at https://youtrack.jetbrains.com/issue/KT-23933
// noinspection DifferentStdlibGradleVersion
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
testImplementation 'junit:junit:4.12'
}

Expand Down

0 comments on commit c7a78cd

Please sign in to comment.