11plugins {
2- // code formatting
3- id " com.diffplug.gradle.spotless" version " 1.3.0"
4- // bintray uploading
5- id " com.jfrog.bintray" version " 1.3.1"
2+ id ' com.diffplug.blowdryer'
3+ id ' com.diffplug.spotless-changelog'
64}
75
86repositories {
97 mavenCentral()
10- // SNAPSHOT versions are free to rely on other SNAPSHOT libraries
11- if (project. version. endsWith(' -SNAPSHOT' )) {
12- maven { url ' https://oss.sonatype.org/content/repositories/snapshots/' }
13- configurations. all { resolutionStrategy. cacheChangingModulesFor 0 , ' seconds' }
14- }
158}
169
17- // ////////
18- // JAVA //
19- // ////////
20- apply plugin : ' java'
21- sourceCompatibility = VER_JAVA
22- targetCompatibility = VER_JAVA
10+ apply from : 干. file(' base/java.gradle' )
11+ apply from : 干. file(' spotless/java.gradle' )
12+ apply plugin : ' java-library'
2313
24- dependencies {
25- testCompile " junit:junit:${ VER_JUNIT} "
26- }
27-
28- // ///////////
29- // ECLIPSE //
30- // ///////////
31- apply plugin : ' eclipse'
32- eclipse {
33- classpath {
34- downloadSources true
35- downloadJavadoc true
36- }
37- jdt {
38- sourceCompatibility VER_JAVA
39- targetCompatibility VER_JAVA
40- }
41- }
42- // always create fresh projects
43- tasks. eclipse. dependsOn(cleanEclipse)
44-
45- // //////////
46- // FORMAT //
47- // //////////
48- apply plugin : ' com.diffplug.gradle.spotless'
49- spotless {
50- java {
51- licenseHeaderFile ' spotless.license.java' // License header file
52- importOrderFile ' spotless.importorder' // An import ordering file, exported from Eclipse
53- eclipseFormatFile ' spotless.eclipseformat.xml' // XML file dumped out by the Eclipse formatter
54- // Eclipse formatter puts excess whitespace after lambda blocks
55- // funcThatTakesLambdas(x -> {} , y -> {} ) // what Eclipse does
56- // funcThatTakesLambdas(x -> {}, y -> {}) // what I wish Eclipse did
57- custom ' Lambda fix' , { it. replace(' } )' , ' })' ). replace(' } ,' , ' },' ) }
58- }
59- format ' misc' , {
60- target ' **/.gitignore' , ' **/*.gradle' , ' **/*.md' , ' **/*.sh'
61- indentWithTabs()
62- trimTrailingWhitespace()
63- endWithNewline()
64- }
65- freshmark {}
66- }
6714
68- // ////////////
69- // FINDBUGS //
70- // ////////////
71- apply plugin : ' findbugs'
72- findbugs {
73- toolVersion = VER_FINDBUGS
74- sourceSets = [sourceSets. main] // don't check the test code
75- ignoreFailures = false // bug free or it doesn't ship!
76- reportsDir = file(' build/findbugs' )
77- effort = ' max' // min|default|max
78- reportLevel = ' low' // low|medium|high (low = sensitive to even minor mistakes)
79- omitVisitors = [] // bugs that we want to ignore
80- }
81- // HTML instead of XML
82- tasks. withType(FindBugs ) {
83- reports {
84- xml. enabled = false
85- html. enabled = true
86- }
87- }
88- // we'll want the findbugs annotations (they don't have a 3.0.1 version)
8915dependencies {
90- compile ' com.google.code.findbugs:annotations:3.0.0'
91- compile ' com.google.code.findbugs:jsr305:3.0.0'
92- }
93-
94- // /////////
95- // MAVEN //
96- // /////////
97- apply plugin : ' maven-publish'
98-
99- task sourcesJar (type : Jar ) {
100- classifier = ' sources'
101- from sourceSets. main. allJava
16+ testImplementation ' junit:junit:4.13.2'
10217}
10318
104- // Where it's possible to name parameters and methods clearly enough
105- // that javadoc is not necessary, why make the code bigger?
106- //
107- // Thus, no javadoc warnings.
108- def makeLink = { url , text -> " <a href=\" ${ url} \" style=\" text-transform: none;\" >${ text} </a>" }
109- def javadocInfo = ' <h2>' + makeLink(" https://github.com/${ org} /${ name} " , " ${ group} :${ name} :${ version} " ) +
110- ' by ' + makeLink(' http://www.diffplug.com' , ' DiffPlug' ) + ' </h2>'
111- javadoc {
112- options. addStringOption(' Xdoclint:none' , ' -quiet' )
113- options. header javadocInfo
114- options. footer javadocInfo
115- options. links(' https://docs.oracle.com/javase/8/docs/api/' )
116- }
117-
118- task javadocJar (type : Jar , dependsOn : javadoc) {
119- classifier = ' javadoc'
120- from javadoc. destinationDir
121- }
122-
123- // //////////////
124- // PUBLISHING //
125- // //////////////
126- def isSnapshot = project. version. endsWith(' -SNAPSHOT' )
127- // pulls the credentials from either the environment variable or gradle.properties
128- def cred = {
129- if (System . env[it] != null ) {
130- return System . env[it]
131- } else if (project. hasProperty(it)) {
132- return project[it]
133- } else {
134- return ' unknown_' + it
135- }
136- }
137-
138- publishing {
139- publications {
140- mavenJava(MavenPublication ) {
141- from components. java
142- artifact sourcesJar
143- artifact javadocJar
144- pom. withXml {
145- // findbugs annotations should have scope "provided"
146- asNode(). dependencies. ' *' . findAll() { it. groupId. text() == ' com.google.code.findbugs' }. each() { it. scope* . value = ' provided' }
147- // add MavenCentral requirements to the POM
148- asNode(). children(). last() + {
149- resolveStrategy = Closure . DELEGATE_FIRST
150- name project. name
151- description project. description
152- url " https://github.com/${ project.org} /${ project.name} "
153- scm {
154- url " https://github.com/${ project.org} /${ project.name} "
155- connection " scm:git:git://github.com/${ project.org} /${ project.name} "
156- developerConnection
" scm:git:ssh:[email protected] /${ project.org} /${ project.name} " 157- }
158- licenses {
159- license {
160- name ' The Apache Software License, Version 2.0'
161- url ' http://www.apache.org/license/LICENSE-2.0.txt'
162- distribution ' repo'
163- }
164- }
165- developers {
166- developer {
167- id ' nedtwigg'
168- name ' Ned Twigg'
169- 170- }
171- }
172- }
173- }
174- }
175- }
176- if (isSnapshot) {
177- // upload snapshots to oss.sonatype.org
178- repositories { maven {
179- url = ' https://oss.sonatype.org/content/repositories/snapshots'
180- credentials {
181- username = cred(' nexus_user' )
182- password = cred(' nexus_pass' )
183- }
184- } }
185- }
186- }
187-
188- if (! isSnapshot) {
189- // upload releases to bintray and then mavenCentral
190- bintray {
191- user = cred(' bintray_user' )
192- key = cred(' bintray_pass' )
193- publications = [' mavenJava' ]
194- publish = true
195- pkg {
196- repo = ' opensource'
197- name = project. name
198- userOrg = project. org
199- version {
200- name = project. version
201- mavenCentralSync {
202- user = cred(' nexus_user' )
203- password = cred(' nexus_pass' )
204- }
205- }
206- }
207- }
208-
209- publish. dependsOn(bintrayUpload)
210- bintrayUpload. dependsOn([' generatePomFileForMavenJavaPublication' , jar, sourcesJar, javadocJar])
211- }
212-
213- // helps external scripts detect version
214- task printVersion << {
215- println version
216- }
19+ apply from : 干. file(' base/maven.gradle' )
20+ apply from : 干. file(' base/sonatype.gradle' )
0 commit comments