Created
November 2, 2014 04:01
-
-
Save eddumelendez/803c1e990736f8683b0c to your computer and use it in GitHub Desktop.
Gradle script to upload java components into Repository Manager
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
apply plugin: 'java' | |
apply plugin: 'maven-publish' | |
apply plugin: 'distribution' | |
archivesBaseName = 'my-component' | |
group = 'io.eddumelendez.gradle' | |
version = '1.0' | |
sourceCompatibility = 1.7 | |
task sourcesJar(type: Jar) { | |
baseName 'my-component' | |
classifier 'sources' | |
from sourceSets.main.allSource | |
} | |
task javadocJar(type: Jar, dependsOn: javadoc) { | |
baseName 'my-component' | |
classifier 'javadoc' | |
from javadoc.destinationDir | |
} | |
artifacts { | |
archives sourcesJar | |
archives javadocJar | |
} | |
distributions { | |
main { | |
baseName = archivesBaseName | |
contents { | |
from { libsDir } | |
} | |
} | |
docs { | |
baseName = "$archivesBaseName-docs" | |
contents { | |
from(libsDir) { | |
include sourcesJar.archiveName | |
include javadocJar.archiveName | |
} | |
} | |
} | |
} | |
ext { | |
artifactoryBaseUrl = 'http://localhost:8081/artifactory' | |
artifactorySnapshotRepoUrl = "$artifactoryBaseUrl/libs-snapshot-local" | |
artifactoryReleaseRepoUrl = "$artifactoryBaseUrl/libs-release-local" | |
artifactoryUsername = "admin" | |
artifactoryPassword = "password" | |
} | |
publishing { | |
publications { | |
plugin(MavenPublication) { | |
from components.java | |
artifactId 'my-component' | |
artifact sourcesJar | |
artifact javadocJar | |
} | |
} | |
repositories { | |
mavenLocal() | |
maven { | |
name 'remoteArtifactory' | |
url project.version.endsWith('-SNAPSHOT') ? artifactorySnapshotRepoUrl : artifactoryReleaseRepoUrl | |
credentials { | |
username = artifactoryUsername | |
password = artifactoryPassword | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why won't you use Artifactory Gradle Plugin? It takes care of everything.