Как я могу исключить банки, используя Bootjar, похожий на CustomConfiguration в BootRepackage?JAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Как я могу исключить банки, используя Bootjar, похожий на CustomConfiguration в BootRepackage?

Сообщение Anonymous »

Недавно я выполнил весеннюю миграцию загрузки с 1.5.8 на 2.1.14-RELEASE и использовал gradle в качестве сценария сборки. Я использую плагины Spring-boot-gradle-plugin и Spring-Boot-Dependency-Management. Мы создаем 4 исполняемых файла jar (eureka, oAuth, apiGateWay, abcApplication), используя задачи gradle и упаковываем их в tar-файл. Перед миграцией во время создания jar-файлов некоторые jar-файлы исключались с помощью customConfiguration of BootRepackage. Из-за этого размер нашего tar-файла составил 650 МБ. Теперь после миграции размер tar-файла увеличился до 850 МБ. Когда я проверил файл tar, он добавил все банки из пути к классам времени выполнения. Итак, размер увеличился. Не могли бы вы помочь мне исключить банки, упомянутые в свойстве конфигурации, с помощью BootJar. Прямо сейчас мы используем конфигурацию компиляции для всех зависимостей в gradle. Я упомянул полный файл Gradle.
buildscript {
repositories {
maven {
url '...'
...
}

}

ext {
springBootVersion = '2.1.14.RELEASE'
springCloudVersion = 'Greenwich.SR4'
springRetryVersion = "1.2.3.RELEASE"
}

dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.13.0"
}
ext['tomcat.version'] = '8.5.64'
ext['jackson.version'] = '2.11.2'
ext['hibernate.version'] = '5.4.24.Final'
ext['snakeyaml.version'] = '1.26'
}
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'idea'
apply plugin: "com.jfrog.artifactory"
apply plugin: 'io.spring.dependency-management'

sourceCompatibility = 1.8

ext {
excludeCLoudJar = '**spring-cloud-config-server*'
exludedJarsForEureka = ['**spring-cloud-config-server*', '**poi-ooxml*', '**guava*', '**ojdbc8*', '**springfox-swagger2*', '**springfox-swagger-ui*']
}

configurations.all {
resolutionStrategy {
force 'org.bouncycastle:bcpkix-jdk15on:1.64'
}
}
configurations {
all*.exclude group: 'aopalliance'
cloudconfigexclusion.exclude group: 'org.springframework.cloud', module: 'spring-cloud-config-server'
cloudconfigexclusion.extendsFrom(compile)
}
configurations {
eurekaconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-config-server'
eurekaconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-config-client'
eurekaconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-starter-config'
eurekaconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-starter-oauth2'
eurekaconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-starter-zuul'
eurekaconfiguration.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-data-jpa'
eurekaconfiguration.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-aop'
eurekaconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-config'
eurekaconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-crypto'
eurekaconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-core'
eurekaconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-web'
eurekaconfiguration.exclude group: 'org.apache.poi'
eurekaconfiguration.exclude group: 'com.opencsv'
eurekaconfiguration.exclude group: 'org.springframework.retry'
eurekaconfiguration.exclude group: 'com.oracle', module: 'ojdbc8'
eurekaconfiguration.extendsFrom(compile)
}

configurations {
zuulconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-config-server'
zuulconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-config-client'
zuulconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-starter-oauth2'
zuulconfiguration.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-data-jpa'
zuulconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-config'
zuulconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-crypto'
zuulconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-core'
zuulconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-web'
zuulconfiguration.exclude group: 'org.apache.poi'
zuulconfiguration.exclude group: 'com.opencsv'
zuulconfiguration.exclude group: 'com.oracle', module: 'ojdbc8'
zuulconfiguration.extendsFrom(compile)
}

configurations {
cloudconfigconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-starter-oauth2'
cloudconfigconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-config-client'
cloudconfigconfiguration.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-data-jpa'
cloudconfigconfiguration.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-aop'
cloudconfigconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-config'
cloudconfigconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-crypto'
cloudconfigconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-core'
cloudconfigconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-web'
cloudconfigconfiguration.exclude group: 'org.apache.poi'
cloudconfigconfiguration.exclude group: 'com.opencsv'
cloudconfigconfiguration.exclude group: 'org.springframework.retry'
cloudconfigconfiguration.exclude group: 'com.oracle', module: 'ojdbc8'
cloudconfigconfiguration.extendsFrom(compile)
}

mainClassName = "..."

