Skip to content

Commit 7c40798

Browse files
committed
Improved gradle build files
1 parent 4363e97 commit 7c40798

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

build.gradle

+9-9
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@ allprojects {
252252
}
253253
}
254254
normal(MavenPublication) {
255-
from project.components.java
256-
artifact project.tasks.javadocJar
257-
artifact project.tasks.sourcesJar
255+
from components.java
256+
artifact tasks.javadocJar
257+
artifact tasks.sourcesJar
258258
suppressAllPomMetadataWarnings()
259259
}
260260
}
@@ -294,7 +294,7 @@ allprojects {
294294

295295
// workaround for publishing gradle metadata https://github.com/bintray/gradle-bintray-plugin/issues/229
296296
//noinspection UnnecessaryQualifiedReference
297-
project.tasks.withType(com.jfrog.bintray.gradle.tasks.BintrayUploadTask) {
297+
tasks.withType(com.jfrog.bintray.gradle.tasks.BintrayUploadTask) {
298298
doFirst {
299299
publishing.publications.withType(MavenPublication).each { publication ->
300300
def moduleFile = new File(new File(new File(project.buildDir, 'publications'), publication.name), 'module.json')
@@ -313,13 +313,13 @@ allprojects {
313313
publications {
314314
shaded(MavenPublication) {
315315
artifactId project.name + '-' + project.shadedAppendix
316-
artifact project.tasks.shadowJar
317-
artifact project.tasks.javadocJar
318-
artifact project.tasks.sourcesJar
316+
artifact tasks.shadowJar
317+
artifact tasks.javadocJar
318+
artifact tasks.sourcesJar
319319
pom.withXml {
320320
def dependenciesNode = asNode().appendNode('dependencies')
321321

322-
project.configurations.api.allDependencies.each {
322+
configurations.api.allDependencies.each {
323323
def dependencyNode = dependenciesNode.appendNode('dependency')
324324
dependencyNode.appendNode('groupId', it.group)
325325
dependencyNode.appendNode('artifactId', it.name)
@@ -347,7 +347,7 @@ features.each { feature ->
347347
rootDependencyNode.appendNode('version', project.version)
348348
rootDependencyNode.appendNode('scope', 'compile')
349349

350-
project.configurations.getByName(feature + 'Implementation').allDependencies.each {
350+
configurations.getByName(feature + 'Implementation').allDependencies.each {
351351
def dependencyNode = dependenciesNode.appendNode('dependency')
352352
dependencyNode.appendNode('groupId', it.group)
353353
dependencyNode.appendNode('artifactId', it.name)

gradle/japicc.gradle

+13-13
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ task japicc {
55
workingDir = new File(project.buildDir, 'japicc')
66
}
77
}
8-
project.tasks.check.dependsOn(japicc)
8+
tasks.check.dependsOn(japicc)
99

1010
if (rootProject.tasks.findByName('japiccDownload') == null) {
1111
rootProject.tasks.create('japiccDownload') {
@@ -44,7 +44,7 @@ task japiccNonImpl {
4444
description 'List non impl interfaces'
4545

4646
ext {
47-
nonImplFile = new File(project.tasks.japicc.workingDir, 'non-impl')
47+
nonImplFile = new File(tasks.japicc.workingDir, 'non-impl')
4848
}
4949

5050
inputs.files sourceSets.main.java
@@ -128,11 +128,11 @@ def addCheck(Jar jarTask) {
128128
String archiveAppendix = jarTask.archiveAppendix.getOrElse('')
129129
String taskName = 'japiccCheck' + archiveAppendix.capitalize()
130130

131-
def task = project.tasks.create(taskName) {
131+
def task = tasks.create(taskName) {
132132

133133
group 'japicc'
134134
description 'Checks for binary and source incompatibility.'
135-
dependsOn rootProject.tasks.japiccDownload, project.tasks.japiccNonImpl
135+
dependsOn rootProject.tasks.japiccDownload, tasks.japiccNonImpl
136136

137137
String archiveName = archiveBaseName
138138
if (archiveAppendix != '') {
@@ -141,9 +141,9 @@ def addCheck(Jar jarTask) {
141141

142142
String lastSemVer = project.prevVersion
143143
String lastJarName = archiveName + '-' + lastSemVer + '.jar'
144-
File lastJar = new File(project.tasks.japicc.workingDir, lastJarName)
144+
File lastJar = new File(tasks.japicc.workingDir, lastJarName)
145145

146-
File report = new File(new File(new File(new File(project.tasks.japicc.workingDir, 'compat_reports'),
146+
File report = new File(new File(new File(new File(tasks.japicc.workingDir, 'compat_reports'),
147147
archiveName), lastSemVer + '_to_' + project.version), 'compat_report.html')
148148

149149
inputs.files jarTask
@@ -165,7 +165,7 @@ def addCheck(Jar jarTask) {
165165
lastJar.parentFile.mkdirs()
166166
if (!lastJar.exists()) {
167167
String path = project.group.replace('.', '/') + '/' + archiveName + '/' + lastSemVer + '/' + lastJarName
168-
new URL(project.repositories.mavenCentral().url.toString() + path)
168+
new URL(repositories.mavenCentral().url.toString() + path)
169169
.withInputStream { i -> lastJar.withOutputStream { it << i } }
170170
}
171171
}
@@ -177,23 +177,23 @@ def addCheck(Jar jarTask) {
177177
def command = ['perl', rootProject.tasks.japiccDownload.executable.getPath(), '-lib', archiveName,
178178
'-skip-internal-packages', 'com.hivemq.client.internal',
179179
'-skip-internal-packages', 'com.hivemq.shaded',
180-
'-non-impl', project.tasks.japiccNonImpl.nonImplFile.getPath(),
180+
'-non-impl', tasks.japiccNonImpl.nonImplFile.getPath(),
181181
'-check-annotations', '-s',
182182
lastJar.getPath(), jarTask.archiveFile.get().getAsFile().getPath()]
183183

184-
Process process = new ProcessBuilder(command).directory(project.tasks.japicc.workingDir).start()
184+
Process process = new ProcessBuilder(command).directory(tasks.japicc.workingDir).start()
185185
int returnCode = process.waitFor()
186186
if (returnCode != 0) {
187187
throw new GradleException('Binary or source incompatibilities, code ' + returnCode)
188188
}
189189
}
190190
}
191-
project.tasks.japicc.dependsOn(task)
191+
tasks.japicc.dependsOn(task)
192192
}
193193

194194
afterEvaluate {
195-
addCheck(project.tasks.jar)
196-
if (project.plugins.hasPlugin('com.github.johnrengelman.shadow')) {
197-
addCheck(project.tasks.shadowJar)
195+
addCheck(tasks.jar)
196+
if (plugins.hasPlugin('com.github.johnrengelman.shadow')) {
197+
addCheck(tasks.shadowJar)
198198
}
199199
}

0 commit comments

Comments
 (0)