11ext {
22 jakartaSpringVersion = ' 6.0.0'
33 jakartaSpringBootVersion = ' 3.0.0'
4-
5- javaxSpringVersion = ' 5.3.20'
6- javaxSpringBootVersion = ' 2.5.14'
74}
85
96apply plugin : ' java-library'
@@ -15,190 +12,42 @@ repositories {
1512java {
1613 withJavadocJar()
1714 toolchain {
18- languageVersion. set(JavaLanguageVersion . of(8 ))
15+ languageVersion. set(JavaLanguageVersion . of(17 ))
1916 }
2017}
2118
22- // We use 3 custom configurations and matching sourceSets to avoid the standard behaviours which interfere with
23- // our compilation structure
24- configurations {
25- compileCommon
26- compileJavax
27- compileJakarta
28- }
29-
30- sourceSets {
31- common {
32- java
33- // common.compileClasspath includes the compileJavax classpath in order to give the common classes access
34- // to Spring without confusing the dependencies, including it here ensures that any use of javax.* packages
35- // in src/common will result in test failures (although not compile failures)
36- // we need the javax.* packages included here so that the compiler can type-check all the way up the hierarchy
37- // for things like "ServletRequestBindingException extends ServletException"
38- compileClasspath + = configurations. compileCommon + configurations. compileJavax
39- }
40- javax {
41- java
42- compileClasspath + = configurations. compileJavax + common. output + configurations. compileCommon
43- }
44- jakarta {
45- java
46- compileClasspath + = configurations. compileJakarta + common. output + configurations. compileCommon
47- }
48- }
49-
50- // test sourceSets
51- sourceSets {
52- commonTest {
53- java
54- }
55- javaxTest {
56- java
57- compileClasspath + = javax. output + javax. compileClasspath + commonTest. output + commonTest. runtimeClasspath + common. output
58- runtimeClasspath = compileClasspath
59- }
60- jakartaTest {
61- java
62- compileClasspath + = jakarta. output + jakarta. compileClasspath + commonTest. output + commonTest. runtimeClasspath + common. output
63- runtimeClasspath = compileClasspath
64- }
65- }
6619
6720tasks. register(' sourceJar' , Jar ). configure {
68- from(
69- sourceSets. common. allJava,
70- sourceSets. javax. allJava,
71- sourceSets. jakarta. allJava
72- )
21+ from sourceSets. main. allJava
7322}
7423
7524// do not move this higher - sourceJar must be registered before we apply common.gradle
7625apply from : ' ../common.gradle'
7726
78- compileJava. dependsOn(compileCommonJava, compileJavaxJava, compileJakartaJava)
79-
80- // Separated Javax / Jakarta tests -------------------------------------------------------------------------------------
81-
82- compileJakartaJava {
83- // set the compiler for the `jakarta` sourceSet to Java17
84- javaCompiler. set(
85- javaToolchains. compilerFor {
86- languageVersion = JavaLanguageVersion . of(17 )
87- }
88- )
89- }
90-
91- compileJakartaTestJava {
92- // set the compiler for the `jakartaTest` sourceSet to Java17
93- javaCompiler. set(
94- javaToolchains. compilerFor {
95- languageVersion = JavaLanguageVersion . of(17 )
96- }
97- )
98- }
99-
100- testClasses. dependsOn(javaxTestClasses, jakartaTestClasses)
101-
102- tasks. register(' testJakarta' , Test ) {
103- testClassesDirs = sourceSets. jakartaTest. output. classesDirs
104- classpath = sourceSets. jakartaTest. output. classesDirs + sourceSets. jakartaTest. runtimeClasspath
105- javaLauncher. set(
106- javaToolchains. launcherFor {
107- languageVersion = JavaLanguageVersion . of(17 )
108- }
109- )
110-
111- dependsOn(jakartaTestClasses)
112- }
113-
114- tasks. register(' testJavax' , Test ) {
115- testClassesDirs = sourceSets. javaxTest. output. classesDirs
116- classpath = sourceSets. javaxTest. output. classesDirs + sourceSets. javaxTest. runtimeClasspath
117- javaLauncher. set(
118- javaToolchains. launcherFor {
119- languageVersion = JavaLanguageVersion . of(8 )
120- }
121- )
122-
123- dependsOn(javaxTestClasses)
124- }
125-
126- test. dependsOn(testJakarta, testJavax)
127-
128- dependencies {
129- compileCommon project(' :bugsnag' )
130-
131- compileCommon " ch.qos.logback:logback-core:${ logbackVersion} "
132- compileCommon " org.slf4j:slf4j-api:${ slf4jApiVersion} "
133-
134- compileJavax " javax.servlet:javax.servlet-api:${ javaxServletApiVersion} "
135- compileJavax " org.springframework:spring-webmvc:${ javaxSpringVersion} "
136- compileJavax " org.springframework.boot:spring-boot:${ javaxSpringBootVersion} "
137- compileJavax " org.springframework:spring-aop:${ javaxSpringVersion} "
138-
139- compileJakarta " jakarta.servlet:jakarta.servlet-api:${ jakartaServletApiVersion} "
140- compileJakarta " org.springframework:spring-webmvc:${ jakartaSpringVersion} "
141- compileJakarta " org.springframework.boot:spring-boot:${ jakartaSpringBootVersion} "
142- compileJakarta " org.springframework:spring-aop:${ jakartaSpringVersion} "
143-
144-
145- commonTestImplementation project(' :bugsnag' ). sourceSets. test. output
146- commonTestImplementation project(' :bugsnag' )
147-
148- commonTestImplementation " junit:junit:${ junitVersion} "
149-
150- commonTestCompileOnly " org.mockito:mockito-core:2.10.0"
151-
152- jakartaTestImplementation " org.mockito:mockito-core:${ mockitoVersion} "
153- jakartaTestImplementation " jakarta.servlet:jakarta.servlet-api:${ jakartaServletApiVersion} "
154- jakartaTestImplementation " org.springframework.boot:spring-boot-starter-test:${ jakartaSpringBootVersion} "
155- jakartaTestImplementation " org.springframework.boot:spring-boot-starter-web:${ jakartaSpringBootVersion} "
156- jakartaTestImplementation " org.springframework:spring-aop:${ jakartaSpringVersion} "
157-
158- javaxTestImplementation " org.mockito:mockito-core:2.10.0"
159- javaxTestImplementation " javax.servlet:javax.servlet-api:${ javaxServletApiVersion} "
160- javaxTestImplementation " org.springframework.boot:spring-boot-starter-test:${ javaxSpringBootVersion} "
161- javaxTestImplementation " org.springframework.boot:spring-boot-starter-web:${ javaxSpringBootVersion} "
162- javaxTestImplementation " org.springframework:spring-aop:${ javaxSpringVersion} "
163- }
164-
16527dependencies {
166- // ensure that the published .pom file includes a dependency on com.bugsnag:bugsnag
167- // this 'api' dependency has no impact on the compilation of this projects source,
168- // so we keep it in it's own dependencies block
169- api project(' :bugsnag' )
170- }
171-
172- // here is where we merge all of the class outputs into the default classes directory doing this as its own step avoids
173- // circular dependencies between the sourceSets and their output directories (if they all use 'main.output.classesDirs'
174- // then jakarta+javax both depend on it as well)
175- tasks. register(' mergeClasses' , Copy ) {
176- from sourceSets. common. output. classesDirs
177- from sourceSets. jakarta. output. classesDirs
178- from sourceSets. javax. output. classesDirs
179-
180- into sourceSets. main. output. classesDirs. asPath
181- }
182-
183- classes. dependsOn(' mergeClasses' )
184-
185- if (project. hasProperty(' releasing' )) {
186- publishing {
187- publications {
188- Publication (MavenPublication ) {
189- // this is vital: we use the version details from the "javax" side of the project
190- // this ensures that Gradle considers that as the baseline set of required versions
191- // allowing old projects that still use Java8 and the javax.servlet packages to use
192- // bugsnag-java without any secondary artifacts
193- versionMapping {
194- usage(' java-api' ) {
195- fromResolutionOf(' compileCommon' )
196- }
197- usage(' java-runtime' ) {
198- fromResolutionOf(' compileCommon' )
199- }
200- }
201- }
202- }
203- }
204- }
28+ implementation project(' :bugsnag' )
29+
30+ implementation " ch.qos.logback:logback-core:${ logbackVersion} "
31+ implementation " org.slf4j:slf4j-api:${ slf4jApiVersion} "
32+
33+ implementation " jakarta.servlet:jakarta.servlet-api:${ jakartaServletApiVersion} "
34+ implementation " org.springframework:spring-webmvc:${ jakartaSpringVersion} "
35+ implementation " org.springframework.boot:spring-boot:${ jakartaSpringBootVersion} "
36+ implementation " org.springframework:spring-aop:${ jakartaSpringVersion} "
37+
38+ testImplementation project(' :bugsnag' ). sourceSets. test. output
39+ testImplementation project(' :bugsnag' )
40+ testImplementation " junit:junit:${ junitVersion} "
41+ testImplementation " org.springframework.boot:spring-boot-starter-test:${ jakartaSpringBootVersion} "
42+ testImplementation " org.springframework.boot:spring-boot-starter-web:${ jakartaSpringBootVersion} "
43+ testImplementation " org.junit.jupiter:junit-jupiter:5.8.2"
44+ testCompileOnly " org.mockito:mockito-core:2.10.0"
45+ }
46+
47+ /* * ---- Publishing config ----
48+ * Pulls in publishing+signing rules from the shared release.gradle.
49+ * This will create tasks like:
50+ * :bugsnag:publishMavenJavaPublicationToTestRepository
51+ * :bugsnag:publishMavenJavaPublicationToOssrhStagingRepository
52+ */
53+ apply from : " ${ rootProject.projectDir} /release.gradle"
0 commit comments