-
Notifications
You must be signed in to change notification settings - Fork 139
/
methods.gradle
126 lines (111 loc) · 4.02 KB
/
methods.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
def compileCompatibility(javaCompile, level) {
configure(javaCompile) {
if (sourceCompatibility.toString() != level.toString()) {
sourceCompatibility = level
targetCompatibility = level
options.fork = true
options.forkOptions.executable =
"${System.properties['java.home']}/../../jdk$level/bin/javac"
}
}
}
def setSourceCompatibility(project, level) { configure(project) {
if (sourceCompatibility.toString() != level.toString()) {
tasks.withType(JavaCompile) { javaCompile ->
compileCompatibility(javaCompile, level)
}
sourceCompatibility = level
targetCompatibility = level
}
def langLevel = 'JDK_' + level.toString().replace('.', '_')
idea.module.iml { withXml {
it.asNode().component.find {
it.@name == 'NewModuleRootManager'
}.@LANGUAGE_LEVEL = langLevel
} }
} }
def applyJpsg() {
apply plugin: 'jpsg'
idea.module {
excludeDirs = [file('.gradle')]
['classes', 'dependency-cache', 'docs', 'java-compiler', 'libs', 'reports', 'resources',
'test-results', 'tmp'].each { excludeDirs << file("$buildDir/$it") }
}
}
def configurePublishing(project, generateJavadoc = true) { configure(project) {
apply plugin: 'signing'
apply plugin: 'maven'
group = 'com.koloboke'
task sourcesJar(type: Jar, dependsOn: classes) {
classifier 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar) {
classifier 'javadoc'
if (generateJavadoc)
from javadoc
}
artifacts {
archives sourcesJar
archives javadocJar
}
ext {
if (!project.hasProperty('sonatypeUrl'))
sonatypeUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
if (!project.hasProperty('sonatypeUsername')) sonatypeUsername = ''
if (!project.hasProperty('sonatypePassword')) sonatypePassword = ''
}
ext.isReleaseVersion = !version.endsWith('SNAPSHOT')
signing {
required { isReleaseVersion && gradle.taskGraph.hasTask('uploadArchives') }
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: sonatypeUrl) {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
}
}
}
def installer = install.repositories.mavenInstaller
def deployer = uploadArchives.repositories.mavenDeployer
project.ext.poms = [installer, deployer]*.pom
poms*.whenConfigured { pom ->
pom.dependencies.removeAll { dep -> dep.scope == 'test' }
pom.project {
url = 'https://github.com/leventov/Koloboke'
inceptionYear = '2013'
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
scm {
url = 'https://github.com/leventov/Koloboke'
connection = 'scm:git:git://github.com/leventov/Koloboke'
developerConnection = 'scm:git:git://github.com/leventov/Koloboke'
}
developers {
developer {
id = 'leventov'
name = 'Roman Leventov'
email = 'leventov@ya.ru'
url = 'http://www.leventov.ru'
}
}
issueManagement {
system = 'GitHub'
url = 'https://github.com/leventov/Koloboke/issues'
}
}
}
} }
ext.setSourceCompatibility = this.&setSourceCompatibility
ext.compileCompatibility = this.&compileCompatibility
ext.applyJpsg = this.&applyJpsg
ext.configurePublishing = this.&configurePublishing