common.gradle 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. //
  2. // This file is to be applied to every subproject.
  3. //
  4. apply plugin: 'java-library'
  5. apply plugin: 'groovy'
  6. apply plugin: 'maven-publish'
  7. apply plugin: 'signing'
  8. apply plugin: 'eclipse'
  9. apply plugin: 'checkstyle'
  10. eclipse.jdt.file.withProperties { props ->
  11. props.setProperty "org.eclipse.jdt.core.circularClasspath", "warning"
  12. }
  13. group = 'org.jmonkeyengine'
  14. version = jmeFullVersion
  15. java {
  16. sourceCompatibility = JavaVersion.VERSION_1_8
  17. targetCompatibility = JavaVersion.VERSION_1_8
  18. }
  19. tasks.withType(JavaCompile) { // compile-time options:
  20. //options.compilerArgs << '-Xlint:deprecation' // to show deprecation warnings
  21. options.compilerArgs << '-Xlint:unchecked'
  22. options.encoding = 'UTF-8'
  23. if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_1_10)) {
  24. options.release = 8
  25. }
  26. }
  27. repositories {
  28. mavenCentral()
  29. flatDir {
  30. dirs rootProject.file('lib')
  31. }
  32. }
  33. dependencies {
  34. // Adding dependencies here will add the dependencies to each subproject.
  35. testImplementation libs.junit4
  36. testImplementation libs.mokito.core
  37. testImplementation libs.groovy.test
  38. }
  39. // Uncomment if you want to see the status of every test that is run and
  40. // the test output.
  41. /*
  42. test {
  43. testLogging {
  44. events "passed", "skipped", "failed", "standardOut", "standardError"
  45. }
  46. }
  47. */
  48. jar {
  49. manifest {
  50. attributes 'Implementation-Title': 'jMonkeyEngine',
  51. 'Implementation-Version': jmeFullVersion,
  52. 'Automatic-Module-Name': "${project.name.replace("-", ".")}",
  53. 'Created-By': "${JavaVersion.current()} (${System.getProperty("java.vendor")})"
  54. }
  55. }
  56. javadoc {
  57. failOnError = false
  58. options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
  59. options.docTitle = "jMonkeyEngine ${jmeFullVersion} ${project.name} Javadoc"
  60. options.windowTitle = "jMonkeyEngine ${jmeFullVersion} ${project.name} Javadoc"
  61. options.header = "<b>jMonkeyEngine ${jmeFullVersion} ${project.name}</b>"
  62. options.author = "true"
  63. options.use = "true"
  64. options.charSet = "UTF-8"
  65. options.encoding = "UTF-8"
  66. source = sourceSets.main.allJava // main only, exclude tests
  67. }
  68. test {
  69. testLogging {
  70. exceptionFormat = 'full'
  71. }
  72. }
  73. task sourcesJar(type: Jar, dependsOn: classes, description: 'Creates a jar from the source files.') {
  74. archiveClassifier = 'sources'
  75. from sourceSets*.allSource
  76. }
  77. task javadocJar(type: Jar, dependsOn: javadoc, description: 'Creates a jar from the javadoc files.') {
  78. archiveClassifier = 'javadoc'
  79. from javadoc.destinationDir
  80. }
  81. ext.pomConfig = {
  82. name POM_NAME
  83. description POM_DESCRIPTION
  84. url POM_URL
  85. inceptionYear POM_INCEPTION_YEAR
  86. scm {
  87. url POM_SCM_URL
  88. connection POM_SCM_CONNECTION
  89. developerConnection POM_SCM_DEVELOPER_CONNECTION
  90. }
  91. licenses {
  92. license {
  93. name POM_LICENSE_NAME
  94. url POM_LICENSE_URL
  95. distribution POM_LICENSE_DISTRIBUTION
  96. }
  97. }
  98. developers {
  99. developer {
  100. name 'jMonkeyEngine Team'
  101. id 'jMonkeyEngine'
  102. }
  103. }
  104. }
  105. artifacts {
  106. archives jar
  107. archives sourcesJar
  108. if (buildJavaDoc == "true") {
  109. archives javadocJar
  110. }
  111. }
  112. publishing {
  113. publications {
  114. maven(MavenPublication) {
  115. artifact javadocJar
  116. artifact sourcesJar
  117. from components.java
  118. pom {
  119. description = POM_DESCRIPTION
  120. developers {
  121. developer {
  122. id = 'jMonkeyEngine'
  123. name = 'jMonkeyEngine Team'
  124. }
  125. }
  126. inceptionYear = POM_INCEPTION_YEAR
  127. licenses {
  128. license {
  129. distribution = POM_LICENSE_DISTRIBUTION
  130. name = POM_LICENSE_NAME
  131. url = POM_LICENSE_URL
  132. }
  133. }
  134. name = POM_NAME
  135. scm {
  136. connection = POM_SCM_CONNECTION
  137. developerConnection = POM_SCM_DEVELOPER_CONNECTION
  138. url = POM_SCM_URL
  139. }
  140. url = POM_URL
  141. }
  142. version project.version
  143. }
  144. }
  145. repositories {
  146. maven {
  147. name = 'Dist'
  148. url = gradle.rootProject.projectDir.absolutePath + '/dist/maven'
  149. }
  150. // Uploading to Sonatype relies on the existence of 2 properties
  151. // (centralUsername and centralPassword)
  152. // which should be set using -P options on the command line.
  153. maven {
  154. // for uploading release builds to the default repo in Sonatype's OSSRH staging area
  155. credentials {
  156. username = gradle.rootProject.hasProperty('centralUsername') ? centralUsername : 'Unknown user'
  157. password = gradle.rootProject.hasProperty('centralPassword') ? centralPassword : 'Unknown password'
  158. }
  159. name = 'Central'
  160. url = 'https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/'
  161. }
  162. maven {
  163. // for uploading snapshot builds to Sonatype's maven-snapshots repo
  164. credentials {
  165. username = gradle.rootProject.hasProperty('centralUsername') ? centralUsername : 'Unknown user'
  166. password = gradle.rootProject.hasProperty('centralPassword') ? centralPassword : 'Unknown password'
  167. }
  168. name = 'SNAPSHOT'
  169. url = 'https://central.sonatype.com/repository/maven-snapshots/'
  170. }
  171. }
  172. }
  173. publishToMavenLocal.doLast {
  174. println 'published ' + project.getName() + "-${jmeFullVersion} to mavenLocal"
  175. }
  176. task('install') {
  177. dependsOn 'publishToMavenLocal'
  178. }
  179. signing {
  180. def signingKey = gradle.rootProject.findProperty('signingKey')
  181. def signingPassword = gradle.rootProject.findProperty('signingPassword')
  182. useInMemoryPgpKeys(signingKey, signingPassword)
  183. sign configurations.archives
  184. sign publishing.publications.maven
  185. }
  186. tasks.withType(Sign) {
  187. onlyIf { gradle.rootProject.hasProperty('signingKey') }
  188. }
  189. checkstyle {
  190. toolVersion libs.versions.checkstyle.get()
  191. configFile file("${gradle.rootProject.rootDir}/config/checkstyle/checkstyle.xml")
  192. }
  193. checkstyleMain {
  194. source ='src/main/java'
  195. }
  196. checkstyleTest {
  197. source ='src/test/java'
  198. }
  199. tasks.withType(Checkstyle) {
  200. reports {
  201. xml.required.set(false)
  202. html.required.set(true)
  203. }
  204. include("**/com/jme3/renderer/**/*.java")
  205. }