Skip to content

Commit dfae8ef

Browse files
committed
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
1 parent 7a2c9b8 commit dfae8ef

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

spring-core/spring-core.gradle

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ description = "Spring Core"
44

55
apply plugin: "kotlin"
66

7-
// spring-core includes asm and repackages cglib, inlining both into the spring-core jar.
8-
// cglib itself depends on asm and is therefore further transformed by the ShadowJar task to
9-
// depend on org.springframework.asm; this avoids including two different copies of asm.
7+
// spring-core includes asm, javapoet and repackages cglib, inlining all into the
8+
// spring-core jar. cglib itself depends on asm and is therefore further transformed by
9+
// the ShadowJar task to depend on org.springframework.asm; this avoids including two
10+
// different copies of asm.
1011
def cglibVersion = "3.3.0"
12+
def javapoetVersion = "1.13.0"
1113
def objenesisVersion = "3.2"
1214

1315
configurations {
1416
cglib
17+
javapoet
1518
objenesis
1619
}
1720

@@ -23,6 +26,13 @@ task cglibRepackJar(type: ShadowJar) {
2326
relocate 'org.objectweb.asm', 'org.springframework.asm'
2427
}
2528

29+
task javapoetRepackJar(type: ShadowJar) {
30+
archiveBaseName.set('spring-javapoet-repack')
31+
archiveVersion.set(javapoetVersion)
32+
configurations = [project.configurations.javapoet]
33+
relocate 'com.squareup.javapoet', 'org.springframework.javapoet'
34+
}
35+
2636
task objenesisRepackJar(type: ShadowJar) {
2737
archiveBaseName.set('spring-objenesis-repack')
2838
archiveVersion.set(objenesisVersion)
@@ -32,8 +42,10 @@ task objenesisRepackJar(type: ShadowJar) {
3242

3343
dependencies {
3444
cglib("cglib:cglib:${cglibVersion}@jar")
45+
javapoet("com.squareup:javapoet:${javapoetVersion}@jar")
3546
objenesis("org.objenesis:objenesis:${objenesisVersion}@jar")
3647
api(files(cglibRepackJar))
48+
api(files(javapoetRepackJar))
3749
api(files(objenesisRepackJar))
3850
api(project(":spring-jcl"))
3951
compileOnly("io.projectreactor.tools:blockhound")
@@ -83,6 +95,11 @@ jar {
8395
exclude "org/springframework/cglib/proxy/MethodProxy*.class"
8496
}
8597

98+
dependsOn javapoetRepackJar
99+
from(zipTree(javapoetRepackJar.archivePath)) {
100+
include "org/springframework/javapoet/**"
101+
}
102+
86103
dependsOn objenesisRepackJar
87104
from(zipTree(objenesisRepackJar.archivePath)) {
88105
include "org/springframework/objenesis/**"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Spring's repackaging of
3+
* <a href="https://github.com/square/javapoet">JavaPoet</a>
4+
* (with Spring-specific utilities; for internal use only).
5+
*/
6+
package org.springframework.javapoet;

src/docs/dist/license.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,14 @@ CGLIB 3.3 is licensed under the Apache License, version 2.0, the text of which
255255
is included above.
256256

257257

258+
>>> JavaPoet 1.13.0 (com.squareup:javapoet:1.13.0):
259+
260+
Per the LICENSE file in the CGLIB JAR distribution downloaded from
261+
https://github.com/square/javapoet/archive/refs/tags/javapoet-1.13.0.zip,
262+
JavaPoet 1.13.0 is licensed under the Apache License, version 2.0, the text of
263+
which is included above.
264+
265+
258266
>>> Objenesis 3.1 (org.objenesis:objenesis:3.1):
259267

260268
Per the LICENSE file in the Objenesis ZIP distribution downloaded from

0 commit comments

Comments
 (0)