common.gradle 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. eclipse.jdt.file.withProperties { props ->
  10. props.setProperty "org.eclipse.jdt.core.circularClasspath", "warning"
  11. }
  12. group = 'org.jmonkeyengine'
  13. version = jmeFullVersion
  14. sourceCompatibility = JavaVersion.VERSION_1_8
  15. targetCompatibility = JavaVersion.VERSION_1_8
  16. tasks.withType(JavaCompile) { // compile-time options:
  17. //options.compilerArgs << '-Xlint:deprecation' // to show deprecation warnings
  18. options.compilerArgs << '-Xlint:unchecked'
  19. options.encoding = 'UTF-8'
  20. if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_1_10)) {
  21. options.release = 8
  22. }
  23. }
  24. ext {
  25. lwjgl3Version = '3.3.1' // used in both the jme3-lwjgl3 and jme3-vr build scripts
  26. niftyVersion = '1.4.3' // used in both the jme3-niftygui and jme3-examples build scripts
  27. }
  28. repositories {
  29. mavenCentral()
  30. flatDir {
  31. dirs rootProject.file('lib')
  32. }
  33. }
  34. dependencies {
  35. // Adding dependencies here will add the dependencies to each subproject.
  36. testImplementation 'junit:junit:4.13.2'
  37. testImplementation 'org.mockito:mockito-core:3.12.4'
  38. testImplementation 'org.codehaus.groovy:groovy-test:3.0.14'
  39. }
  40. // Uncomment if you want to see the status of every test that is run and
  41. // the test output.
  42. /*
  43. test {
  44. testLogging {
  45. events "passed", "skipped", "failed", "standardOut", "standardError"
  46. }
  47. }
  48. */
  49. jar {
  50. manifest {
  51. attributes 'Implementation-Title': 'jMonkeyEngine',
  52. 'Implementation-Version': jmeFullVersion,
  53. 'Automatic-Module-Name': "${project.name.replace("-", ".")}",
  54. 'Created-By': "${JavaVersion.current()} (${System.getProperty("java.vendor")})"
  55. }
  56. }
  57. javadoc {
  58. failOnError = false
  59. options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
  60. options.docTitle = "jMonkeyEngine ${jmeFullVersion} ${project.name} Javadoc"
  61. options.windowTitle = "jMonkeyEngine ${jmeFullVersion} ${project.name} Javadoc"
  62. options.header = "<b>jMonkeyEngine ${jmeFullVersion} ${project.name}</b>"
  63. options.author = "true"
  64. options.use = "true"
  65. options.charSet = "UTF-8"
  66. options.encoding = "UTF-8"
  67. source = sourceSets.main.allJava // main only, exclude tests
  68. }
  69. test {
  70. testLogging {
  71. exceptionFormat = 'full'
  72. }
  73. }
  74. task sourcesJar(type: Jar, dependsOn: classes, description: 'Creates a jar from the source files.') {
  75. classifier = 'sources'
  76. from sourceSets*.allSource
  77. }
  78. task javadocJar(type: Jar, dependsOn: javadoc, description: 'Creates a jar from the javadoc files.') {
  79. classifier = 'javadoc'
  80. from javadoc.destinationDir
  81. }
  82. ext.pomConfig = {
  83. name POM_NAME
  84. description POM_DESCRIPTION
  85. url POM_URL
  86. inceptionYear POM_INCEPTION_YEAR
  87. scm {
  88. url POM_SCM_URL
  89. connection POM_SCM_CONNECTION
  90. developerConnection POM_SCM_DEVELOPER_CONNECTION
  91. }
  92. licenses {
  93. license {
  94. name POM_LICENSE_NAME
  95. url POM_LICENSE_URL
  96. distribution POM_LICENSE_DISTRIBUTION
  97. }
  98. }
  99. developers {
  100. developer {
  101. name 'jMonkeyEngine Team'
  102. id 'jMonkeyEngine'
  103. }
  104. }
  105. }
  106. artifacts {
  107. archives jar
  108. archives sourcesJar
  109. if (buildJavaDoc == "true") {
  110. archives javadocJar
  111. }
  112. }
  113. publishing {
  114. publications {
  115. maven(MavenPublication) {
  116. artifact javadocJar
  117. artifact sourcesJar
  118. from components.java
  119. pom {
  120. description = POM_DESCRIPTION
  121. developers {
  122. developer {
  123. id = 'jMonkeyEngine'
  124. name = 'jMonkeyEngine Team'
  125. }
  126. }
  127. inceptionYear = POM_INCEPTION_YEAR
  128. licenses {
  129. license {
  130. distribution = POM_LICENSE_DISTRIBUTION
  131. name = POM_LICENSE_NAME
  132. url = POM_LICENSE_URL
  133. }
  134. }
  135. name = POM_NAME
  136. scm {
  137. connection = POM_SCM_CONNECTION
  138. developerConnection = POM_SCM_DEVELOPER_CONNECTION
  139. url = POM_SCM_URL
  140. }
  141. url = POM_URL
  142. }
  143. version project.version
  144. }
  145. }
  146. repositories {
  147. maven {
  148. name = 'Dist'
  149. url = gradle.rootProject.projectDir.absolutePath + '/dist/maven'
  150. }
  151. maven {
  152. credentials {
  153. username = gradle.rootProject.hasProperty('ossrhUsername') ? ossrhUsername : 'Unknown user'
  154. password = gradle.rootProject.hasProperty('ossrhPassword') ? ossrhPassword : 'Unknown password'
  155. }
  156. name = 'OSSRH'
  157. url = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2'
  158. }
  159. }
  160. }
  161. publishToMavenLocal.doLast {
  162. println 'published ' + project.getName() + "-${jmeFullVersion} to mavenLocal"
  163. }
  164. task('install') {
  165. dependsOn 'publishToMavenLocal'
  166. }
  167. signing {
  168. def signingKey = gradle.rootProject.findProperty('signingKey')
  169. def signingPassword = gradle.rootProject.findProperty('signingPassword')
  170. useInMemoryPgpKeys(signingKey, signingPassword)
  171. sign configurations.archives
  172. sign publishing.publications.maven
  173. }
  174. tasks.withType(Sign) {
  175. onlyIf { gradle.rootProject.hasProperty('signingKey') }
  176. }