|
|
@ -1,3 +1,5 @@ |
|
|
|
import org.gradle.api.artifacts.DependencyResolveDetails |
|
|
|
|
|
|
|
apply from: "build-version.gradle" |
|
|
|
|
|
|
|
def isFrontendProject(currentDir){ |
|
|
@ -42,71 +44,79 @@ subprojects { |
|
|
|
apply plugin: 'io.spring.dependency-management' |
|
|
|
apply plugin: "org.asciidoctor.jvm.convert" |
|
|
|
|
|
|
|
configurations.all { |
|
|
|
//设置 gradle 拉取依赖包的缓存策略为不进行缓存,可保证每次拉取最新的依赖包 |
|
|
|
//resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds' //动态版本: 1.1.+ |
|
|
|
//resolutionStrategy.cacheChangingModulesFor 0, 'seconds' //静态版本: 1.1.2 |
|
|
|
configurations.all { |
|
|
|
//设置 gradle 拉取依赖包的缓存策略为不进行缓存,可保证每次拉取最新的依赖包 |
|
|
|
//resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds' //动态版本: 1.1.+ |
|
|
|
//resolutionStrategy.cacheChangingModulesFor 0, 'seconds' //静态版本: 1.1.2 |
|
|
|
|
|
|
|
//排除不需要的外部依赖 |
|
|
|
//exclude group: "org.apache.logging.log4j", module: "log4j-api" |
|
|
|
//exclude group: "org.apache.logging.log4j", module: "log4j-to-slf4j" |
|
|
|
//exclude group: "org.slf4j", module: "slf4j-jdk14" |
|
|
|
// exclude group: "org.apache.logging.log4j", module: "log4j-api" |
|
|
|
// exclude group: "org.apache.logging.log4j", module: "log4j-to-slf4j" |
|
|
|
// exclude group: "org.slf4j", module: "slf4j-jdk14" |
|
|
|
exclude group: "org.slf4j", module: "slf4j-nop" |
|
|
|
} |
|
|
|
|
|
|
|
dependencyManagement { |
|
|
|
resolutionStrategy { |
|
|
|
//设置 gradle 拉取依赖包的缓存策略为不进行缓存,可保证每次拉取最新的依赖包 |
|
|
|
//cacheDynamicVersionsFor 0, 'seconds' //动态版本: 1.1.+ |
|
|
|
resolutionStrategy.eachDependency { DependencyResolveDetails detail -> |
|
|
|
def requested =detail.requested; |
|
|
|
def groupAndName =requested.group + ":" + requested.name; |
|
|
|
if(PlatformDependencyVersions[groupAndName]!=null){ |
|
|
|
detail.useVersion(PlatformDependencyVersions[groupAndName]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
dependencyManagement { |
|
|
|
resolutionStrategy { |
|
|
|
//设置 gradle 拉取依赖包的缓存策略为不进行缓存,可保证每次拉取最新的依赖包 |
|
|
|
//cacheDynamicVersionsFor 0, 'seconds' //动态版本: 1.1.+ |
|
|
|
//cacheChangingModulesFor 0, 'seconds' //静态版本: 1.1.2 |
|
|
|
} |
|
|
|
imports { |
|
|
|
//mavenBom "org.springframework.cloud:spring-cloud-dependencies:${spring_cloud_version}" |
|
|
|
imports { |
|
|
|
//mavenBom "org.springframework.cloud:spring-cloud-dependencies:${spring_cloud_version}" |
|
|
|
mavenBom "com.alibaba.cloud:spring-cloud-alibaba-dependencies:${spring_cloud_alibaba_version}" |
|
|
|
mavenBom "org.springframework.statemachine:spring-statemachine-bom:${spring_statemachine_version}" |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*----------------------------------------------------------------- |
|
|
|
/*----------------------------------------------------------------- |
|
|
|
* 配置构建时所需依赖的仓库 url |
|
|
|
* 将仓库 url 都定位到 ${repository_url} 指定的本地私有仓库地址 |
|
|
|
*----------------------------------------------------------------*/ |
|
|
|
repositories { |
|
|
|
all { ArtifactRepository repo -> |
|
|
|
repositories { |
|
|
|
all { ArtifactRepository repo -> |
|
|
|
if(repo instanceof MavenArtifactRepository){ |
|
|
|
def url = repo.url.toString() |
|
|
|
if ( |
|
|
|
url.startsWith('https://repo1.maven.org/maven2') |
|
|
|
|| url.startsWith('https://jcenter.bintray.com/') |
|
|
|
|| url.startsWith('https://maven.aliyun.com') |
|
|
|
url.startsWith('https://repo1.maven.org/maven2') |
|
|
|
|| url.startsWith('https://jcenter.bintray.com/') |
|
|
|
|| url.startsWith('https://maven.aliyun.com') |
|
|
|
) { |
|
|
|
remove repo |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
maven { |
|
|
|
allowInsecureProtocol = true |
|
|
|
url "${repository_url}" |
|
|
|
} |
|
|
|
} |
|
|
|
maven { |
|
|
|
allowInsecureProtocol = true |
|
|
|
url "${repository_url}" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*----------------------------------------------------------------- |
|
|
|
/*----------------------------------------------------------------- |
|
|
|
* java 编译时选项 |
|
|
|
*----------------------------------------------------------------*/ |
|
|
|
sourceCompatibility ="${java_version}" |
|
|
|
targetCompatibility ="${java_version}" |
|
|
|
compileJava.options.encoding ="${java_encoding}" |
|
|
|
compileTestJava.options.encoding ="${java_encoding}" |
|
|
|
targetCompatibility ="${java_version}" |
|
|
|
compileJava.options.encoding ="${java_encoding}" |
|
|
|
compileTestJava.options.encoding ="${java_encoding}" |
|
|
|
|
|
|
|
tasks.withType(JavaCompile) { |
|
|
|
options.compilerArgs += ["-Xlint:deprecation","-Xlint:unchecked"] |
|
|
|
} |
|
|
|
tasks.withType(JavaCompile) { |
|
|
|
options.compilerArgs += ["-Xlint:deprecation","-Xlint:unchecked"] |
|
|
|
} |
|
|
|
|
|
|
|
/*----------------------------------------------------------------- |
|
|
|
/*----------------------------------------------------------------- |
|
|
|
* 配置项目基本信息 |
|
|
|
*----------------------------------------------------------------*/ |
|
|
|
group ="${application_group}" |
|
|
|
version ="${application_version}" |
|
|
|
group ="${application_group}" |
|
|
|
version ="${application_version}" |
|
|
|
|
|
|
|
if(file('package.json').exists()){ |
|
|
|
mkdir 'java-src/main/java'; |
|
|
@ -114,7 +124,7 @@ subprojects { |
|
|
|
mkdir 'dist'; |
|
|
|
sourceSets.main.java.srcDir 'java-src/main/java' |
|
|
|
sourceSets.main.resources.srcDir 'java-src/main/resources' |
|
|
|
sourceSets.main.resources.srcDir 'dist' |
|
|
|
sourceSets.main.resources.srcDir 'dist' |
|
|
|
} |
|
|
|
|
|
|
|
/*----------------------------------------------------------------- |
|
|
@ -140,48 +150,48 @@ subprojects { |
|
|
|
} |
|
|
|
|
|
|
|
clean { |
|
|
|
delete 'dist' //删除前端自动生成的资源目录 |
|
|
|
delete 'dist' //删除前端自动生成的资源目录 |
|
|
|
delete 'bin' //删除 eclipse 编译的 bin 目录 |
|
|
|
delete 'build' //删除 gradle 构建目录 |
|
|
|
} |
|
|
|
|
|
|
|
/*----------------------------------------------------------------- |
|
|
|
/*----------------------------------------------------------------- |
|
|
|
* 配置 eclipse 插件 |
|
|
|
*----------------------------------------------------------------*/ |
|
|
|
eclipse{ |
|
|
|
jdt{ |
|
|
|
sourceCompatibility ="${java_version}" |
|
|
|
targetCompatibility ="${java_version}" |
|
|
|
} |
|
|
|
} |
|
|
|
jdt{ |
|
|
|
sourceCompatibility ="${java_version}" |
|
|
|
targetCompatibility ="${java_version}" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*----------------------------------------------------------------- |
|
|
|
/*----------------------------------------------------------------- |
|
|
|
* springboot 插件配置 |
|
|
|
*----------------------------------------------------------------*/ |
|
|
|
jar { |
|
|
|
//可以生成普通的 jar |
|
|
|
enabled = true |
|
|
|
archiveClassifier.set("") |
|
|
|
manifest { |
|
|
|
//可以生成普通的 jar |
|
|
|
enabled = true |
|
|
|
archiveClassifier.set("") |
|
|
|
manifest { |
|
|
|
attributes 'Manifest-Version' : '1.0', |
|
|
|
'Implementation-Title' : name, |
|
|
|
'Implementation-Vendor' : group, |
|
|
|
'Implementation-Version': archiveVersion |
|
|
|
'Implementation-Title' : name, |
|
|
|
'Implementation-Vendor' : group, |
|
|
|
'Implementation-Version': archiveVersion |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*----------------------------------------------------------------- |
|
|
|
/*----------------------------------------------------------------- |
|
|
|
* asciidoctor 插件配置,用于生成 asciidoc 文档,用于打包到 jar 中 |
|
|
|
*----------------------------------------------------------------*/ |
|
|
|
asciidoctor { |
|
|
|
baseDirFollowsSourceDir() |
|
|
|
outputs.upToDateWhen { true } |
|
|
|
|
|
|
|
logDocuments = true |
|
|
|
sourceDir = file('asciidoc') |
|
|
|
sources { |
|
|
|
include '*.adoc' |
|
|
|
} |
|
|
|
asciidoctor { |
|
|
|
baseDirFollowsSourceDir() |
|
|
|
outputs.upToDateWhen { true } |
|
|
|
|
|
|
|
logDocuments = true |
|
|
|
sourceDir = file('asciidoc') |
|
|
|
sources { |
|
|
|
include '*.adoc' |
|
|
|
} |
|
|
|
outputDir = file("dist/help/" + project.name) |
|
|
|
resources { |
|
|
|
from(sourceDir) { |
|
|
@ -191,24 +201,24 @@ subprojects { |
|
|
|
} |
|
|
|
|
|
|
|
asciidoctorj { |
|
|
|
modules { |
|
|
|
diagram.use() |
|
|
|
} |
|
|
|
} |
|
|
|
modules { |
|
|
|
diagram.use() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*----------------------------------------------------------------- |
|
|
|
* 自定义任务,用于生成 asciidoc 文档到 web 服务器,以便实时查看效果 |
|
|
|
*----------------------------------------------------------------*/ |
|
|
|
task doc(type: org.asciidoctor.gradle.jvm.AsciidoctorTask){ |
|
|
|
baseDirFollowsSourceDir() |
|
|
|
outputs.upToDateWhen { true } |
|
|
|
baseDirFollowsSourceDir() |
|
|
|
outputs.upToDateWhen { true } |
|
|
|
|
|
|
|
logDocuments = true |
|
|
|
sourceDir = file('asciidoc') |
|
|
|
sources { |
|
|
|
include '*.adoc' |
|
|
|
} |
|
|
|
outputDir = file("$asciidoc_deploy_dir" + project.name) |
|
|
|
logDocuments = true |
|
|
|
sourceDir = file('asciidoc') |
|
|
|
sources { |
|
|
|
include '*.adoc' |
|
|
|
} |
|
|
|
outputDir = file("$asciidoc_deploy_dir" + project.name) |
|
|
|
|
|
|
|
// 拷贝 asciidoc 自定义资源 |
|
|
|
// 设置方式: 通过命令行 -D 传入目标环境参数 |
|
|
@ -222,48 +232,48 @@ subprojects { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*----------------------------------------------------------------- |
|
|
|
* 资源处理前执行 asciidoctor |
|
|
|
*----------------------------------------------------------------*/ |
|
|
|
processResources { |
|
|
|
dependsOn asciidoctor |
|
|
|
doLast{ |
|
|
|
//打包时移除 jrebel 相关的文件 |
|
|
|
delete "$buildDir/resources/main/rebel.xml" |
|
|
|
} |
|
|
|
} |
|
|
|
dependsOn asciidoctor |
|
|
|
doLast{ |
|
|
|
//打包时移除 jrebel 相关的文件 |
|
|
|
delete "$buildDir/resources/main/rebel.xml" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*----------------------------------------------------------------- |
|
|
|
* 用于自动生成 jrebel.xml 文件的自定义任务(eclipse) |
|
|
|
*----------------------------------------------------------------*/ |
|
|
|
task jrebelEclipse() {} |
|
|
|
tasks.jrebelEclipse.doLast { |
|
|
|
File resourcesFile =file('src/main/resources') |
|
|
|
if(resourcesFile!=null && resourcesFile.exists()){ |
|
|
|
File rebelFile = file('src/main/resources/rebel.xml') |
|
|
|
rebelFile.withWriter('UTF-8') { writer -> |
|
|
|
writer.write('<?xml version="1.0" encoding="UTF-8"?>\n'); |
|
|
|
writer.write('<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_1.xsd">\n'); |
|
|
|
writer.write('\t<classpath>\n'); |
|
|
|
if(file(project.name + '/src/main').exists()){ |
|
|
|
writer.write('\t\t<dir name="' + project.projectDir + '/bin/main"/>\n'); |
|
|
|
} |
|
|
|
if(file(project.name + '/src/generated').exists()){ |
|
|
|
writer.write('\t\t<dir name="' + project.projectDir + '/bin/generated"/>\n'); |
|
|
|
} |
|
|
|
writer.write('\t</classpath>\n'); |
|
|
|
writer.write('</application>'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
task jrebelEclipse() {} |
|
|
|
tasks.jrebelEclipse.doLast { |
|
|
|
File resourcesFile =file('src/main/resources') |
|
|
|
if(resourcesFile!=null && resourcesFile.exists()){ |
|
|
|
File rebelFile = file('src/main/resources/rebel.xml') |
|
|
|
rebelFile.withWriter('UTF-8') { writer -> |
|
|
|
writer.write('<?xml version="1.0" encoding="UTF-8"?>\n'); |
|
|
|
writer.write('<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_1.xsd">\n'); |
|
|
|
writer.write('\t<classpath>\n'); |
|
|
|
if(file(project.name + '/src/main').exists()){ |
|
|
|
writer.write('\t\t<dir name="' + project.projectDir + '/bin/main"/>\n'); |
|
|
|
} |
|
|
|
if(file(project.name + '/src/generated').exists()){ |
|
|
|
writer.write('\t\t<dir name="' + project.projectDir + '/bin/generated"/>\n'); |
|
|
|
} |
|
|
|
writer.write('\t</classpath>\n'); |
|
|
|
writer.write('</application>'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*----------------------------------------------------------------- |
|
|
|
* 用于自动生成 jrebel.xml 文件的自定义任务(idea) |
|
|
|
*----------------------------------------------------------------*/ |
|
|
|
task jrebelIdea() {} |
|
|
|
tasks.jrebelIdea.doLast { |
|
|
|
task jrebelIdea() {} |
|
|
|
tasks.jrebelIdea.doLast { |
|
|
|
if(isFrontendProject(file('.'))) { |
|
|
|
File resourcesFile = file('java-src/main/resources') |
|
|
|
if (resourcesFile != null && resourcesFile.exists()) { |
|
|
@ -295,7 +305,7 @@ subprojects { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*----------------------------------------------------------------- |
|
|
|
* maven publish 插件配置 |
|
|
@ -303,12 +313,12 @@ subprojects { |
|
|
|
publishing { |
|
|
|
repositories { |
|
|
|
maven { |
|
|
|
allowInsecureProtocol = true //允许采用 http 协议发布 |
|
|
|
allowInsecureProtocol = true //允许采用 http 协议发布 |
|
|
|
url = version.contains('SNAPSHOT') ? "${repository_snapshot_url}" : "${repository_release_url}" |
|
|
|
credentials { |
|
|
|
username = (version.contains('SNAPSHOT') ? "${repository_snapshot_username}" : "${repository_release_username}") |
|
|
|
password = (version.contains('SNAPSHOT') ? "${repository_snapshot_password}" : "${repository_release_password}") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
publications{ |
|
|
@ -317,18 +327,18 @@ subprojects { |
|
|
|
//artifact sourcesJar |
|
|
|
//artifact javadocJar |
|
|
|
versionMapping { |
|
|
|
usage('java-api') { |
|
|
|
fromResolutionOf('runtimeClasspath') |
|
|
|
} |
|
|
|
usage('java-runtime') { |
|
|
|
fromResolutionResult() |
|
|
|
} |
|
|
|
} |
|
|
|
usage('java-api') { |
|
|
|
fromResolutionOf('runtimeClasspath') |
|
|
|
} |
|
|
|
usage('java-runtime') { |
|
|
|
fromResolutionResult() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*----------------------------------------------------------------- |
|
|
|
/*----------------------------------------------------------------- |
|
|
|
* 更新前端模块的 package.json 文件,同步其中的 name 和 version |
|
|
|
*----------------------------------------------------------------*/ |
|
|
|
task frontendUpdatePackageJson(){} |
|
|
@ -354,7 +364,7 @@ subprojects { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*----------------------------------------------------------------- |
|
|
|
/*----------------------------------------------------------------- |
|
|
|
* pnpm install |
|
|
|
*----------------------------------------------------------------*/ |
|
|
|
task frontendNpmInstall(type:Exec){ |
|
|
@ -404,7 +414,7 @@ subprojects { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*----------------------------------------------------------------- |
|
|
|
/*----------------------------------------------------------------- |
|
|
|
* pnpm run build |
|
|
|
*----------------------------------------------------------------*/ |
|
|
|
task frontendNpmBuild(type:Exec) { |
|
|
@ -429,7 +439,7 @@ subprojects { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*----------------------------------------------------------------- |
|
|
|
/*----------------------------------------------------------------- |
|
|
|
* pnpm run prod |
|
|
|
*----------------------------------------------------------------*/ |
|
|
|
task frontendNpmProd(type:Exec) { |
|
|
@ -672,7 +682,16 @@ subprojects { |
|
|
|
|
|
|
|
processResources { |
|
|
|
if(isFrontendProject(file('.'))) { |
|
|
|
exclude("**/${project.name}/*.*") |
|
|
|
exclude("**/${project.name}/*.*"); |
|
|
|
if(project.name!='io.sc.platform.mvc.frontend' && project.name!='io.sc.platform.security.frontend'){ |
|
|
|
// exclude("**/${project.name}/javascript/codemirror.*"); |
|
|
|
// exclude("**/${project.name}/javascript/echarts.*"); |
|
|
|
// exclude("**/${project.name}/javascript/platform-core.*"); |
|
|
|
// exclude("**/${project.name}/javascript/quasar.*"); |
|
|
|
// exclude("**/${project.name}/javascript/vue.*"); |
|
|
|
// exclude("**/${project.name}/fonts/*.*"); |
|
|
|
// exclude("**/${project.name}/webjars/**/*.*"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -714,8 +733,8 @@ idea { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
project { |
|
|
|
vcs = 'Git' |
|
|
|
project { |
|
|
|
vcs = 'Git' |
|
|
|
ipr { |
|
|
|
// 自动化配置生成的 ipr 文件内容,减少手工操作 |
|
|
|
// 1. 移除根项目模块 |
|
|
@ -801,7 +820,7 @@ idea { |
|
|
|
setNode.appendNode("option",[value:"reload"]) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*----------------------------------------------------------------- |
|
|
|