Last active
January 2, 2016 10:48
-
-
Save lifuzu/8291973 to your computer and use it in GitHub Desktop.
Upload packages to Nexus artifact server
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
/* | |
* The name of the package. Also used as the name uploaded to the maven repo. | |
*/ | |
def artifactId='DemoApp' | |
/* | |
* The group definition. | |
*/ | |
def groupId='com.lifuzu.app' | |
/* | |
* The version definition, please suffix with '-SNAPSHOT' for snapshot version. | |
*/ | |
def version='1.0.0-SNAPSHOT' | |
/* | |
* The packages definition. | |
*/ | |
def packages=[ | |
[source: 'commons-codec-1.4.jar', classifier: null, extension: 'jar'], | |
[source: 'lint-api-22.2.1.jar', classifier: 'api', extension: 'jar'] | |
] | |
apply plugin: 'maven-publish' | |
def publication = publishing.publications.create("packages", MavenPublication) | |
def repositories = publishing.repositories | |
def artifacts = publication.artifacts | |
task collectArtifacts << { | |
packages.each { | |
artifacts.add(publication.artifact([source: file(relativePath(it.source)), classifier: it.classifier, extension: it.extension])) | |
} | |
publication.artifactId = artifactId | |
publication.groupId = groupId | |
publication.version = version | |
publication.pom.withXml { | |
asNode().children().last() + { | |
resolveStrategy = Closure.DELEGATE_FIRST | |
name artifactId | |
description 'description for project' | |
url 'projectUrl' | |
scm { | |
url 'scmUrl' | |
connection 'connectionUrl' | |
developerConnection 'developerConnectionUrl' | |
} | |
licenses { | |
license { | |
name 'The Apache Software License, Version 2.0' | |
url 'http://www.apache.org/license/LICENSE-2.0.txt' | |
distribution 'repo' | |
} | |
} | |
developers { | |
developer { | |
id 'lifuzu' | |
name 'Richard Lee' | |
email '[email protected]' | |
} | |
} | |
} | |
} | |
} | |
def maven = { | |
credentials { | |
username REPO_DEPLOYMENT_USERNAME | |
password REPO_DEPLOYMENT_PASSWORD | |
} | |
if(version.endsWith('-SNAPSHOT')){ | |
url REPO_DEPLOYMENT_URL + "/snapshots" | |
} else { | |
url REPO_DEPLOYMENT_URL + "/releases" | |
} | |
} | |
repositories.maven(maven) | |
generatePomFileForPackagesPublication.dependsOn collectArtifacts |
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
# save this file under the ~/.gradle/ folder | |
WORD=world | |
PASSWORD=helo3 | |
REPO_DEPLOYMENT_USERNAME=deployment | |
REPO_DEPLOYMENT_PASSWORD=deployment123 | |
REPO_DEPLOYMENT_URL=http://repo.server.com:8081/nexus/content/repositories |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment