You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build.gradle 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*
  2. * Copyright (c) 2006-2017 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  5. * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
  6. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
  7. * permit persons to whom the Software is furnished to do so, subject to the following conditions:
  8. *
  9. * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
  10. * Software.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  13. * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
  14. * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  15. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16. */
  17. subprojects {
  18. apply plugin: 'com.dmdirc.git-version'
  19. apply plugin: 'java'
  20. apply plugin: 'findbugs'
  21. apply plugin: 'pmd'
  22. apply plugin: 'idea'
  23. apply from: '../gradle/coverage.gradle'
  24. idea {
  25. module {
  26. sourceDirs += file('src/main/generated')
  27. testSourceDirs += file('src/test/generated_tests')
  28. generatedSourceDirs = [file('src/main/generated'), file('src/test/generated_tests')]
  29. }
  30. }
  31. configurations {
  32. provided
  33. bundle {
  34. extendsFrom provided
  35. }
  36. compile {
  37. extendsFrom bundle
  38. }
  39. }
  40. sourceCompatibility = 1.8
  41. targetCompatibility = 1.8
  42. repositories {
  43. mavenCentral()
  44. maven { url 'https://artifactory.dmdirc.com/releases' }
  45. maven { url 'https://artifactory.dmdirc.com/snapshots' }
  46. }
  47. dependencies {
  48. provided group: 'com.dmdirc', name: 'client', version: '+', changing: true
  49. compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
  50. compile group: 'com.squareup.dagger', name: 'dagger-compiler', version: '1.2.4'
  51. testCompile group: 'junit', name: 'junit', version: '4.12'
  52. testCompile group: 'org.mockito', name: 'mockito-core', version: '1.10.19'
  53. pmd group: 'net.sourceforge.pmd', name: 'pmd-core', version: '5.4.1'
  54. pmd group: 'net.sourceforge.pmd', name: 'pmd-java', version: '5.4.1'
  55. }
  56. task copyPluginConfig(type: Copy) {
  57. from 'plugin.config'
  58. into "$buildDir"
  59. }
  60. task updatePluginConfig(dependsOn: copyPluginConfig) << {
  61. def targetFile = new File(buildDir, 'plugin.config')
  62. targetFile << "\n\nversion:\n number=${project.version}"
  63. targetFile << "\n\nbuildenv:\n"
  64. def compileConfiguration = project.configurations.getByName("compile")
  65. def resolvedConfiguration = compileConfiguration.resolvedConfiguration
  66. def resolvedArtifacts = resolvedConfiguration.resolvedArtifacts
  67. resolvedArtifacts.each { dp ->
  68. def version = dp.moduleVersion.id
  69. targetFile << " " + version.group + " " + version.name + " " + version.version + "\n"
  70. }
  71. }
  72. pmd {
  73. ruleSets = []
  74. ruleSetFiles = files("$rootDir/etc/pmd/full.xml")
  75. toolVersion = '5.2.3'
  76. ignoreFailures = true
  77. }
  78. pmdMain.doLast {
  79. copy {
  80. from pmd.reportsDir
  81. into "../pmd/"
  82. include "*.html"
  83. rename "main.html", "${project.name}-main.html"
  84. }
  85. }
  86. tasks.withType(FindBugs) {
  87. reports {
  88. html.enabled = true
  89. xml.enabled = false
  90. }
  91. }
  92. findbugs {
  93. reportLevel = 'low'
  94. effort = 'max'
  95. ignoreFailures = true
  96. }
  97. jar {
  98. from("$buildDir/plugin.config") {
  99. into 'META-INF'
  100. }
  101. from { configurations.bundle.minus(configurations.provided).collect { it.isDirectory() ? it : zipTree(it) } } {
  102. exclude 'META-INF/*'
  103. }
  104. }
  105. jar.doLast {
  106. copy {
  107. from jar.archivePath
  108. into "../dist/"
  109. rename ".*", "${project.name}.jar"
  110. }
  111. copy {
  112. from jar.archivePath
  113. into "../dist-versioned/"
  114. rename ".*", "${project.name}-${project.version}.jar"
  115. }
  116. }
  117. jar.outputs.file "../dist/${project.name}.jar"
  118. jar.outputs.file "../dist-versioned/${project.name}-${project.version}.jar"
  119. jar.dependsOn updatePluginConfig
  120. }
  121. allprojects {
  122. configurations.all {
  123. resolutionStrategy.cacheDynamicVersionsFor 2, 'minutes'
  124. resolutionStrategy.cacheChangingModulesFor 2, 'minutes'
  125. }
  126. }
  127. buildscript {
  128. repositories {
  129. mavenCentral()
  130. maven { url 'https://artifactory.dmdirc.com/releases' }
  131. maven { url 'https://artifactory.dmdirc.com/snapshots' }
  132. }
  133. dependencies {
  134. classpath group: 'com.dmdirc', name: 'git-version', version: '1.0'
  135. classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.6.3'
  136. }
  137. }
  138. task wrapper(type: Wrapper) {
  139. gradleVersion = '3.1'
  140. }
  141. subprojects.each { evaluationDependsOn it.path }
  142. task jars(dependsOn: subprojects*.jar)
  143. task tests(dependsOn: subprojects*.test)
  144. tasks.dependencies.dependsOn subprojects*.tasks.dependencies
  145. def plugin(name) {
  146. if (allprojects.find { it.name == name }) {
  147. project(name)
  148. } else if (allprojects.find { it.name == 'plugins:' + name }) {
  149. project('plugins:' + name)
  150. } else if (allprojects.find { it.name == 'modules:plugins:' + name }) {
  151. project('modules:plugins:' + name)
  152. } else {
  153. println "Couldn't find project $name"
  154. }
  155. }
  156. apply from: 'gradle/coveralls.gradle'