From 9ca77a23aabca2ecc4fa8335284e8c2be95d0303 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 15 Dec 2018 12:35:16 +1000 Subject: [PATCH] issue #3186 add it to override javax.annotation provided by maven core (#3194) Signed-off-by: olivier lamy --- Jenkinsfile | 20 ++-- .../javax-annotation-api/invoker.properties | 1 + .../src/it/javax-annotation-api/pom.xml | 103 ++++++++++++++++++ .../it/javax-annotation-api/postbuild.groovy | 21 ++++ .../src/main/java/test/App.java | 64 +++++++++++ .../src/main/resources/my.properties | 1 + 6 files changed, 199 insertions(+), 11 deletions(-) create mode 100644 jetty-maven-plugin/src/it/javax-annotation-api/invoker.properties create mode 100644 jetty-maven-plugin/src/it/javax-annotation-api/pom.xml create mode 100644 jetty-maven-plugin/src/it/javax-annotation-api/postbuild.groovy create mode 100644 jetty-maven-plugin/src/it/javax-annotation-api/src/main/java/test/App.java create mode 100644 jetty-maven-plugin/src/it/javax-annotation-api/src/main/resources/my.properties diff --git a/Jenkinsfile b/Jenkinsfile index dd0a07980b1..23bb2ab39de 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,7 +9,7 @@ pipeline { agent { node { label 'linux' } } options { timeout(time: 120, unit: 'MINUTES') } steps { - mavenBuild("jdk11", "-Pmongodb install") + mavenBuild("jdk11", "-Pmongodb install", "maven3") warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'Java']] // Collect up the jacoco execution results (only on main build) jacoco inclusionPattern: '**/org/eclipse/jetty/**/*.class', @@ -36,10 +36,7 @@ pipeline { sourcePattern: '**/src/main/java' warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'Java']] - script { - step([$class : 'MavenInvokerRecorder', reportsFilenamePattern: "**/target/invoker-reports/BUILD*.xml", - invokerBuildDir: "**/target/its"]) - } + maven_invoker reportsFilenamePattern: "**/target/invoker-reports/BUILD*.xml", invokerBuildDir: "**/target/its" } } @@ -47,7 +44,7 @@ pipeline { agent { node { label 'linux' } } options { timeout(time: 30, unit: 'MINUTES') } steps { - mavenBuild("jdk11", "install javadoc:javadoc -DskipTests") + mavenBuild("jdk11", "install javadoc:javadoc -DskipTests", "maven3") warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'JavaDoc'], [parserName: 'Java']] } } @@ -63,6 +60,7 @@ pipeline { } */ } + } } } @@ -74,13 +72,13 @@ pipeline { * * @param jdk the jdk tool name (in jenkins) to use for this build * @param cmdline the command line in " "`format. + * @paran mvnName maven installation to use * @return the Jenkinsfile step representing a maven build */ -def mavenBuild(jdk, cmdline) { - def mvnName = 'maven3.5' - def localRepo = "${env.JENKINS_HOME}/${env.EXECUTOR_NUMBER}" // ".repository" // - def settingsName = 'oss-settings.xml' - def mavenOpts = '-Xms1g -Xmx4g -Djava.awt.headless=true' +def mavenBuild(jdk, cmdline, mvnName) { + def localRepo = "${env.JENKINS_HOME}/${env.EXECUTOR_NUMBER}" // ".repository" // + def settingsName = 'oss-settings.xml' + def mavenOpts = '-Xms1g -Xmx4g -Djava.awt.headless=true' withMaven( maven: mvnName, diff --git a/jetty-maven-plugin/src/it/javax-annotation-api/invoker.properties b/jetty-maven-plugin/src/it/javax-annotation-api/invoker.properties new file mode 100644 index 00000000000..e0222d4d54e --- /dev/null +++ b/jetty-maven-plugin/src/it/javax-annotation-api/invoker.properties @@ -0,0 +1 @@ +invoker.goals = test \ No newline at end of file diff --git a/jetty-maven-plugin/src/it/javax-annotation-api/pom.xml b/jetty-maven-plugin/src/it/javax-annotation-api/pom.xml new file mode 100644 index 00000000000..4ef25cb17c3 --- /dev/null +++ b/jetty-maven-plugin/src/it/javax-annotation-api/pom.xml @@ -0,0 +1,103 @@ + + + + 4.0.0 + + + + + org.eclipse.jetty.its + it-parent-pom + 0.0.1-SNAPSHOT + + + javax-annotation-api-test + 1.0.0-SNAPSHOT + war + + + + UTF-8 + 8 + 8 + + ${project.build.directory}/jetty-run-mojo-annotation.txt + 1.3.2 + + + + + javax.servlet + javax.servlet-api + 4.0.1 + provided + + + javax.annotation + javax.annotation-api + ${annotation-api.version} + + + org.springframework.boot + spring-boot-autoconfigure + 2.1.1.RELEASE + + + org.springframework.boot + spring-boot-starter-web + 2.1.1.RELEASE + + + org.springframework.boot + spring-boot-starter-tomcat + + + + + + + + + + org.eclipse.jetty + jetty-maven-plugin + + + start-jetty + test-compile + + start + + + + + jetty.port.file + ${jetty.port.file} + + + true + + + + + + + + + javax.annotation + javax.annotation-api + ${annotation-api.version} + + + javax.annotation + jsr250-api + 1.0 + + + + diff --git a/jetty-maven-plugin/src/it/javax-annotation-api/postbuild.groovy b/jetty-maven-plugin/src/it/javax-annotation-api/postbuild.groovy new file mode 100644 index 00000000000..9533c9ecc2c --- /dev/null +++ b/jetty-maven-plugin/src/it/javax-annotation-api/postbuild.groovy @@ -0,0 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * http://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. + */ +File buildLog = new File( basedir, 'build.log' ) +assert buildLog.text.contains( 'Started Jetty Server' ) +assert buildLog.text.contains( 'all good guys get a good Beer') diff --git a/jetty-maven-plugin/src/it/javax-annotation-api/src/main/java/test/App.java b/jetty-maven-plugin/src/it/javax-annotation-api/src/main/java/test/App.java new file mode 100644 index 00000000000..d03ad70999b --- /dev/null +++ b/jetty-maven-plugin/src/it/javax-annotation-api/src/main/java/test/App.java @@ -0,0 +1,64 @@ +// +// ======================================================================== +// Copyright (c) 1995-2018 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package test; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.context.annotation.Bean; + +import javax.annotation.PostConstruct; +import javax.annotation.Resource; +import java.io.InputStream; +import java.util.Properties; + +/** + * Hello world! + * + */ +public class App extends SpringBootServletInitializer { + + private Logger logger = LoggerFactory.getLogger( getClass() ); + + @Resource(name="my.properties") + private Properties somePropertyFile; + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder builder ) { + return builder.sources( App.class ); + } + + @PostConstruct + public void done(){ + logger.info( "all good guys get a good {}", somePropertyFile.get( "drink" ) ); + + } + + @Bean(name = "my.properties") + public Properties getSomeProperties() throws Exception{ + Properties properties = new Properties( ); + try(InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream( "my.properties" )) + { + properties.load( inputStream ); + } + return properties; + } + +} diff --git a/jetty-maven-plugin/src/it/javax-annotation-api/src/main/resources/my.properties b/jetty-maven-plugin/src/it/javax-annotation-api/src/main/resources/my.properties new file mode 100644 index 00000000000..5c07b0ed01e --- /dev/null +++ b/jetty-maven-plugin/src/it/javax-annotation-api/src/main/resources/my.properties @@ -0,0 +1 @@ +drink=Beer