更改标准打包方式为Fat Jar

This commit is contained in:
MaxKey 2024-04-06 21:09:05 +08:00
parent b091733ff1
commit 95f5ccd446
7 changed files with 192 additions and 167 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright [2023] [MaxKey of copyright http://www.maxkey.top] * Copyright [2024] [MaxKey of copyright http://www.maxkey.top]
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,47 +22,11 @@ defaultTasks "clean", "build"
//Version define //Version define
ext { ext {
} }
def libjarsmapper=[
'maxkey-authentication-captcha' :'lib',
'maxkey-authentication-core' :'lib',
'maxkey-authentication-ip2location' :'lib',
'maxkey-authentication-otp' :'lib',
'maxkey-authentication-provider' :'lib',
'maxkey-authentication-sms' :'lib',
'maxkey-common' :'lib',
'maxkey-core' :'lib',
'maxkey-persistence' :'lib',
'maxkey-protocol-authorize' :'lib',
'maxkey-protocol-cas' :'lib',
'maxkey-protocol-desktop' :'lib',
'maxkey-protocol-extendapi' :'lib',
'maxkey-protocol-formbased' :'lib',
'maxkey-protocol-jwt' :'lib',
'maxkey-protocol-oauth-2.0' :'lib',
'maxkey-protocol-saml-2.0' :'lib',
'maxkey-protocol-tokenbased' :'lib',
'maxkey-web-resources' :'lib',
'maxkey-authentication-social' :'maxkey',
'maxkey-web-maxkey' :'maxkey',
'maxkey-web-mgt' :'maxkey_mgt',
'maxkey-synchronizer' :'maxkey_mgt',
'maxkey-synchronizer-activedirectory' :'maxkey_mgt',
'maxkey-synchronizer-common' :'maxkey_mgt',
'maxkey-synchronizer-jdbc' :'maxkey_mgt',
'maxkey-synchronizer-ldap' :'maxkey_mgt',
'maxkey-synchronizer-dingtalk' :'maxkey_mgt',
'maxkey-synchronizer-workweixin' :'maxkey_mgt',
'maxkey-synchronizer-reorgdept' :'maxkey_mgt',
'maxkey-web-openapi' :'maxkey_openapi',
'maxkey-web-api-rest' :'maxkey_openapi',
'maxkey-web-api-scim' :'maxkey_openapi',
]
configurations.all { configurations.all {
transitive = false// transitive = false//
} }
//add support for Java //add support for Java
@ -74,14 +38,14 @@ allprojects {
//apply plugin: "findbugs" //apply plugin: "findbugs"
//apply plugin: "jdepend" //apply plugin: "jdepend"
configurations.all { configurations.all {
transitive = false// transitive = false//
} }
//java Version //java Version
sourceCompatibility = 17 sourceCompatibility = 17
targetCompatibility = 17 targetCompatibility = 17
compileJava.options.encoding = 'UTF-8' compileJava.options.encoding = 'UTF-8'
eclipse { eclipse {
/*设置工程字符集*/ /*设置工程字符集*/
jdt { jdt {
@ -91,7 +55,7 @@ allprojects {
prefs.append('encoding/<project>=UTF-8') //use UTF-8 prefs.append('encoding/<project>=UTF-8') //use UTF-8
} }
} }
} }
} }
buildscript { buildscript {
@ -105,46 +69,55 @@ repositories {
// Use 'jcenter' for resolving your dependencies. // Use 'jcenter' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here. // You can declare any Maven/Ivy/file repository here.
mavenCentral() mavenCentral()
jcenter()
} }
// In this section you declare the dependencies for your production and test code
dependencies {
}
subprojects {
processResources { subprojects {
from ('src/main/resources') { /*
include 'src/main/resources/*.*' eclipse {
} eclipse设置
} jdt {
sourceSets { File f = file('.settings/org.eclipse.core.resources.prefs')
main { f.write('eclipse.preferences.version=1\n')
java { f.append('encoding/<project>=UTF-8') //use UTF-8
srcDir 'src/main/java' // }
} }
} */
} processResources {
repositories { from ('src/main/resources') {
include 'src/main/resources/*.*'
}
}
sourceSets {
main {
java {
srcDir 'src/main/java' //
}
}
}
repositories {
mavenLocal() mavenLocal()
maven { url "https://maven.aliyun.com/repository/central"} maven { url "https://maven.aliyun.com/repository/central"}
maven { url "https://maven.aliyun.com/repository/public"} maven { url "https://maven.aliyun.com/repository/public"}
maven { url "https://repo.spring.io/plugins-release/" } maven { url "https://repo.spring.io/plugins-release" }
maven { url "https://repo.spring.io/milestone" } maven { url "https://repo.spring.io/milestone" }
maven { url "https://repo1.maven.org/maven2/" } maven { url "https://repo1.maven.org/maven2" }
maven { url "https://build.shibboleth.net/nexus/content/repositories/releases/" } maven { url "https://build.shibboleth.net/nexus/content/repositories/releases" }
maven { url "https://mvnrepository.com/repos/central/" } maven { url "https://mvnrepository.com/repos/central" }
maven { url "https://jcenter.bintray.com" } maven { url "https://jcenter.bintray.com" }
maven { url "https://mvn.gt.igexin.com/nexus/content/repositories/releases"} maven { url "https://mvn.gt.igexin.com/nexus/content/repositories/releases"}
maven { url "https://plugins.gradle.org/m2/" } maven { url "https://plugins.gradle.org/m2" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" } maven { url "https://oss.sonatype.org/content/repositories/releases" }
maven { url "https://maven.repository.redhat.com/ga/" } maven { url "https://maven.repository.redhat.com/ga" }
maven { url "https://repository.apache.org/content/repositories/releases/" } maven { url "https://repository.apache.org/content/repositories/releases" }
mavenCentral() mavenCentral()
} }
//all dependencies //all dependencies
dependencies { dependencies {
//for Test and Compile //for Test and Compile
testImplementation group: 'junit', name: 'junit', version: "${junitVersion}" testImplementation group: 'junit', name: 'junit', version: "${junitVersion}"
@ -447,92 +420,47 @@ subprojects {
jar { jar {
def currentTime = java.time.ZonedDateTime.now() def currentTime = java.time.ZonedDateTime.now()
manifest { manifest {
attributes( attributes(
"Implementation-Title": project.name, "Implementation-Title": project.name,
"Implementation-Vendor": project.vendor, "Implementation-Vendor": project.vendor,
"Created-By": project.author, "Created-By": project.author,
"Implementation-Date": currentTime, "Implementation-Date": currentTime,
"Implementation-Version": project.version "Implementation-Version": project.version
) )
} }
} }
tasks.register("buildRelease",Copy) { tasks.register("buildRelease",Copy) {
dependsOn assemble dependsOn assemble
// group version // group version
println "subproject " + project.name + ", group " + project.group +" , version " + project.version println "subproject " + project.name + ", group " + project.group +" , version " + project.version
//copy //copy
into "$rootDir/build/maxkey-jars/" into "$rootDir/build/"
from "$buildDir/libs/" from "$buildDir/libs/"
include '*.jar' include '*-boot-*.jar'
} }
tasks.register("copyLibJars",Copy) { assemble.configure { finalizedBy buildRelease }
if (libjarsmapper["${project.name}"] != null){
into "$rootDir/build/MaxKey-v${project.version}GA/"+libjarsmapper["${project.name}"]
from "$buildDir/libs/"
include '*.jar'
}
}
assemble.configure { finalizedBy buildRelease,copyLibJars }
}
//copy Dep Jars to /build/maxkey-depjars,only maxkey-common deps
project('maxkey-common') {
task createReleaseDir(type: Copy){
def paths = ["$rootDir/build/MaxKey-v${project.version}GA",
"$rootDir/build/MaxKey-v${project.version}GA/maxkey",
"$rootDir/build/MaxKey-v${project.version}GA/maxkey_mgt",
"$rootDir/build/MaxKey-v${project.version}GA/lib"];
//createDir闭包
paths.forEach(){path->
File dir=new File(path);
if (!dir.exists()){
print("create "+path+"\n")
dir.mkdirs();
}
};
}
task copyDepJars (type: Copy){
dependsOn assemble
println "copy Dep Jars to $rootDir/build/MaxKey-v${project.version}GA/lib"
//copy runtime
from configurations.runtimeClasspath
into "$rootDir/build/MaxKey-v${project.version}GA/lib";
}
build.configure { finalizedBy copyDepJars }
} }
tasks.register("buildRelease") { tasks.register("buildRelease") {
dependsOn 'copyShellScript','copyWindowsShellScript'
// group version // group version
println "Root project " + project.name + ", group " + project.group +" , version " + project.version println "Root project " + project.name + ", group " + project.group +" , version " + project.version
// to build文件绝对路径 // to build文件绝对路径
println "Root project projectDir " + project.projectDir +" to " + project.buildDir println "Root project projectDir " + project.projectDir +" to " + project.buildDir
} }
tasks.register("copyShellScript",Copy) {
println "project copyMaxKeyShellScript .";
from "$rootDir/shellscript/"
into "$rootDir/build/MaxKey-v${project.version}GA/shellscript/";
}
tasks.register("copyWindowsShellScript",Copy) {
println "project copyMaxKeyWindowsShellScript .";
from "$rootDir/shellscript/windows"
into "$rootDir/build/MaxKey-v${project.version}GA/";
}
build.configure { build.configure {
finalizedBy buildRelease finalizedBy buildRelease
println "" println ""
println "Gradle version is ${GradleVersion.current().version}" println "Gradle version is ${GradleVersion.current().version}"
}
// In this section you declare the dependencies for your production and test code
dependencies {
} }

View File

@ -1,4 +1,4 @@
FROM adoptopenjdk:8-jre FROM openjdk:17-jdk-alpine
RUN mkdir -p /maxkey RUN mkdir -p /maxkey
@ -10,6 +10,6 @@ COPY ${JAR_FILE} maxkey-boot.jar
EXPOSE 9527 EXPOSE 9527
ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom" ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms256m -Xmx2048m -Djava.security.egd=file:/dev/./urandom"
CMD sleep 60; java -jar maxkey-boot.jar $JAVA_OPTS CMD sleep 60; java -jar maxkey-boot.jar $JAVA_OPTS

View File

@ -1,7 +1,38 @@
buildscript {
repositories {
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/'}
}
dependencies {
//springboot jar
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
plugins {
id 'java'
id "io.spring.dependency-management" version "1.0.11.RELEASE"
id 'org.springframework.boot' version "${springBootVersion}"
}
apply plugin: 'io.spring.dependency-management'
description = "maxkey-web-maxkey" description = "maxkey-web-maxkey"
//add support for Java bootJar {
apply plugin: 'java' dependsOn jar
archiveBaseName = 'maxkey-boot'
version = "${project.version}-ga"
mainClass = 'org.dromara.maxkey.MaxKeyApplication'
manifest {
attributes(
"Implementation-Title": project.name,
"Implementation-Vendor": project.vendor,
"Created-By": project.author,
"Implementation-Date": java.time.ZonedDateTime.now(),
"Implementation-Version": project.version
)
}
}
dependencies { dependencies {
implementation project(":maxkey-common") implementation project(":maxkey-common")
@ -9,12 +40,12 @@ dependencies {
implementation project(":maxkey-persistence") implementation project(":maxkey-persistence")
implementation project(":maxkey-authentications:maxkey-authentication-core") implementation project(":maxkey-authentications:maxkey-authentication-core")
implementation project(":maxkey-authentications:maxkey-authentication-social")
implementation project(":maxkey-authentications:maxkey-authentication-captcha") implementation project(":maxkey-authentications:maxkey-authentication-captcha")
implementation project(":maxkey-authentications:maxkey-authentication-ip2location") implementation project(":maxkey-authentications:maxkey-authentication-ip2location")
implementation project(":maxkey-authentications:maxkey-authentication-otp") implementation project(":maxkey-authentications:maxkey-authentication-otp")
implementation project(":maxkey-authentications:maxkey-authentication-provider") implementation project(":maxkey-authentications:maxkey-authentication-provider")
implementation project(":maxkey-authentications:maxkey-authentication-sms") implementation project(":maxkey-authentications:maxkey-authentication-sms")
implementation project(":maxkey-authentications:maxkey-authentication-social")
implementation project(":maxkey-protocols:maxkey-protocol-authorize") implementation project(":maxkey-protocols:maxkey-protocol-authorize")
implementation project(":maxkey-protocols:maxkey-protocol-cas") implementation project(":maxkey-protocols:maxkey-protocol-cas")

View File

@ -1,4 +1,4 @@
FROM adoptopenjdk:8-jre FROM openjdk:17-jdk-alpine
RUN mkdir -p /maxkey-mgt RUN mkdir -p /maxkey-mgt
@ -10,6 +10,6 @@ COPY ${JAR_FILE} maxkey-mgt-boot.jar
EXPOSE 9526 EXPOSE 9526
ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom" ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms256m -Xmx2048m -Djava.security.egd=file:/dev/./urandom"
CMD sleep 60; java -jar maxkey-mgt-boot.jar $JAVA_OPTS CMD sleep 60; java -jar maxkey-mgt-boot.jar $JAVA_OPTS

View File

@ -1,8 +1,44 @@
buildscript {
repositories {
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/'}
}
dependencies {
//springboot jar
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
plugins {
id 'org.springframework.boot' version "${springBootVersion}"
id "io.spring.dependency-management" version "1.0.11.RELEASE"
}
description = "maxkey-web-mgt" description = "maxkey-web-mgt"
//springboot jar
apply plugin: 'io.spring.dependency-management'
//add support for Java //add support for Java
apply plugin: 'java' apply plugin: 'java'
bootJar {
dependsOn jar
archiveBaseName = 'maxkey-mgt-boot'
version = "${project.version}-ga"
mainClass = 'org.dromara.maxkey.MaxKeyMgtApplication'
manifest {
attributes(
"Implementation-Title": project.name,
"Implementation-Vendor": project.vendor,
"Created-By": project.author,
"Implementation-Date": java.time.ZonedDateTime.now(),
"Implementation-Version": project.version
)
}
}
dependencies { dependencies {
implementation project(":maxkey-common") implementation project(":maxkey-common")
implementation project(":maxkey-core") implementation project(":maxkey-core")
@ -17,12 +53,8 @@ dependencies {
implementation project(":maxkey-protocols:maxkey-protocol-oauth-2.0") implementation project(":maxkey-protocols:maxkey-protocol-oauth-2.0")
implementation project(":maxkey-protocols:maxkey-protocol-saml-2.0") implementation project(":maxkey-protocols:maxkey-protocol-saml-2.0")
//rest apis //synchronizers
implementation project(":maxkey-web-apis:maxkey-web-api-scim")
implementation project(":maxkey-web-apis:maxkey-web-api-rest")
//synchronizers
implementation project(":maxkey-synchronizers:maxkey-synchronizer") implementation project(":maxkey-synchronizers:maxkey-synchronizer")
implementation project(":maxkey-synchronizers:maxkey-synchronizer-activedirectory") implementation project(":maxkey-synchronizers:maxkey-synchronizer-activedirectory")
implementation project(":maxkey-synchronizers:maxkey-synchronizer-feishu") implementation project(":maxkey-synchronizers:maxkey-synchronizer-feishu")
@ -30,5 +62,4 @@ dependencies {
implementation project(":maxkey-synchronizers:maxkey-synchronizer-ldap") implementation project(":maxkey-synchronizers:maxkey-synchronizer-ldap")
implementation project(":maxkey-synchronizers:maxkey-synchronizer-workweixin") implementation project(":maxkey-synchronizers:maxkey-synchronizer-workweixin")
implementation project(":maxkey-synchronizers:maxkey-synchronizer-dingtalk") implementation project(":maxkey-synchronizers:maxkey-synchronizer-dingtalk")
}
}

View File

@ -1,4 +1,4 @@
FROM adoptopenjdk:8-jre FROM openjdk:17-jdk-alpine
RUN mkdir -p /maxkey-openapi RUN mkdir -p /maxkey-openapi
@ -10,6 +10,6 @@ COPY ${JAR_FILE} maxkey-openapi-boot.jar
EXPOSE 9525 EXPOSE 9525
ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom" ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms256m -Xmx2048m -Djava.security.egd=file:/dev/./urandom"
CMD sleep 60; java -jar maxkey-openapi-boot.jar $JAVA_OPTS CMD sleep 60; java -jar maxkey-openapi-boot.jar $JAVA_OPTS

View File

@ -1,8 +1,44 @@
buildscript {
repositories {
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/'}
}
dependencies {
//springboot jar
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
plugins {
id 'org.springframework.boot' version "${springBootVersion}"
id "io.spring.dependency-management" version "1.0.11.RELEASE"
}
description = "maxkey-web-openapi" description = "maxkey-web-openapi"
//springboot jar
apply plugin: 'io.spring.dependency-management'
//add support for Java //add support for Java
apply plugin: 'java' apply plugin: 'java'
bootJar {
dependsOn jar
archiveBaseName = 'maxkey-openapi-boot'
version = "${project.version}-ga"
mainClass = 'org.dromara.maxkey.MaxKeyOpenApiApplication'
manifest {
attributes(
"Implementation-Title": project.name,
"Implementation-Vendor": project.vendor,
"Created-By": project.author,
"Implementation-Date": java.time.ZonedDateTime.now(),
"Implementation-Version": project.version
)
}
}
dependencies { dependencies {
implementation project(":maxkey-common") implementation project(":maxkey-common")
implementation project(":maxkey-core") implementation project(":maxkey-core")
@ -18,8 +54,7 @@ dependencies {
implementation project(":maxkey-protocols:maxkey-protocol-oauth-2.0") implementation project(":maxkey-protocols:maxkey-protocol-oauth-2.0")
implementation project(":maxkey-protocols:maxkey-protocol-saml-2.0") implementation project(":maxkey-protocols:maxkey-protocol-saml-2.0")
//rest apis //webapis
implementation project(":maxkey-web-apis:maxkey-web-api-scim") implementation project(":maxkey-web-apis:maxkey-web-api-scim")
implementation project(":maxkey-web-apis:maxkey-web-api-rest") implementation project(":maxkey-web-apis:maxkey-web-api-rest")
}
}