// During Migration changed from Jar to BootJar
task eurekaAppJar(type: BootJar) {
baseName = 'eurekaJar'
version = '0.0.1'
println sourceSets.main.output
manifest {
attributes 'Main-Class': "org.springframework.boot.loader.JarLauncher"
attributes 'Start-Class': "com.abc.abcCompany.service.eurekaApp.EurekaApplication"
attributes 'Implementation-Version': "001"
}
bootJar {
mainClassName = "com.abc.abcCompany.service.eurekaApp.EurekaApplication"
}
classpath sourceSets.main.runtimeClasspath
}
// During Migration changed from Jar to BootJar
task oAuthConfigJar(type: BootJar) {
baseName = 'oAuthConfigJar'
version = '0.0.1'

manifest {
attributes 'Main-Class': "org.springframework.boot.loader.JarLauncher"
attributes 'Start-Class': "com.abc.abcCompany.service.authserver.AuthServerApplication"
attributes 'Implementation-Version': "001"

}
springBoot {
mainClassName = "com.abcCompany.service.authserver.AuthServerApplication"
}
classpath sourceSets.main.runtimeClasspath
}
// During migration changed from BootRepackage to BootJar
task eurekaBoot(type: BootJar, dependsOn: eurekaAppJar) {
mainClassName = 'com.abc.abcCompany.service.eurekaApp.EurekaApplication'
// During migration commented the below code. The below code helped to exclude jars using BootRepackage
// customConfiguration = "eurekaconfiguration"
// withJarTask = eztrackerEurekaJar
}

// During migration changed from BootRepackage to BootJar
task oAuthConfigJarBoot(type: BootJar, dependsOn: oAuthConfigJar) {
mainClassName = 'com.abc.abcCompany.service.authserver.AuthServerApplication'
// During migration commented the below code. The below code helped to exclude jars using BootRepackage
// customConfiguration = "zuulconfiguration"
// withJarTask = eztrackerApiGatewayJar
}

dependencies {
runtime("org.springframework.boot:spring-boot-properties-migrator")
compile("org.springframework.cloud:spring-cloud-starter-netflix-eureka-server")
compile("org.springframework.cloud:spring-cloud-starter-netflix-eureka-client")

compile group: 'com.google.guava', name: 'guava', version: '30.0-jre'

compile("org.springframework.cloud:spring-cloud-starter-netflix-zuul")

implementation('org.springframework.cloud:spring-cloud-starter-oauth2')
implementation('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-web')
compile(group: 'com.oracle.jdbc', name: 'ojdbc8', version: '12.2.0.1')
compile("io.springfox:springfox-swagger2:2.9.2")
compile("io.springfox:springfox-swagger-ui:2.9.2")
testCompile('org.springframework.boot:spring-boot-starter-test')
compile("org.apache.poi:poi-ooxml:4.1.2")
compile 'com.opencsv:opencsv:5.2'
compile "javax.mail:mail:1.4.4"
compile("org.springframework.cloud:spring-cloud-config-server")
compile("org.springframework.cloud:spring-cloud-config-client:1.4.6.RELEASE") {
force = true
}

compile("org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-aop")
compile("org.springframework.retry:spring-retry:${springRetryVersion}")
compile("org.springframework.boot:spring-boot-starter-web-services")
compile('com.thoughtworks.xstream:xstream:1.4.10') {
force = true
}
compile('commons-io:commons-io:2.7') {
force = true
}
compile('io.netty:netty-transport:4.1.63.Final') {
force = true
}
compile('io.netty:netty-transport-native-epoll:4.1.63.Final') {
force = true
}
compile('org.dom4j:dom4j:2.1.3') {
force = true
}
compile("wsdl4j:wsdl4j:1.6.1")
compile('io.netty:netty-codec:4.1.63.Final') {
force = true
}
compile('org.apache.commons:commons-math3:3.6') {
force = true
}
compile('org.springframework:spring-expression:5.2.12.RELEASE') {
force = true
}
compile('io.netty:netty-codec-http:4.1.63.Final') {
force = true
}
compile('com.thoughtworks.xstream:xstream:1.4.16') {
force = true
}
compile('commons-beanutils:commons-beanutils:1.9.4') {
force = true
}

compile group: 'org.postgresql', name: 'postgresql', version: '42.2.13'

compile group: 'commons-dbcp', name: 'commons-dbcp', version: '1.4'
}

bootJar.enabled = false // disable default bootRepackage since we have custom repackage tasks
// bootJar.withJarTask = jar // use custom Jar repackaging using the generated jar from the jar tasks
bootJar.dependsOn = [oAuthConfigJarBoot, eurekaBoot, ...]

distTar() {

from('scripts') {
include '**/*'
into 'bin'
}
from(oAuthConfigJar.archivePath)
from(eurekaJar.archivePath)
from(abcApplicationApiGatewayJar.archivePath)
from(cloudConfigServerJar.archivePath)

archiveName 'abcApplicationService.tar'
}

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}



Подробнее здесь: https://stackoverflow.com/questions/684 ... n-in-bootr
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»