gradle支持

This commit is contained in:
陈云志
2020-12-15 20:21:23 +08:00
parent 743e59db7a
commit 53aa2db213
35 changed files with 899 additions and 2 deletions

View File

@@ -0,0 +1,14 @@
//该产品的构建基本配置,公司统一模板,禁止开发人员修改。
allprojects {
def releaseVersion = System.getProperty("releaseVersion")
version = releaseVersion ? releaseVersion : "${devVersion}"
}
ext {
buildProduct = System.getProperty("buildProduct") ?: false
}
task abuildAllModule(type: Exec) {
workingDir("../")
executable "build-config/build_jar.sh"
args(project.name)
}

View File

@@ -0,0 +1,80 @@
//该产品的构建基本配置,公司统一模板,禁止开发人员修改。
ext {
swaggerVersion = "3.0.0"
lombokVersion = "1.18.16"
junitVersion = "4.13.1"
logbackVersion = "1.2.3"
}
task copyConfig(type: Copy) {
from "src/main/resources/application.properties"
from "src/main/resources/application.yaml"
from "src/main/resources/appServer.conf"
from "src/main/resources/subGui.conf"
into "build/libs/"
}
task copySql(type: Copy) {
from "src/main/resources/sql"
into "build/libs/sql"
}
task cleanGridnt(type: Exec) {
executable "../rmGridntJar.sh"
}
clean {
delete = ["build", "out", "dist_java", "boot", "log", "logs",]
}
[compileJava, compileTestJava]*.options*.encoding = "UTF-8"
[compileJava, compileTestJava]*.sourceCompatibility = "11"
[compileJava, compileTestJava]*.targetCompatibility = "11"
repositories {
mavenLocal()
mavenCentral()
maven { url "https://maven.aliyun.com/repository/public/" }
// maven { url "http://192.168.8.200:8081/repository/public/" }
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, "seconds"
resolutionStrategy.cacheDynamicVersionsFor 0, "seconds"
}
dependencies {
/*lombok依赖*/
testCompile "junit:junit:${junitVersion}"
compileOnly "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
testCompileOnly "org.projectlombok:lombok:${lombokVersion}"
testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}"
compile "ch.qos.logback:logback-classic:${logbackVersion}"
testCompileOnly "ch.qos.logback:logback-classic:${logbackVersion}"
}
jar {
// // 排除掉模块调试的资源文件, 启动类.
// excludes = ["file/WaveAnalysis", "com/gridnt/**/*Starter*", "logback*.xml",
// "application*.properties", "application*.yaml", "config"
// ]
manifest {
attributes "releaseVersion": version + "-" + getGitVersion()
attributes "vendor": "GRIDNT山东网聪信息科技有限公司 build"
attributes "description": "重新编译打包,引用的其它组织的代码,著作圈原作者所有"
attributes "buildTime": new Date().format("yyyy-MM-dd HH:mm:ss", TimeZone.getTimeZone("GMT+08:00"))
}
}
apply plugin: "org.sonarqube"
sonarqube {
properties {
property "sonar.projectKey", "${project.name}"
property "sonar.projectName", "${project.name}"
property "sonar.sources", "src"
property "sonar.java.binaries", "build"
property "sonar.exclusions", "**/**test**/**"
property "sonar.sourceEncoding", "UTF-8"
}
}

View File

@@ -0,0 +1,28 @@
//该产品的构建基本配置,公司统一模板,禁止开发人员开发过程中修改。
apply plugin: "org.springframework.boot"
// 清除现有的lib目录
task clearJar(type: Delete) {
delete "$buildDir\\libs\\lib"
}
// 将依赖包复制到lib目录
task copyJar(type: Copy, dependsOn: "clearJar") {
from configurations.compileClasspath
into "$buildDir\\libs\\lib"
}
bootJar {
// excludes = ["file/WaveAnalysis", "*.jar", "*.properties", "*.yaml", "config", "*.conf"]
manifest {
attributes "Main-Class": "org.springframework.boot.loader.PropertiesLauncher"
attributes "Manifest-Release-Version": version + "-" + getGitVersion()
// attributes "Class-Path": configurations.runtime.files.collect { "../lib/$it.name" }.join(" ")
attributes "releaseVersion": version + "-" + getGitVersion()
attributes "vendor": "GRIDNT山东网聪信息科技有限公司"
attributes "buildTime": new Date().format("yyyy-MM-dd HH:mm:ss", TimeZone.getTimeZone("GMT+08:00"))
}
// launchScript()
} dependsOn(clearJar, copyJar, copyConfig, copySql)

View File

@@ -0,0 +1,44 @@
apply plugin: "maven-publish"
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = "sources"
}
publishing {
publications {
maven(MavenPublication) {
artifactId "${archivesBaseName}"
version project.version
//如果是war包填写components.web如果是jar包填写components.java
from components.java
artifact sourcesJar
}
mavenJava(MavenPublication) {
versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}
}
}
repositories {
maven {
//指定要上传的maven私服仓库
def releasesRepoUrl = "http://192.168.8.200:8081/repository/releases"
def snapshotsRepoUrl = "http://192.168.8.200:8081/repository/snapshots/"
url = version.endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl
println "${group} ${archivesBaseName} publishing version is ${version}"
//认证用户和密码
credentials {
username "developer"
password "dev123"
}
}
}
}

