-
Notifications
You must be signed in to change notification settings - Fork 5
/
mavenCentralPublish.gradle
111 lines (96 loc) · 3.38 KB
/
mavenCentralPublish.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/* Maven publish - start */
task sourcesJar(type: Jar) {
classifier "sources"
from sourceSets.main.allJava
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier "javadoc"
from javadoc.destinationDir
}
if (project.hasProperty('user') && project.hasProperty('password') && project.hasProperty('deployVersion')) {
// snapshot version differs from normal version
String versionString = project.getProperty('deployVersion')
signing {
required { !versionString.endsWith('SNAPSHOT') }
if (required)
sign(publishing.publications)
}
publishing {
publications {
mavenJava(MavenPublication) {
versionMapping {
// resolves dynamic versioning to current version number
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
description = 'Elaborated data model to model energy systems with a high granularity @ the Institute of Energy Systems, Energy Efficiency and Energy Economics (ie3) @ TU Dortmund University'
name = 'Power System Data Model'
url = 'https:github.com/ie3-institute/PowerSystemDatamodel'
organization {
name = 'Institute of Energy Systems, Energy Efficiency and Energy Economics (ie3)/TU Dortmund University'
url = 'https:www.ie3.tu-dortmund.de/'
}
issueManagement {
system = 'GitHub'
url = 'https:github.com/ie3-institute/PowerSystemDataModel/issues'
}
licenses {
license {
name = 'BSD 3-Clause License'
url = 'https:github.com/ie3-institute/PowerSystemDataModel/blob/master/LICENSE'
}
}
developers {
developer {
organization = "Institute of Energy Systems, Energy Efficiency and Energy Economics (ie3)/TU Dortmund University"
organizationUrl = "https:ie3.etit.tu-dortmund.de"
}
}
scm {
connection = 'scm:git:git:github.com/ie3-institute/PowerSystemDataModel.git'
developerConnection = 'scm:git:ssh:github.com:ie3-institute/PowerSystemDataModel.git'
url = 'https:github.com/ie3-institute/PowerSystemDataModel'
}
}
removeTestDependenciesFromPom(pom)
groupId group
artifactId 'PowerSystemDataModel'
version versionString
from components.java
artifact sourcesJar
artifact javadocJar
}
}
repositories {
maven {
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = versionString.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username project.getProperty('user')
password project.getProperty('password')
}
}
}
}
model {
tasks.generatePomFileForMavenJavaPublication {
destination = file("$buildDir/generated-pom.xml")
}
}
}
def removeTestDependenciesFromPom(pom) {
pom.withXml {
def root = asNode()
// eliminate test-scoped dependencies (no need in maven central POMs)
root.dependencies.removeAll { dep ->
dep.scope == "test"
}
}
}
/* Maven publish - end */