build.gradle 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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-04-14 11:39:48
  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 outputdir = ext.path.outputdir
  25. //所有工程共用的配置
  26. allprojects {
  27. apply plugin: 'java'
  28. apply plugin: 'maven-publish'
  29. apply plugin: 'java-library'
  30. apply plugin: 'eclipse'
  31. apply plugin: 'idea'
  32. repositories{
  33. mavenLocal()
  34. maven{ url'https://maven.aliyun.com/repository/public/'}
  35. maven{ url'https://maven.aliyun.com/repository/gradle-plugin'}
  36. mavenCentral()
  37. //maven { url 'https://repo.gradle.org/gradle/libs-releases' }
  38. //gradlePluginPortal()
  39. }
  40. group = System.getProperty('groupId')
  41. version = System.getProperty('version')
  42. def jdk_version = System.getProperty('jdk.version')
  43. sourceCompatibility = jdk_version
  44. targetCompatibility = jdk_version
  45. tasks.withType(JavaCompile) {
  46. options.encoding = "UTF-8"
  47. }
  48. dependencies {
  49. //implementation 'cn.hutool:hutool-all:5.8.20'
  50. //implementation 'ch.qos.logback:logback-classic:1.2.12'
  51. //implementation 'org.slf4j:log4j-over-slf4j:1.7.36'
  52. //implementation 'org.apache.logging.log4j:log4j-to-slf4j:2.20.0'
  53. //testImplementation platform('org.junit:junit-bom:5.9.1')
  54. //testImplementation 'org.junit.jupiter:junit-jupiter'
  55. }
  56. test {
  57. useJUnitPlatform()
  58. }
  59. java {
  60. withSourcesJar()
  61. //withJavadocJar()
  62. }
  63. Date now = new Date()
  64. String date = now.format('yyyy-MM-dd HH:mm:ss')
  65. String buildNum = now.format('yyyyMMddHHmmssSSS')
  66. String gitCommitShortHash = ''
  67. String gitBranch = ''
  68. try{
  69. gitCommitShortHash = 'git log -1 --pretty=%H'.execute([], rootDir).text.trim()
  70. gitBranch = 'git branch --show-current'.execute([], rootDir).text.trim()
  71. } catch(Exception e){
  72. println "warning: the commandline tools of git was not installed!"
  73. }
  74. jar {
  75. manifest {
  76. attributes 'Group-Name': project.group
  77. attributes 'Project-Name': project.name
  78. attributes 'Bundle-Version': project.version
  79. attributes 'Build-Num': buildNum
  80. attributes 'Build-Date': date
  81. attributes 'Build-Jdk': System.getProperty('java.version')
  82. attributes 'Built-By': 'Kingdee Cosmic Developer Tools'
  83. attributes 'Build-Tool': 'Gradle ' + project.gradle.gradleVersion
  84. attributes 'Git-Commit-Hash': gitCommitShortHash
  85. attributes 'Git-Branch': gitBranch
  86. attributes 'Cloud-Name': ''
  87. attributes 'App-Name': ''
  88. attributes 'Jar-Id': ''
  89. attributes 'Build-Image': ''
  90. }
  91. }
  92. }
  93. //所有子工程共用的配置
  94. subprojects {
  95. dependencies {
  96. }
  97. //生成本工程jar包并拷贝到outputdir目录
  98. task buildJar(type: Copy, dependsOn: build){
  99. group 'build'
  100. description '生成本工程jar包并拷贝到outputdir目录'
  101. from 'build/libs'
  102. into outputdir
  103. exclude '*sources.jar','*javadoc.jar','*cosmic-debug*.jar'
  104. // 多语言配置文件放在src/main/java/resources目录下
  105. // 其他配置文件放在src/main/resources目录下
  106. processResources{
  107. from('src/main/java'){
  108. include '**/*.properties'
  109. }
  110. }
  111. }
  112. //生成本工程jar包并拷贝到拷贝到cus目录
  113. task deployJar(type: Copy, dependsOn: buildJar){
  114. group 'build'
  115. description '生成本工程jar包并拷贝到拷贝到cus目录'
  116. from outputdir
  117. into cus
  118. exclude '*sources.jar','*javadoc.jar','*cosmic-debug*.jar'
  119. }
  120. test.ignoreFailures true
  121. }