31
build-config/build_jar.sh Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
#echo " 本脚本参数说明,支持一个参数,当前模块目录"
bootModule=$1
echo "bootModule is :" $bootModule
# 准备 bootjar 依赖目录
rm -rf $bootModule/$bootModule-gui/libs $bootModule/$bootModule-server/libs
mkdir -p $bootModule/$bootModule-gui/libs $bootModule/$bootModule-server/libs
# 编译各个模块
for dir in $(ls .)
do
if [[ -d $dir && -f $dir/build.gradle && $dir != 'build-config' && $dir != $bootModule ]] ; then
# 清理
if [[ -d $dir/$dir-pub ]] ; then rm -rf $dir/$dir-pub/build ;fi
if [[ -d $dir/$dir-gui ]] ; then rm -rf $dir/$dir-gui/build ;fi
if [[ -d $dir/$dir-server ]] ; then rm -rf $dir/$dir-server/build ;fi
rm -rf $dir/.gradle $dir/.idea
echo "gradle home is =" $PATH
$GRADLE_HOME/bin/gradle $gradleArgs --daemon --parallel -x test -DbuildProduct=true -b $dir/build.gradle jar --s
# 拷贝gui server公用jar到对应的目录。
if [[ -d $dir/$dir-pub ]] ; then echo $bootModule/$bootModule-gui/libs/ $bootModule/$bootModule-server/libs | xargs -n 1 cp -f $dir/$dir-pub/build/libs/*.jar ;fi
if [[ -d $dir/$dir-gui ]] ; then cp -f $dir/$dir-gui/build/libs/*.jar $bootModule/$bootModule-gui/libs;fi
if [[ -d $dir/$dir-server ]] ; then cp -f $dir/$dir-server/build/libs/*.jar $bootModule/$bootModule-server/libs;fi
if [ 0 -ne $? ] ; then echo "$dir build failed, please check the error log! "; exit 1 ; fi
echo -e "\033[32m----------------- $dir 模块编译成功 ---------------------- \033[0m"
fi
done
echo "BUILD SUCCESSFUL " `date`

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL -->
<configuration scan="false" scanPeriod="60 seconds" debug="false">
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<root level="INFO">
<appender-ref ref="FILE"/>
</root>
</configuration>

View File

@@ -0,0 +1,24 @@
import org.codehaus.groovy.runtime.GStringImpl
//共享的非业务功能模块,禁止将其它业务功能模块添加进来
// 该产品 gui 和 appServer都需要的依赖
ext {
gridntBase = "${devVersion}" as GStringImpl
// gridntBase = "2.1.0"
svgshowVersion = "2.1.0"
protectVersion = "2.1.1"
mybatisPlus = "3.2.0"
debugProduct = System.getProperty("debugProduct") ?: false
}
dependencies {
//-------网聪 开发中的模块----------------------------------------------------------------------------------------
implementation "com.gridnt:gridnt-base-pub:${gridntBase}"
//-------网聪正式发布的共享模块-------------------------------------------------------------------------------------
//-------第三依赖 -----------------------------------------------------------------------
implementation "org.springframework.boot:spring-boot-starter-logging:${springBoot}"
}

View File

@@ -0,0 +1,41 @@
apply plugin: "org.openjfx.javafxplugin"
//apply plugin: "com.github.ayltai.spring-graalvm-native-plugin"
javafx {
version = "11.0.2"
// version = "15.0.1"
modules = ["javafx.base", "javafx.controls", "javafx.fxml", "javafx.graphics", "javafx.media"
, "javafx.swing", "javafx.web"
]
}
//共享的功能模块
dependencies {
//------- 一、网聪 开发中的模块----------------------------------------------------------------------------------------
implementation "com.gridnt:gridnt-base-gui:${gridntBase}"
//------- 1.1 网聪产品间共享的业务功能模块------------------------------------------------------------------------------
if (debugProduct) {
// 构建产品,产品全功能运行
compile fileTree(dir: "libs", include: ["*.jar"])
}
//------- 二、网聪正式发布工具类 共享模块--------------------------------------------------------------------------------
implementation "com.gridnt:springboot-javafx-support:${devVersion}"
//-------独有的第三依赖-------------------------------------------------------------------------------------------
implementation "org.yaml:snakeyaml:1.27"
//---------- 测试 ---------------------------------------------------------------------------------------------
testCompile "org.springframework.boot:spring-boot-starter-test:${springBoot}"
//-------runtime-----------------------------------------------------------------------------------------------
testCompile "org.springframework.boot:spring-boot-devtools:${springBoot}"
}

View File

@@ -0,0 +1,33 @@
ext {
mybatisPlus = "3.4.1"
}
dependencies {
//------- 一、网聪 开发中的模块----------------------------------------------------------------------------------------
implementation "com.gridnt:gridnt-base-server:${gridntBase}"
//------- 1.1 网聪产品间共享的业务功能模块---------------------------------------------------------------
if (debugProduct) {
// 构建产品,产品全功能运行
compile fileTree(dir: "libs", include: ["*.jar"])
}
//------- 二、网聪正式发布工具类 共享模块--------------------------------------------------------------------------------
//-------产品独有的第三依赖-------------------------------------------------------------------------------------------
implementation "org.springframework.boot:spring-boot-starter-data-redis:${springBoot}"
implementation "com.fasterxml.jackson.core:jackson-databind:2.12.0"
//-------runtime-----------------------------------------------------------------------------------------------
//---------- 测试 ---------------------------------------------------------------------------------------------
testCompile "org.springframework.boot:spring-boot-starter-test:${springBoot}"
}

7
build-config/publish.sh Executable file
View File

@@ -0,0 +1,7 @@
#! /bin/bash
# 发布之前,必须先提交 !!!! 发布之前,必须先提交 !!!! 发布之前,必须先提交 !!!!
# 使用方法: ./publish.sh 版本号.
# git pull; git add . ;git commit -m " 发布版本 $*" ; git push
gradle --daemon --parallel -DbuildProduct=true clean publish -DreleaseVersion=$1