Skip to content

Commit d7b63b1

Browse files
rjrudinMarkLogic Builder
authored andcommitted
DHFPROD-4854: Removing Spring Boot dependency from DHF core
Spring Boot was never needed; Spring is still being used heavily. And Spring Boot is still used by the QS and HC projects.
1 parent 0bb249f commit d7b63b1

File tree

8 files changed

+42
-69
lines changed

8 files changed

+42
-69
lines changed

marklogic-data-hub/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
src/main/resources/ml-modules/root/data-hub/third-party
2+
src/trace-ui/package-lock.json

marklogic-data-hub/build.gradle

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ plugins {
66
id 'com.jfrog.bintray' version '1.7.2'
77
id 'com.marklogic.ml-gradle' version '4.1.1'
88
id "com.github.node-gradle.node" version "2.2.4"
9-
id 'org.springframework.boot' version '2.1.15.RELEASE'
10-
id "io.spring.dependency-management" version "1.0.7.RELEASE"
119
id 'com.marklogic.ml-development-tools' version '5.3.0'
1210

1311
// Declaring this at each subproject level, as declaring it at root level resulted in an error about the plugin
@@ -71,9 +69,6 @@ dependencies {
7169
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-common'
7270
}
7371

74-
compile group: 'org.springframework.boot', name: 'spring-boot', version: '2.1.15.RELEASE'
75-
compile group: 'org.springframework.boot', name: 'spring-boot-autoconfigure', version: '2.1.15.RELEASE'
76-
7772
compile 'com.marklogic:mlcp-util:0.9.0'
7873
compile 'com.marklogic:marklogic-data-movement-components:2.2.1'
7974

@@ -115,15 +110,24 @@ dependencies {
115110
mlBundle "com.marklogic:marklogic-unit-test-modules:1.0.0"
116111
}
117112

118-
import com.marklogic.mgmt.ManageClient
119-
import com.marklogic.mgmt.resource.hosts.HostManager
120-
121-
122113
configurations.all {
123114
exclude group: "org.slf4j", module: "slf4j-log4j12"
124115
exclude group: "log4j", module: "log4j"
125116
}
126117

118+
ext {
119+
uberJarLoggingClasses = configurations.datahubLogging.collect { it.isDirectory() ? it : zipTree(it) }
120+
121+
// Because this is evaluated eagerly, the project dependency classes directory main not yet exist.
122+
// But if it ends in "main", we know it's a directory and should not be zipped, which causes an error.
123+
// The path likely ends in "build/classes/java/main", but we only need to check for "main" (and could
124+
// likely only check that it doesn't end in ".jar", but checking for "main" suffices for now).
125+
uberJarClasses = configurations.compileClasspath.collect({
126+
def isProjectDependencyClassesPath = "main".equals(it.getName())
127+
return it.isDirectory() || isProjectDependencyClassesPath ? it : zipTree(it)
128+
})
129+
}
130+
127131
task extractFastXmlParserZip(type: Copy) {
128132
doFirst {
129133
new File(thirdPartySourcePath).mkdirs()
@@ -136,21 +140,28 @@ task extractFastXmlParserZip(type: Copy) {
136140
// Ensure that the fast-xml-parser files are available before any DHF jars are built
137141
processResources.dependsOn extractFastXmlParserZip
138142

139-
140-
// The Spring Boot bootJar task produces an executable jar with all dependencies that runs the DHF installer
141-
// This jar is only meant to be used by the DHS team for installing DHF into DHS
142-
bootJar {
143+
task installerJar(type: Jar) {
144+
description = "Build an executable jar for installing DHF into DHS"
145+
manifest {
146+
attributes "Main-Class": "com.marklogic.hub.dhs.installer.Main"
147+
}
143148
archiveClassifier = "installer"
144-
mainClassName = "com.marklogic.hub.dhs.installer.Main"
145-
from("src/main/installer") {
146-
include "logback.xml"
149+
from(uberJarLoggingClasses) {
150+
exclude "META-INF/*.SF"
151+
exclude "META-INF/*.DSA"
152+
exclude "META-INF/*.RSA"
147153
}
148-
from(configurations.datahubLogging.collect { it.isDirectory() ? it : zipTree(it) }) {
154+
from(uberJarClasses) {
149155
exclude "META-INF/*.SF"
150156
exclude "META-INF/*.DSA"
151157
exclude "META-INF/*.RSA"
152158
}
159+
from("src/main/installer") {
160+
include "logback.xml"
161+
}
162+
with jar
153163
}
164+
build.dependsOn installerJar
154165

155166
task installDhfIntoDhs(type: Exec) {
156167
description = "Builds and runs the DHF installer for DHS"
@@ -165,25 +176,24 @@ task installDhfIntoDhs(type: Exec) {
165176
"dhsInstall"
166177
]
167178
}
168-
installDhfIntoDhs.dependsOn bootJar
179+
installDhfIntoDhs.dependsOn installerJar
169180

170181
task clientJar(type: Jar) {
171182
description = "Build an executable jar to be used by DHF clients; as of 5.2.0, this is just for running flows"
172183
manifest {
173184
attributes "Main-Class": "com.marklogic.hub.cli.client.Main"
174185
}
175186
archiveClassifier = "client"
176-
from(configurations.datahubLogging.collect { it.isDirectory() ? it : zipTree(it) }) {
187+
from(uberJarLoggingClasses) {
177188
exclude "META-INF/*.SF"
178189
exclude "META-INF/*.DSA"
179190
exclude "META-INF/*.RSA"
180191
}
181-
from(configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }) {
192+
from(uberJarClasses) {
182193
exclude "META-INF/*.SF"
183194
exclude "META-INF/*.DSA"
184195
exclude "META-INF/*.RSA"
185196
}
186-
exclude "spring-boot*.jar"
187197
from("src/main/clientJar") {
188198
include "logback.xml"
189199
}
@@ -291,10 +301,6 @@ jar{
291301
enabled = true
292302
}
293303

294-
bootRun {
295-
enabled = false
296-
}
297-
298304
javadoc {
299305
options.overview = 'src/main/resources/overview.html'
300306
}
@@ -340,7 +346,7 @@ publishing {
340346
from components.java
341347
artifact sourcesJar
342348
artifact javadocJar
343-
artifact bootJar
349+
artifact installerJar
344350
artifact clientJar
345351

346352
pom.withXml {
@@ -519,4 +525,4 @@ task testUnit(type: Test) {
519525
// Avoids a bug in Java 1.8 with reading zip files in our tests. See https://bugs.openjdk.java.net/browse/JDK-8156179
520526
tasks.withType(Test) {
521527
jvmArgs += "-Dsun.zip.disableMemoryMapping=true"
522-
}
528+
}

marklogic-data-hub/src/main/java/com/marklogic/hub/ApplicationConfig.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
import com.marklogic.hub.impl.HubConfigImpl;
44
import com.marklogic.hub.impl.HubProjectImpl;
5-
import org.slf4j.LoggerFactory;
6-
import org.springframework.boot.SpringApplication;
7-
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
85
import org.springframework.context.annotation.Bean;
96
import org.springframework.context.annotation.ComponentScan;
107
import org.springframework.context.annotation.Configuration;
@@ -16,7 +13,6 @@
1613
@Configuration
1714
@ComponentScan(basePackages = {"com.marklogic.hub.impl", "com.marklogic.hub.legacy.impl", "com.marklogic.hub.deploy.commands",
1815
"com.marklogic.hub.job.impl", "com.marklogic.hub.flow.impl", "com.marklogic.hub.step", "com.marklogic.hub.util"})
19-
@EnableAutoConfiguration
2016
public class ApplicationConfig {
2117

2218
/**
@@ -30,10 +26,6 @@ HubConfig hubConfig() {
3026
return new HubConfigImpl(new HubProjectImpl());
3127
}
3228

33-
public static void main(String[] args) {
34-
LoggerFactory.getLogger(ApplicationConfig.class).info("Starting Data Hub Application Context");
35-
SpringApplication.run(ApplicationConfig.class);
36-
}
3729

3830
}
3931

marklogic-data-hub/src/main/java/com/marklogic/hub/dhs/installer/Main.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
import com.marklogic.hub.dhs.installer.command.CanInstallDhsCommand;
77
import com.marklogic.hub.dhs.installer.command.InstallIntoDhsCommand;
88
import com.marklogic.hub.dhs.installer.command.VerifyDhfInDhsCommand;
9-
import org.springframework.boot.Banner;
10-
import org.springframework.boot.SpringApplication;
119
import org.springframework.context.ConfigurableApplicationContext;
10+
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
1211

1312
/**
1413
* Intended for installing and upgrading DHF via a command-line interface. It is expected to be run as the main class
@@ -35,10 +34,7 @@ public static void main(String[] args) {
3534
} else {
3635
InstallerCommand command = (InstallerCommand) commander.getCommands().get(parsedCommand).getObjects().get(0);
3736

38-
SpringApplication app = new SpringApplication(ApplicationConfig.class);
39-
app.setBannerMode(Banner.Mode.OFF);
40-
41-
ConfigurableApplicationContext context = app.run();
37+
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfig.class);
4238
try {
4339
command.run(context, options);
4440
} finally {

marklogic-data-hub/src/test/java/com/marklogic/bootstrap/TestAppInstaller.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import com.marklogic.hub.deploy.commands.CreateGranularPrivilegesCommand;
1616
import com.marklogic.hub.deploy.commands.GenerateFunctionMetadataCommand;
1717
import com.marklogic.hub.test.HubConfigInterceptor;
18-
import com.marklogic.hub.test.HubConfigObjectFactory;
1918
import com.marklogic.hub.test.HubCoreTestConfig;
2019
import com.marklogic.mgmt.ManageClient;
2120
import com.marklogic.mgmt.api.API;
@@ -27,10 +26,9 @@
2726
import com.marklogic.mgmt.resource.security.PrivilegeManager;
2827
import org.slf4j.Logger;
2928
import org.slf4j.LoggerFactory;
30-
import org.springframework.boot.SpringApplication;
31-
import org.springframework.boot.WebApplicationType;
3229
import org.springframework.context.ApplicationContext;
3330
import org.springframework.context.ConfigurableApplicationContext;
31+
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
3432
import org.springframework.core.io.ClassPathResource;
3533
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
3634

@@ -43,27 +41,24 @@ public class TestAppInstaller {
4341
private final static Logger logger = LoggerFactory.getLogger(TestAppInstaller.class);
4442

4543
public static void main(String[] args) {
46-
SpringApplication app = new SpringApplication(HubCoreTestConfig.class);
47-
app.setWebApplicationType(WebApplicationType.NONE);
48-
ConfigurableApplicationContext ctx = app.run();
44+
ConfigurableApplicationContext applicationContext = new AnnotationConfigApplicationContext(HubCoreTestConfig.class);
4945
try {
50-
HubConfigObjectFactory factory = ctx.getBean(HubConfigInterceptor.class).getHubConfigObjectFactory();
51-
String[] hosts = factory.getHosts();
46+
String[] hosts = applicationContext.getBean(HubConfigInterceptor.class).getHubConfigObjectFactory().getHosts();
5247
logger.info("Will install test app on hosts: " + Arrays.asList(hosts));
5348
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
5449
taskExecutor.setCorePoolSize(hosts.length);
5550
taskExecutor.setMaxPoolSize(hosts.length);
5651
taskExecutor.setWaitForTasksToCompleteOnShutdown(true);
5752
taskExecutor.afterPropertiesSet();
5853
for (int i = 0; i < hosts.length; i++) {
59-
taskExecutor.execute(new InstallerThread(ctx));
54+
taskExecutor.execute(new InstallerThread(applicationContext));
6055
}
6156
// Installation should normally just take a couple minutes
6257
taskExecutor.setAwaitTerminationSeconds(600);
6358
taskExecutor.shutdown();
6459
logger.info("Finished installing test app on hosts: " + Arrays.asList(hosts));
6560
} finally {
66-
ctx.close();
61+
applicationContext.close();
6762
// LoadUserModulesCommand may cause hanging because its thread pool is not shutdown;
6863
// will investigate in 5.5.0, doing system.exit for now
6964
System.exit(0);

ml-data-hub-plugin/build.gradle

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ plugins {
3131
id "java-gradle-plugin"
3232
id "maven-publish"
3333
id "com.jfrog.bintray" version "1.7.3"
34-
id 'org.springframework.boot' version '2.1.3.RELEASE'
35-
id "io.spring.dependency-management" version "1.0.7.RELEASE"
3634

3735
id "io.snyk.gradle.plugin.snykplugin" version "0.4"
3836
}
@@ -42,7 +40,6 @@ apply plugin: "com.gradle.plugin-publish"
4240
sourceCompatibility = "8"
4341
targetCompatibility = "8"
4442

45-
bootJar.enabled = false
4643
jar.enabled = true
4744

4845
// See https://github.com/snyk/gradle-plugin for docs
@@ -75,9 +72,7 @@ dependencies {
7572
testCompile('org.spockframework:spock-core:1.2-groovy-2.5') {
7673
exclude module: 'groovy-all'
7774
}
78-
testCompile ('org.springframework.boot:spring-boot-starter-test:2.1.3.RELEASE') {
79-
exclude module: "logback-classic"
80-
}
75+
testCompile 'org.springframework:spring-test:5.2.9.RELEASE'
8176
}
8277

8378
test {
@@ -107,10 +102,6 @@ task sourcesJar(type: Jar, dependsOn: classes) {
107102
from sourceSets.main.allGroovy
108103
}
109104

110-
bootRun {
111-
enabled = false
112-
}
113-
114105
publishing {
115106
publications {
116107
main(MavenPublication) {

ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/DataHubPlugin.groovy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,8 @@ import org.gradle.api.Plugin
5151
import org.gradle.api.Project
5252
import org.slf4j.Logger
5353
import org.slf4j.LoggerFactory
54-
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
5554
import org.springframework.context.annotation.AnnotationConfigApplicationContext
5655

57-
@EnableAutoConfiguration
5856
class DataHubPlugin implements Plugin<Project> {
5957

6058
private DataHubImpl dataHub

ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/BaseTest.groovy

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,18 @@ import org.custommonkey.xmlunit.XMLUnit
4242
import org.gradle.testkit.runner.BuildResult
4343
import org.gradle.testkit.runner.GradleRunner
4444
import org.junit.rules.TemporaryFolder
45-
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
4645
import org.springframework.context.annotation.AnnotationConfigApplicationContext
47-
import org.springframework.util.ReflectionUtils
4846
import org.w3c.dom.Document
4947
import org.xml.sax.SAXException
5048
import spock.lang.Specification
5149

5250
import javax.xml.parsers.DocumentBuilder
5351
import javax.xml.parsers.DocumentBuilderFactory
5452
import javax.xml.parsers.ParserConfigurationException
55-
import java.lang.reflect.Field
5653
import java.nio.file.Files
5754
import java.nio.file.Paths
5855
import java.nio.file.StandardCopyOption
59-
import java.util.stream.Collectors
60-
import java.util.stream.Stream
6156

62-
@EnableAutoConfiguration
6357
class BaseTest extends Specification {
6458

6559
// this value is for legacy purposes. on dev should always be 5

0 commit comments

Comments
 (0)