Skip to content

Commit

Permalink
Merge pull request #909 from PatrickWalter214/add-spring-boot-plugins…
Browse files Browse the repository at this point in the history
…-dsl-support

Add support for Spring Boot Gradle plugin using plugins DSL
  • Loading branch information
cherylking authored Sep 24, 2024
2 parents 32bda99 + a1ab576 commit cc74566
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ abstract class AbstractLibertyTask extends DefaultTask {
if (project.plugins.hasPlugin("org.springframework.boot")) {
try {
for (Dependency dep : project.buildscript.configurations.classpath.getAllDependencies().toArray()) {
if ("org.springframework.boot".equals(dep.getGroup()) && "spring-boot-gradle-plugin".equals(dep.getName())) {
if ("org.springframework.boot".equals(dep.getGroup()) &&
("spring-boot-gradle-plugin".equals(dep.getName()) ||
"org.springframework.boot.gradle.plugin".equals(dep.getName()))) {
version = dep.getVersion()
break
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,20 @@ public class TestSpringBootApplication30 extends AbstractIntegrationTest{
throw new AssertionError ("Fail on task deploy.", e)
}
}

@Test
public void test_spring_boot_plugins_dsl_apps_30() {
try {
runTasks(buildDir, 'deploy', 'libertyStart')

String webPage = new URL("http://localhost:9080").getText()
Assert.assertEquals("Did not get expected http response.","Hello!", webPage)
Assert.assertTrue('defaultServer/dropins has app deployed',
new File(buildDir, 'build/wlp/usr/servers/defaultServer/dropins').list().size() == 0)
Assert.assertTrue('no app in apps folder',
new File(buildDir, "build/wlp/usr/servers/defaultServer/apps/thin-${testName.getMethodName()}-1.0-SNAPSHOT.jar").exists() )
} catch (Exception e) {
throw new AssertionError ("Fail on task deploy.", e)
}
}
}
10 changes: 9 additions & 1 deletion src/test/resources/sample.springboot3/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
//Empty
pluginManagement {
repositories {
mavenCentral()
mavenLocal()
maven {
url = uri(file("$rootDir/../../plugin-test-repository/"))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.1.3'
id 'io.spring.dependency-management' version '1.1.6'
id 'io.openliberty.tools.gradle.Liberty' version "$lgpVersion"
}

group = 'liberty.gradle'
version = '1.0-SNAPSHOT'
sourceCompatibility = 17

repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
testImplementation('org.springframework.boot:spring-boot-starter-test')
libertyRuntime group: 'io.openliberty', name: 'openliberty-runtime', version: '23.0.0.10'
}

liberty {
server {
serverXmlFile = file("src/main/liberty/config/server30.xml")
}
}

0 comments on commit cc74566

Please sign in to comment.