Last active
October 18, 2017 11:58
-
-
Save edwardstock/ca4baec09d3134bc0f0905a654b55526 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2017 Eduard Maximovich | |
* Atlas | |
*/ | |
apply plugin: 'maven' | |
version = VERSION_NAME | |
group = GROUP | |
def isReleaseBuild() { | |
return !VERSION_NAME.contains("SNAPSHOT") | |
} | |
def getReleaseRepositoryUrl() { | |
if (hasProperty('atlas_maven_repo')) { | |
return String.format("file:%s/%s", atlas_maven_repo, "releases") | |
} | |
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL : | |
"https://oss.sonatype.org/service/local/staging/deploy/maven2/" | |
} | |
def getSnapshotRepositoryUrl() { | |
if (hasProperty('atlas_maven_repo')) { | |
return String.format("file:%s/%s", atlas_maven_repo, "snapshots") | |
} | |
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL : | |
"https://oss.sonatype.org/content/repositories/snapshots/" | |
} | |
def getRepositoryUsername() { | |
if (hasProperty('atlas_maven_user')) { | |
return atlas_maven_user | |
} | |
return hasProperty('SONATYPE_NEXUS_USERNAME') ? SONATYPE_NEXUS_USERNAME : "" | |
} | |
def getRepositoryPassword() { | |
if (hasProperty('atlas_maven_password')) { | |
return atlas_maven_password | |
} | |
return hasProperty('SONATYPE_NEXUS_PASSWORD') ? SONATYPE_NEXUS_PASSWORD : "" | |
} | |
afterEvaluate { project -> | |
uploadArchives { | |
repositories { | |
mavenDeployer { | |
pom.groupId = GROUP | |
pom.artifactId = POM_ARTIFACT_ID | |
pom.version = VERSION_NAME | |
repository(url: getReleaseRepositoryUrl()) { | |
// authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) | |
} | |
snapshotRepository(url: getSnapshotRepositoryUrl()) { | |
// authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) | |
} | |
pom.project { | |
name POM_NAME | |
packaging POM_PACKAGING | |
description POM_DESCRIPTION | |
url POM_URL | |
scm { | |
url POM_SCM_URL | |
connection POM_SCM_CONNECTION | |
developerConnection POM_SCM_DEV_CONNECTION | |
} | |
licenses { | |
license { | |
name POM_LICENCE_NAME | |
url POM_LICENCE_URL | |
distribution POM_LICENCE_DIST | |
} | |
} | |
developers { | |
developer { | |
id POM_DEVELOPER_ID | |
name POM_DEVELOPER_NAME | |
} | |
} | |
} | |
} | |
} | |
} | |
if (project.getPlugins().hasPlugin('com.android.application') || | |
project.getPlugins().hasPlugin('com.android.library')) { | |
task install(type: Upload, dependsOn: assemble) { | |
repositories.mavenInstaller { | |
configuration = configurations.archives | |
pom.groupId = GROUP | |
pom.artifactId = POM_ARTIFACT_ID | |
pom.version = VERSION_NAME | |
pom.project { | |
name POM_NAME | |
packaging POM_PACKAGING | |
description POM_DESCRIPTION | |
url POM_URL | |
scm { | |
url POM_SCM_URL | |
connection POM_SCM_CONNECTION | |
developerConnection POM_SCM_DEV_CONNECTION | |
} | |
licenses { | |
license { | |
name POM_LICENCE_NAME | |
url POM_LICENCE_URL | |
distribution POM_LICENCE_DIST | |
} | |
} | |
developers { | |
developer { | |
id POM_DEVELOPER_ID | |
name POM_DEVELOPER_NAME | |
} | |
} | |
} | |
} | |
} | |
task androidJavadocs(type: Javadoc) { | |
source = android.sourceSets.main.java.source | |
classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) | |
} | |
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { | |
classifier = 'javadoc' | |
from androidJavadocs.destinationDir | |
} | |
task androidSourcesJar(type: Jar) { | |
classifier = 'sources' | |
from android.sourceSets.main.java.source | |
} | |
} else { | |
install { | |
repositories.mavenInstaller { | |
pom.groupId = GROUP | |
pom.artifactId = POM_ARTIFACT_ID | |
pom.version = VERSION_NAME | |
pom.project { | |
name POM_NAME | |
packaging POM_PACKAGING | |
description POM_DESCRIPTION | |
url POM_URL | |
scm { | |
url POM_SCM_URL | |
connection POM_SCM_CONNECTION | |
developerConnection POM_SCM_DEV_CONNECTION | |
} | |
licenses { | |
license { | |
name POM_LICENCE_NAME | |
url POM_LICENCE_URL | |
distribution POM_LICENCE_DIST | |
} | |
} | |
developers { | |
developer { | |
id POM_DEVELOPER_ID | |
name POM_DEVELOPER_NAME | |
} | |
} | |
} | |
} | |
} | |
task sourcesJar(type: Jar, dependsOn: classes) { | |
classifier = 'sources' | |
from sourceSets.main.allSource | |
} | |
task javadocJar(type: Jar, dependsOn: javadoc) { | |
classifier = 'javadoc' | |
from javadoc.destinationDir | |
} | |
} | |
if (JavaVersion.current().isJava8Compatible()) { | |
allprojects { | |
tasks.withType(Javadoc) { | |
options.addStringOption('Xdoclint:none', '-quiet') | |
} | |
} | |
} | |
artifacts { | |
if (project.getPlugins().hasPlugin('com.android.application') || | |
project.getPlugins().hasPlugin('com.android.library')) { | |
archives androidSourcesJar | |
archives androidJavadocsJar | |
} else { | |
archives sourcesJar | |
archives javadocJar | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment