build.gradle 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /**
  2. * This is a kingdee cosmic template project that is automatically generated by the Kingdee cosmic development assistant plugin.
  3. * If there are any issues during the use process, you can provide feedback to the kingdee developer community website.
  4. * Website: https://developer.kingdee.com/developer?productLineId=29
  5. * Author: liebin.zheng
  6. * Generate Date: 2025-03-01 12:08:14
  7. */
  8. plugins {
  9. id 'java'
  10. //https://docs.gradle.org/current/userguide/java_library_plugin.html#java_library_plugin
  11. id 'java-library'
  12. //id 'maven-publish'
  13. //https://docs.gradle.org/current/userguide/idea_plugin.html
  14. //id 'idea'
  15. //https://docs.gradle.org/current/userguide/eclipse_plugin.html
  16. //id 'eclipse'
  17. //id "org.sonarqube" version "3.5.0.2730"
  18. }
  19. apply from: 'config.gradle'
  20. def bos = ext.path.bos
  21. def trd = ext.path.trd
  22. def cus = ext.path.cus
  23. def biz = ext.path.biz
  24. def zip = ext.path.zip
  25. def outputdir = ext.path.outputdir
  26. //所有工程共用的配置
  27. allprojects {
  28. apply plugin: 'java'
  29. apply plugin: 'maven-publish'
  30. apply plugin: 'java-library'
  31. apply plugin: 'eclipse'
  32. apply plugin: 'idea'
  33. repositories{
  34. mavenLocal()
  35. maven{ url'https://maven.aliyun.com/repository/public/'}
  36. maven{ url'https://maven.aliyun.com/repository/gradle-plugin'}
  37. mavenCentral()
  38. //maven { url 'https://repo.gradle.org/gradle/libs-releases' }
  39. //gradlePluginPortal()
  40. }
  41. group = System.getProperty('groupId')
  42. version = System.getProperty('version')
  43. def jdk_version = System.getProperty('jdk.version')
  44. sourceCompatibility = jdk_version
  45. targetCompatibility = jdk_version
  46. tasks.withType(JavaCompile) {
  47. options.encoding = "UTF-8"
  48. }
  49. dependencies {
  50. //implementation 'cn.hutool:hutool-all:5.8.20'
  51. //implementation 'ch.qos.logback:logback-classic:1.2.12'
  52. //implementation 'org.slf4j:log4j-over-slf4j:1.7.36'
  53. //implementation 'org.apache.logging.log4j:log4j-to-slf4j:2.20.0'
  54. //testImplementation platform('org.junit:junit-bom:5.9.1')
  55. //testImplementation 'org.junit.jupiter:junit-jupiter'
  56. }
  57. test {
  58. useJUnitPlatform()
  59. }
  60. java {
  61. withSourcesJar()
  62. //withJavadocJar()
  63. }
  64. Date now = new Date()
  65. String date = now.format('yyyy-MM-dd HH:mm:ss')
  66. String buildNum = now.format('yyyyMMddHHmmssSSS')
  67. String gitCommitShortHash = ''
  68. String gitBranch = ''
  69. try{
  70. gitCommitShortHash = 'git log -1 --pretty=%H'.execute([], rootDir).text.trim()
  71. gitBranch = 'git branch --show-current'.execute([], rootDir).text.trim()
  72. } catch(Exception e){
  73. println "warning: the commandline tools of git was not installed!"
  74. }
  75. jar {
  76. manifest {
  77. attributes 'Group-Name': project.group
  78. attributes 'Project-Name': project.name
  79. attributes 'Bundle-Version': project.version
  80. attributes 'Build-Num': buildNum
  81. attributes 'Build-Date': date
  82. attributes 'Build-Jdk': System.getProperty('java.version')
  83. attributes 'Built-By': 'Kingdee Cosmic Developer Tools'
  84. attributes 'Build-Tool': 'Gradle ' + project.gradle.gradleVersion
  85. attributes 'Git-Commit-Hash': gitCommitShortHash
  86. attributes 'Git-Branch': gitBranch
  87. attributes 'Cloud-Name': ''
  88. attributes 'App-Name': ''
  89. attributes 'Jar-Id': ''
  90. attributes 'Build-Image': ''
  91. }
  92. }
  93. }
  94. //所有子工程共用的配置
  95. subprojects {
  96. dependencies {
  97. }
  98. //生成本工程jar包并拷贝到outputdir目录
  99. task buildJar(type: Copy, dependsOn: build){
  100. group 'build'
  101. description '生成本工程jar包并拷贝到outputdir目录'
  102. from 'build/libs'
  103. into outputdir
  104. exclude '*sources.jar','*javadoc.jar','*cosmic-debug*.jar'
  105. // 多语言配置文件放在src/main/java/resources目录下
  106. // 其他配置文件放在src/main/resources目录下
  107. processResources{
  108. from('src/main/java'){
  109. include '**/*.properties'
  110. }
  111. }
  112. }
  113. //生成本工程jar包并拷贝到拷贝到cus目录
  114. task deployJar(type: Copy, dependsOn: buildJar){
  115. group 'build'
  116. description '生成本工程jar包并拷贝到拷贝到cus目录'
  117. from outputdir
  118. into cus
  119. exclude '*sources.jar','*javadoc.jar','*cosmic-debug*.jar'
  120. }
  121. task basezip(type: Zip) {
  122. group 'build'
  123. description '生成base zip包'
  124. from outputdir
  125. include 'nckd-wnq01*.jar'
  126. destinationDirectory = file(zip)
  127. archiveFileName = "nckd-wnq01.zip"
  128. }
  129. test.ignoreFailures true
  130. }