@@ -15,9 +15,11 @@ buildscript {
1515}
1616
1717plugins {
18- id " com.github.hierynomus.license " version " 0.12 .1"
18+ id " com.jfrog.bintray " version " 1.7 .1"
1919}
2020
21+ apply from : ' gradle/resolveDependencies.gradle'
22+
2123ext. githubProjectName = rootProject. name // Change if github project name is not the same as the root project's name
2224
2325defaultTasks " clean" , " build"
@@ -37,8 +39,7 @@ subprojects {
3739 apply plugin : " java"
3840 apply plugin : " maven"
3941
40- sourceCompatibility = 1.8
41- targetCompatibility = 1.8
42+ sourceCompatibility = targetCompatibility = 1.8
4243
4344 // ======== code quality ========
4445 apply plugin : " checkstyle"
@@ -49,165 +50,26 @@ subprojects {
4950 apply plugin : " de.thetaphi.forbiddenapis"
5051 apply plugin : " com.diffplug.gradle.spotless"
5152
52- // compiler
53- compileJava {
54- options. compilerArgs << " -Xlint"
55- }
56-
57- // jacoco
58- jacocoTestReport {
59- reports {
60- xml. enabled false
61- csv. enabled false
62- }
63- }
64-
65- // checkstyle
66- checkstyle {
67- toolVersion = " 7.1.2"
68- configFile = rootProject. file(' config/checkstyle/checkstyle.xml' )
69- }
70- checkstyleTest {
71- configFile = rootProject. file(" config/checkstyle/checkstyle-test.xml" )
72- }
53+ // code quality configuration
54+ apply from : " ${ rootProject.projectDir} /gradle/quality/checkstyle.gradle"
55+ apply from : " ${ rootProject.projectDir} /gradle/quality/findbugs.gradle"
56+ apply from : " ${ rootProject.projectDir} /gradle/quality/pmd.gradle"
57+ apply from : " ${ rootProject.projectDir} /gradle/quality/cpd.gradle"
58+ apply from : " ${ rootProject.projectDir} /gradle/quality/jacoco.gradle"
59+ apply from : " ${ rootProject.projectDir} /gradle/quality/forbiddenapis.gradle"
60+ apply from : " ${ rootProject.projectDir} /gradle/quality/spotless.gradle"
7361
74- // workaround: see https://issues.gradle.org/browse/GRADLE-2888
75- task verifyNoCheckstyleWarningsInMain {
76- group = " verification"
77- description = " Fail if checkstyleMain result contains warnings"
78- doLast {
79- File warningsFile = file(' build/reports/checkstyle/main.xml' )
80- if (warningsFile. exists() && warningsFile. text. contains(" <error " )) {
81- throw new GradleException (" There were checkstyle warnings! For more info check $warningsFile " )
82- }
83- }
84- }
85- checkstyleMain. finalizedBy verifyNoCheckstyleWarningsInMain
86- task verifyNoCheckstyleWarningsInTest {
87- group = " verification"
88- description = " Fail if checkstyleTest result contains warnings"
89- doLast {
90- File warningsFile = file(' build/reports/checkstyle/test.xml' )
91- if (warningsFile. exists() && warningsFile. text. contains(" <error " )) {
92- throw new GradleException (" There were checkstyle warnings! For more info check $warningsFile " )
93- }
94- }
95- }
96- checkstyleTest. finalizedBy verifyNoCheckstyleWarningsInTest
97-
98- // findbugs
99- findbugs {
100- effort = " max"
101- includeFilter = file(" ../config/findbugs/includeFilter.xml" )
102- excludeFilter = file(" ../config/findbugs/excludeFilter.xml" )
103- }
104- tasks. withType(FindBugs ) {
105- reports {
106- xml. enabled = false
107- html. enabled = true
108- }
109- }
110-
111- // pmd
112- pmd {
113- consoleOutput = true
114- }
115- pmdMain {
116- ruleSetFiles = files(" ../config/pmd/pmd-settings.xml" )
117- ruleSets = [] // To apply only the custom rules
118- }
119- pmdTest {
120- ruleSetFiles = files(" ../config/pmd/pmd-settings-test.xml" )
121- ruleSets = [] // To apply only the custom rules
122- }
123- cpdCheck {
124- reports {
125- text. enabled = true
126- xml. enabled = false
127- }
128- source = sourceSets. main. allJava // only main source
129- ignoreFailures = true
130- }
62+ apply from : " ${ rootProject.projectDir} /gradle/sourceArtifact.gradle"
63+ apply from : " ${ rootProject.projectDir} /gradle/bintray.gradle"
13164
132- // forbiddenapis
133- forbiddenApisMain {
134- bundledSignatures + = [
135- ' jdk-system-out' ,
136- ' jdk-unsafe-' + project. sourceCompatibility,
137- ' jdk-internal-' + project. sourceCompatibility
138- ]
139- signaturesFiles = fileTree(dir : " ../config/forbiddenapis" , include : " *.txt" )
140- ignoreFailures = false
141- }
142- forbiddenApisTest {
143- bundledSignatures + = [
144- ' jdk-system-out' ,
145- ' jdk-internal-' + project. sourceCompatibility
146- ]
147- ignoreFailures = false
65+ // compiler
66+ tasks. withType(AbstractCompile ) each {
67+ it. options. encoding = " UTF-8"
14868 }
149-
150- // spotless
151- spotless {
152- java {
153- licenseHeaderFile ' ../config/spotless/spotless.license.java'
154- importOrderFile ' ../config/spotless/spotless.importorder'
155- eclipseFormatFile ' ../config/spotless/spotless.eclipseformat.xml'
156-
157- // Eclipse formatter screws up long literals with underscores inside of annotations (see issue #14)
158- // @Max(value = 9_999_999 L) // what Eclipse does
159- // @Max(value = 9_999_999L) // what I wish Eclipse did
160- custom ' Long literal fix' , { it. replaceAll(' ([0-9_]+) [Ll]' , ' $1L' ) }
161-
162- // Eclipse formatter puts excess whitespace after lambda blocks
163- // funcThatTakesLambdas(x -> {} , y -> {} ) // what Eclipse does
164- // funcThatTakesLambdas(x -> {}, y -> {}) // what I wish Eclipse did
165- custom ' Lambda fix' , { it. replace(' } )' , ' })' ). replace(' } ,' , ' },' ) }
166-
167- indentWithTabs()
168- endWithNewline()
169-
170- customReplaceRegex ' Add space before comment asterisk' , ' ^(\\ t*)\\ *' , ' $1 *'
171- // customReplaceRegex 'Remove indent before line comment', '^\\t*//', '//'
172- }
173-
174- // this will create two tasks: spotlessMiscCheck and spotlessMiscApply
175- format ' misc' , {
176- // target determines which files this format will apply to
177- // - if you pass a string or a list of strings, they will be treated
178- // as 'include' parameters to a fileTree in the root directory
179- // - if you pass a FileCollection, it will pass through untouched
180- // e.g. project.files('build.gradle', 'settings.gradle')
181- // - if you pass anything else, it will be sent to project.files(yourArg)
182- target ' **/*.gradle' , ' **/*.md' , ' **/.gitignore'
183-
184- // spotless has built-in rules for the most basic formatting tasks
185- indentWithTabs() // or spaces. Takes an integer argument if you don't like 4
186- endWithNewline()
187- }
69+ compileJava {
70+ options. compilerArgs << " -Xlint"
18871 }
18972
190-
191- // ======== create source and javadoc bundles ========
192- task sourcesJar(type : Jar , dependsOn : classes) {
193- classifier = " sources"
194- from sourceSets. main. allSource
195- }
196-
197- task javadocJar(type : Jar , dependsOn : javadoc) {
198- classifier = " javadoc"
199- from javadoc. destinationDir
200- }
201-
202- javadoc {
203- failOnError = false
204- }
205-
206- artifacts {
207- archives sourcesJar
208- archives javadocJar
209- }
210-
21173 configurations {
21274 deployerJars
21375 }
@@ -228,19 +90,6 @@ subprojects {
22890 }
22991
23092
231- // ======== License =======
232- apply plugin : " license"
233- license {
234- ext. year = Calendar . getInstance(). get(Calendar . YEAR )
235- header rootProject. file(" copyright/HEADER" )
236- strictCheck true
237- mapping {
238- java = " SLASHSTAR_STYLE"
239- }
240- exclude " **/*.json"
241- }
242-
243-
24493 // ======== Publishing =======
24594 apply plugin : ' maven-publish'
24695 publishing {
@@ -278,29 +127,8 @@ subprojects {
278127 }
279128 }
280129 }
281-
282- if (project. hasProperty(" bintrayUser" ) && project. hasProperty(" bintrayKey" )) {
283- apply plugin : " com.jfrog.bintray"
284- bintray {
285- user = project. bintrayUser
286- key = project. bintrayKey
287- publications = [" mavenJava" ]
288- pkg {
289- repo = " spar-wings"
290- name = project. name
291- desc = project. description
292- websiteUrl = " https://github.com/dai0304/spar-wings"
293- issueTrackerUrl = " https://github.com/dai0304/spar-wings/issues"
294- vcsUrl = " https://github.com/dai0304/spar-wings.git"
295- licenses = [" Apache-2.0" ]
296- labels = [" AWS" , " Spring framework" ]
297- }
298- }
299- }
300130}
301131
302-
303-
304132// ======== wrapper ========
305133task wrapper(type : Wrapper ) {
306134 gradleVersion = " 2.12"
0 commit comments