Repackage Javapoet in org.springframework.javapoet

This commit repackages the Javapoet library into spring-core so that it
can be used by the AOT engine without requiring a specific version.

Closes gh-27828
This commit is contained in:
Stephane Nicoll 2022-01-06 14:52:48 +01:00
parent 7a2c9b80c2
commit dfae8effa8
3 changed files with 34 additions and 3 deletions

View File

@ -4,14 +4,17 @@ description = "Spring Core"
apply plugin: "kotlin" apply plugin: "kotlin"
// spring-core includes asm and repackages cglib, inlining both into the spring-core jar. // spring-core includes asm, javapoet and repackages cglib, inlining all into the
// cglib itself depends on asm and is therefore further transformed by the ShadowJar task to // spring-core jar. cglib itself depends on asm and is therefore further transformed by
// depend on org.springframework.asm; this avoids including two different copies of asm. // the ShadowJar task to depend on org.springframework.asm; this avoids including two
// different copies of asm.
def cglibVersion = "3.3.0" def cglibVersion = "3.3.0"
def javapoetVersion = "1.13.0"
def objenesisVersion = "3.2" def objenesisVersion = "3.2"
configurations { configurations {
cglib cglib
javapoet
objenesis objenesis
} }
@ -23,6 +26,13 @@ task cglibRepackJar(type: ShadowJar) {
relocate 'org.objectweb.asm', 'org.springframework.asm' relocate 'org.objectweb.asm', 'org.springframework.asm'
} }
task javapoetRepackJar(type: ShadowJar) {
archiveBaseName.set('spring-javapoet-repack')
archiveVersion.set(javapoetVersion)
configurations = [project.configurations.javapoet]
relocate 'com.squareup.javapoet', 'org.springframework.javapoet'
}
task objenesisRepackJar(type: ShadowJar) { task objenesisRepackJar(type: ShadowJar) {
archiveBaseName.set('spring-objenesis-repack') archiveBaseName.set('spring-objenesis-repack')
archiveVersion.set(objenesisVersion) archiveVersion.set(objenesisVersion)
@ -32,8 +42,10 @@ task objenesisRepackJar(type: ShadowJar) {
dependencies { dependencies {
cglib("cglib:cglib:${cglibVersion}@jar") cglib("cglib:cglib:${cglibVersion}@jar")
javapoet("com.squareup:javapoet:${javapoetVersion}@jar")
objenesis("org.objenesis:objenesis:${objenesisVersion}@jar") objenesis("org.objenesis:objenesis:${objenesisVersion}@jar")
api(files(cglibRepackJar)) api(files(cglibRepackJar))
api(files(javapoetRepackJar))
api(files(objenesisRepackJar)) api(files(objenesisRepackJar))
api(project(":spring-jcl")) api(project(":spring-jcl"))
compileOnly("io.projectreactor.tools:blockhound") compileOnly("io.projectreactor.tools:blockhound")
@ -83,6 +95,11 @@ jar {
exclude "org/springframework/cglib/proxy/MethodProxy*.class" exclude "org/springframework/cglib/proxy/MethodProxy*.class"
} }
dependsOn javapoetRepackJar
from(zipTree(javapoetRepackJar.archivePath)) {
include "org/springframework/javapoet/**"
}
dependsOn objenesisRepackJar dependsOn objenesisRepackJar
from(zipTree(objenesisRepackJar.archivePath)) { from(zipTree(objenesisRepackJar.archivePath)) {
include "org/springframework/objenesis/**" include "org/springframework/objenesis/**"

View File

@ -0,0 +1,6 @@
/**
* Spring's repackaging of
* <a href="https://github.com/square/javapoet">JavaPoet</a>
* (with Spring-specific utilities; for internal use only).
*/
package org.springframework.javapoet;

View File

@ -255,6 +255,14 @@ CGLIB 3.3 is licensed under the Apache License, version 2.0, the text of which
is included above. is included above.
>>> JavaPoet 1.13.0 (com.squareup:javapoet:1.13.0):
Per the LICENSE file in the CGLIB JAR distribution downloaded from
https://github.com/square/javapoet/archive/refs/tags/javapoet-1.13.0.zip,
JavaPoet 1.13.0 is licensed under the Apache License, version 2.0, the text of
which is included above.
>>> Objenesis 3.1 (org.objenesis:objenesis:3.1): >>> Objenesis 3.1 (org.objenesis:objenesis:3.1):
Per the LICENSE file in the Objenesis ZIP distribution downloaded from Per the LICENSE file in the Objenesis ZIP distribution downloaded from