parent
02ad4ce2c6
commit
58a69bb7e2
|
@ -36,7 +36,6 @@ dependencies {
|
|||
implementation localGroovy()
|
||||
|
||||
implementation 'com.github.ben-manes:gradle-versions-plugin:0.25.0'
|
||||
implementation 'gradle.plugin.org.gretty:gretty:3.0.1'
|
||||
implementation 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.21.1'
|
||||
implementation 'io.spring.gradle:dependency-management-plugin:1.0.9.RELEASE'
|
||||
implementation 'io.spring.gradle:docbook-reference-plugin:0.3.1'
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package io.spring.gradle.convention;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.plugins.PluginManager;
|
||||
import org.gradle.api.plugins.WarPlugin
|
||||
import org.gradle.api.plugins.JavaPlugin;
|
||||
import org.gradle.api.tasks.testing.Test
|
||||
|
||||
/**
|
||||
* @author Rob Winch
|
||||
*/
|
||||
public class SpringSampleBootPlugin extends SpringSamplePlugin {
|
||||
|
||||
@Override
|
||||
public void additionalPlugins(Project project) {
|
||||
super.additionalPlugins(project);
|
||||
|
||||
PluginManager pluginManager = project.getPluginManager();
|
||||
|
||||
pluginManager.apply("org.springframework.boot");
|
||||
|
||||
project.repositories {
|
||||
maven { url 'https://repo.spring.io/snapshot' }
|
||||
maven { url 'https://repo.spring.io/milestone' }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package io.spring.gradle.convention;
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.sonarqube.gradle.SonarQubePlugin;
|
||||
|
||||
/**
|
||||
* @author Rob Winch
|
||||
*/
|
||||
public class SpringSamplePlugin extends AbstractSpringJavaPlugin {
|
||||
|
||||
@Override
|
||||
public void additionalPlugins(Project project) {
|
||||
project.plugins.withType(SonarQubePlugin) {
|
||||
project.sonarqube.skipProject = true
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package io.spring.gradle.convention
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.plugins.PluginManager
|
||||
import org.gradle.api.tasks.testing.Test
|
||||
|
||||
/**
|
||||
* @author Rob Winch
|
||||
*/
|
||||
public class SpringSampleWarPlugin extends SpringSamplePlugin {
|
||||
|
||||
@Override
|
||||
public void additionalPlugins(Project project) {
|
||||
super.additionalPlugins(project);
|
||||
|
||||
PluginManager pluginManager = project.getPluginManager();
|
||||
|
||||
pluginManager.apply("war");
|
||||
pluginManager.apply("org.gretty");
|
||||
|
||||
project.gretty {
|
||||
servletContainer = 'tomcat85'
|
||||
contextPath = '/'
|
||||
fileLogEnabled = false
|
||||
}
|
||||
|
||||
Task prepareAppServerForIntegrationTests = project.tasks.create('prepareAppServerForIntegrationTests') {
|
||||
group = 'Verification'
|
||||
description = 'Prepares the app server for integration tests'
|
||||
doFirst {
|
||||
project.gretty {
|
||||
httpPort = getRandomFreePort()
|
||||
httpsPort = getRandomPort()
|
||||
}
|
||||
}
|
||||
}
|
||||
project.tasks.withType(org.akhikhl.gretty.AppBeforeIntegrationTestTask).all { task ->
|
||||
task.dependsOn prepareAppServerForIntegrationTests
|
||||
}
|
||||
|
||||
project.tasks.withType(Test).all { task ->
|
||||
if("integrationTest".equals(task.name)) {
|
||||
applyForIntegrationTest(project, task)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def applyForIntegrationTest(Project project, Task integrationTest) {
|
||||
project.gretty.integrationTestTask = integrationTest.name
|
||||
|
||||
integrationTest.doFirst {
|
||||
def gretty = project.gretty
|
||||
String host = project.gretty.host ?: 'localhost'
|
||||
boolean isHttps = gretty.httpsEnabled
|
||||
Integer httpPort = integrationTest.systemProperties['gretty.httpPort']
|
||||
Integer httpsPort = integrationTest.systemProperties['gretty.httpsPort']
|
||||
int port = isHttps ? httpsPort : httpPort
|
||||
String contextPath = project.gretty.contextPath
|
||||
String httpBaseUrl = "http://${host}:${httpPort}${contextPath}"
|
||||
String httpsBaseUrl = "https://${host}:${httpsPort}${contextPath}"
|
||||
String baseUrl = isHttps ? httpsBaseUrl : httpBaseUrl
|
||||
integrationTest.systemProperty 'app.port', port
|
||||
integrationTest.systemProperty 'app.httpPort', httpPort
|
||||
integrationTest.systemProperty 'app.httpsPort', httpsPort
|
||||
integrationTest.systemProperty 'app.baseURI', baseUrl
|
||||
integrationTest.systemProperty 'app.httpBaseURI', httpBaseUrl
|
||||
integrationTest.systemProperty 'app.httpsBaseURI', httpsBaseUrl
|
||||
|
||||
integrationTest.systemProperty 'geb.build.baseUrl', baseUrl
|
||||
integrationTest.systemProperty 'geb.build.reportsDir', 'build/geb-reports'
|
||||
}
|
||||
}
|
||||
|
||||
def getRandomPort() {
|
||||
ServerSocket ss = new ServerSocket(0)
|
||||
int port = ss.localPort
|
||||
ss.close()
|
||||
return port
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
implementation-class=io.spring.gradle.convention.SpringSampleBootPlugin
|
|
@ -1 +0,0 @@
|
|||
implementation-class=io.spring.gradle.convention.SpringSampleWarPlugin
|
|
@ -1 +0,0 @@
|
|||
implementation-class=io.spring.gradle.convention.SpringSamplePlugin
|
|
@ -34,12 +34,6 @@ class ShowcaseITest extends Specification {
|
|||
.build();
|
||||
then: 'entire build passes'
|
||||
result.output.contains("BUILD SUCCESSFUL")
|
||||
|
||||
and: 'javadoc api works'
|
||||
|
||||
and: 'integration tests run'
|
||||
new File(testKit.getRootDir(), 'samples/sgbcs-sample-war/build/test-results/integrationTest/').exists()
|
||||
new File(testKit.getRootDir(), 'samples/sgbcs-sample-war/build/reports/tests/integrationTest/').exists()
|
||||
}
|
||||
|
||||
def "install"() {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
plugins {
|
||||
id 'io.spring.convention.javadoc-api'
|
||||
id 'io.spring.convention.spring-module' apply false
|
||||
id 'io.spring.convention.spring-sample' apply false
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
apply plugin: 'io.spring.convention.spring-sample'
|
||||
apply plugin: 'java'
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
apply plugin: 'io.spring.convention.spring-sample-war'
|
||||
|
||||
dependencies {
|
||||
provided 'javax.servlet:javax.servlet-api'
|
||||
testCompile 'commons-io:commons-io'
|
||||
testCompile 'junit:junit'
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
public class HelloServletTest {
|
||||
|
||||
@Test
|
||||
public void hello() throws Exception {
|
||||
String url = System.getProperty("app.baseURI");
|
||||
try(InputStream get = new URL(url).openConnection().getInputStream()) {
|
||||
String hello = IOUtils.toString(get, Charset.defaultCharset());
|
||||
assertEquals("Hello", hello);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package sample;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@WebServlet("/")
|
||||
public class HelloServlet extends HttpServlet {
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
resp.getWriter().write("Hello");
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -166535360229360350L;
|
||||
}
|
Loading…
Reference in New Issue