Skip to content

Commit 7565061

Browse files
author
Caitlin Bales (MSFT)
committed
Add uploadArchives task
1 parent ddfb04b commit 7565061

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

build.gradle

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
apply plugin: 'java-library'
1111
apply plugin: 'java'
1212
apply plugin: 'eclipse'
13+
apply plugin: 'maven'
1314
apply plugin: 'maven-publish'
1415

1516
// In this section you declare where to find the dependencies of your project
@@ -53,3 +54,61 @@ task sourceJar(type: Jar) {
5354
from sourceSets.main.allJava
5455
}
5556

57+
def getVersionCode() {
58+
return mavenMajorVersion.toInteger() * 10000 + mavenMinorVersion.toInteger() * 100 + mavenPatchVersion.toInteger()
59+
}
60+
61+
def getVersionName() {
62+
return "${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}"
63+
}
64+
65+
uploadArchives {
66+
67+
def bintrayUsername = ""
68+
69+
def bintrayApikey = ""
70+
71+
if (project.rootProject.file('local.properties').exists()) {
72+
73+
Properties properties = new Properties()
74+
75+
properties.load(project.rootProject.file('local.properties').newDataInputStream())
76+
77+
bintrayUsername = properties.getProperty('bintray.user')
78+
79+
bintrayApikey = properties.getProperty('bintray.apikey')
80+
81+
}
82+
83+
configuration = configurations.archives
84+
85+
repositories.mavenDeployer {
86+
87+
pom {
88+
89+
setGroupId project.mavenGroupId
90+
91+
setArtifactId project.mavenArtifactId
92+
93+
setVersion getVersionName()
94+
95+
}
96+
97+
repository (url: project.mavenRepoUrl) {
98+
99+
authentication(
100+
101+
// put these values in local file ~/.gradle/gradle.properties
102+
103+
userName: project.hasProperty("bintrayUsername") ? project.bintrayUsername : bintrayUsername,
104+
105+
password: project.hasProperty("bintrayApikey") ? project.bintrayApikey : bintrayApikey
106+
107+
)
108+
109+
}
110+
111+
}
112+
113+
}
114+

0 commit comments

Comments
 (0)