diff --git a/docs/libertyDev.md b/docs/libertyDev.md index b8988653a..b6756c0c6 100644 --- a/docs/libertyDev.md +++ b/docs/libertyDev.md @@ -70,6 +70,7 @@ The following are optional command line parameters supported by this task. | serverStartTimeout | Maximum time to wait (in seconds) to verify that the server has started. The value must be an integer greater than or equal to 0. The default value is `90` seconds. | No | | verifyAppStartTimeout | Maximum time to wait (in seconds) to verify that the application has started or updated before running tests. The value must be an integer greater than or equal to 0. The default value is `30` seconds. | No | | generateFeatures | If set to `true`, when a Java file, server configuration file, or build file is changed, generate features required by the application in the source configuration directory. The default value is `false`. | No | +| skipInstallFeature | If set to `true`, the `installFeature` task will be skipped when `dev` mode is started on an already existing Liberty runtime installation. It will also be skipped when `dev` mode is running and a restart of the server is triggered either directly by the user or by application changes. The `installFeature` task will be invoked though when `dev` mode is running and a change to the configured features is detected. The default value is `false`. | No | ### Properties diff --git a/src/main/groovy/io/openliberty/tools/gradle/tasks/DevTask.groovy b/src/main/groovy/io/openliberty/tools/gradle/tasks/DevTask.groovy index 0f97b500f..37b22cc67 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/tasks/DevTask.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/tasks/DevTask.groovy @@ -87,6 +87,7 @@ class DevTask extends AbstractFeatureTask { private static final boolean DEFAULT_SKIP_DEFAULT_PORTS = false; private static final boolean DEFAULT_KEEP_TEMP_DOCKERFILE = false; private static final boolean DEFAULT_GENERATE_FEATURES = false; + private static final boolean DEFAULT_SKIP_INSTALL_FEATURE = false; // Debug port for BuildLauncher tasks launched from DevTask as parent JVM // (parent defaults to '5005') @@ -267,11 +268,21 @@ class DevTask extends AbstractFeatureTask { @Input Boolean generateFeatures; - // Need to use a string value to allow someone to specify --generateFeatures=false, if not explicitly set defaults to true - @Option(option = 'generateFeatures', description = 'If true, scan the application binary files to determine which Liberty features should be used. The default value is false.') - void setGenerateFeatures(String generateFeatures) { - this.generateFeatures = Boolean.parseBoolean(generateFeatures); - } + // Need to use a string value to allow someone to specify --generateFeatures=false, if not explicitly set defaults to true + @Option(option = 'generateFeatures', description = 'If true, scan the application binary files to determine which Liberty features should be used. The default value is false.') + void setGenerateFeatures(String generateFeatures) { + this.generateFeatures = Boolean.parseBoolean(generateFeatures); + } + + @Optional + @Input + Boolean skipInstallFeature; + + // Need to use a string value to allow someone to specify --skipInstallFeature=true, if not explicitly set defaults to false + @Option(option = 'skipInstallFeature', description = 'If set to true, the installFeature task will be skipped when dev mode is started on an already existing Liberty runtime installation. It will also be skipped when dev mode is running and a restart of the server is triggered either directly by the user or by application changes. The installFeature task will be invoked though when dev mode is running and a change to the configured features is detected. The default value is false.') + void setSkipInstallFeature(String skipInstallFeature) { + this.skipInstallFeature = Boolean.parseBoolean(skipInstallFeature); + } @Optional @Input @@ -302,14 +313,14 @@ class DevTask extends AbstractFeatureTask { DevTaskUtil(File buildDir, File installDirectory, File userDirectory, File serverDirectory, File sourceDirectory, File testSourceDirectory, File configDirectory, File projectDirectory, List resourceDirs, - boolean hotTests, boolean skipTests, String artifactId, int serverStartTimeout, + boolean hotTests, boolean skipTests, boolean skipInstallFeature, String artifactId, int serverStartTimeout, int verifyAppStartTimeout, int appUpdateTimeout, double compileWait, boolean libertyDebug, boolean pollingTest, boolean container, File dockerfile, File dockerBuildContext, String dockerRunOpts, int dockerBuildTimeout, boolean skipDefaultPorts, boolean keepTempDockerfile, String mavenCacheLocation, String packagingType, File buildFile, boolean generateFeatures ) throws IOException { super(buildDir, serverDirectory, sourceDirectory, testSourceDirectory, configDirectory, projectDirectory, /* multi module project directory */ projectDirectory, - resourceDirs, hotTests, skipTests, false /* skipUTs */, false /* skipITs */, artifactId, serverStartTimeout, + resourceDirs, hotTests, skipTests, false /* skipUTs */, false /* skipITs */, skipInstallFeature, artifactId, serverStartTimeout, verifyAppStartTimeout, appUpdateTimeout, ((long) (compileWait * 1000L)), libertyDebug, true /* useBuildRecompile */, true /* gradle */, pollingTest, container, dockerfile, dockerBuildContext, dockerRunOpts, dockerBuildTimeout, skipDefaultPorts, null /* compileOptions not needed since useBuildRecompile is true */, keepTempDockerfile, mavenCacheLocation, null /* multi module upstream projects */, @@ -842,6 +853,10 @@ class DevTask extends AbstractFeatureTask { if (container) { gradleBuildLauncher.addArguments(CONTAINER_PROPERTY_ARG); } + if (skipInstallFeature) { + gradleBuildLauncher.addArguments("--exclude-task", "libertyCreate"); // deploy dependsOn libertyCreate which is finalizedBy installFeature + gradleBuildLauncher.addArguments("--exclude-task", "installFeature"); + } runGradleTask(gradleBuildLauncher, 'deploy'); } catch (BuildException e) { throw new PluginExecutionException(e); @@ -897,6 +912,10 @@ class DevTask extends AbstractFeatureTask { } } + /** + * This method is only called from DevUtil.restartServer() which explicitly calls libertyCreate() before calling this method. We need to explicitly + * exclude the libertyCreate task. + **/ @Override public void libertyDeploy() { ProjectConnection gradleConnection = initGradleProjectConnection(); @@ -907,6 +926,9 @@ class DevTask extends AbstractFeatureTask { // Skip installFeature since it is not needed here in container mode. // Container mode should call installFeature separately with the containerName parameter where needed. gradleBuildLauncher.addArguments("--exclude-task", "installFeature"); + } else if (skipInstallFeature) { + gradleBuildLauncher.addArguments("--exclude-task", "libertyCreate"); // deploy dependsOn libertyCreate which is finalizedBy installFeature + gradleBuildLauncher.addArguments("--exclude-task", "installFeature"); } runGradleTask(gradleBuildLauncher, 'deploy'); } catch (BuildException e) { @@ -916,6 +938,10 @@ class DevTask extends AbstractFeatureTask { } } + /* + * This method is only called from common DevUtil.restartServer() method. The installLiberty task should not need to be called, and must be + * explicitly excluded since libertyCreate dependsOn installLiberty. + */ @Override public void libertyCreate() { if (container) { @@ -928,6 +954,10 @@ class DevTask extends AbstractFeatureTask { gradleBuildLauncher.addArguments('--rerun-tasks'); addLibertyRuntimeProperties(gradleBuildLauncher); + gradleBuildLauncher.addArguments("--exclude-task", "installLiberty"); + if (skipInstallFeature) { + gradleBuildLauncher.addArguments("--exclude-task", "installFeature"); + } try { runGradleTask(gradleBuildLauncher, 'libertyCreate'); } catch (BuildException e) { @@ -1042,6 +1072,10 @@ class DevTask extends AbstractFeatureTask { generateFeatures = DEFAULT_GENERATE_FEATURES; } + if (skipInstallFeature == null) { + skipInstallFeature = DEFAULT_SKIP_INSTALL_FEATURE; + } + processContainerParams(); } @@ -1097,7 +1131,7 @@ class DevTask extends AbstractFeatureTask { // Instantiate util before any child gradle tasks launched so it can help find available port if needed this.util = new DevTaskUtil(project.buildDir, serverInstallDir, getUserDir(project, serverInstallDir), serverDirectory, sourceDirectory, testSourceDirectory, configDirectory, project.getRootDir(), - resourceDirs, hotTests.booleanValue(), skipTests.booleanValue(), artifactId, serverStartTimeout.intValue(), + resourceDirs, hotTests.booleanValue(), skipTests.booleanValue(), skipInstallFeature.booleanValue(), artifactId, serverStartTimeout.intValue(), verifyAppStartTimeout.intValue(), verifyAppStartTimeout.intValue(), compileWait.doubleValue(), libertyDebug.booleanValue(), pollingTest.booleanValue(), container.booleanValue(), dockerfile, dockerBuildContext, dockerRunOpts, dockerBuildTimeout, skipDefaultPorts.booleanValue(), keepTempDockerfile.booleanValue(), localMavenRepoForFeatureUtility, @@ -1150,11 +1184,43 @@ class DevTask extends AbstractFeatureTask { } } if (!container) { + boolean isNewInstallation = true; + // Check to see if Liberty was already installed and set flag accordingly. + if (serverInstallDir != null) { + try { + File installDirectoryCanonicalFile = serverInstallDir.getCanonicalFile(); + // Quick check to see if a Liberty installation exists at the installDirectory + File file = new File(installDirectoryCanonicalFile, "lib/ws-launch.jar"); + if (file.exists()) { + isNewInstallation = false; + logger.info("Dev mode is using an existing installation."); + } + } catch (IOException e) { + } + } + + // if skipInstallFeature is set to true, skip installFeature task unless it is a new installation + if (skipInstallFeature) { + logger.debug("skipInstallFeature flag is set to true"); + } + + if (!isNewInstallation) { + logger.info("Skipping installLiberty task for existing installation.") + // will this cause an issue when changing the runtime? Customer would be forced to cleanup first? + gradleBuildLauncher.addArguments("--exclude-task", "installLiberty"); // skip installing Liberty at startup since it was already installed + if (skipInstallFeature) { + logger.info("Skipping installFeature task due to skipInstallFeature configuration.") + gradleBuildLauncher.addArguments("--exclude-task", "installFeature"); // skip installing features at startup since flag was set + } + } addLibertyRuntimeProperties(gradleBuildLauncher); runGradleTask(gradleBuildLauncher, 'libertyCreate'); - // suppress extra install feature warnings (one would have shown up already from the libertyCreate task on the line above) - gradleBuildLauncher.addArguments("-D" + DevUtil.SKIP_BETA_INSTALL_WARNING + "=" + Boolean.TRUE.toString()); - runInstallFeatureTask(gradleBuildLauncher, null); + + if (!skipInstallFeature || isNewInstallation) { + // suppress extra install feature warnings (one would have shown up already from the libertyCreate task on the line above) + gradleBuildLauncher.addArguments("-D" + DevUtil.SKIP_BETA_INSTALL_WARNING + "=" + Boolean.TRUE.toString()); + runInstallFeatureTask(gradleBuildLauncher, null); + } } else { // skip creating the server and installing features and just propagate the option to 'deploy' createServerDirectories(); diff --git a/src/main/groovy/io/openliberty/tools/gradle/tasks/InstallLibertyTask.groovy b/src/main/groovy/io/openliberty/tools/gradle/tasks/InstallLibertyTask.groovy index db2be553d..4b98602dc 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/tasks/InstallLibertyTask.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/tasks/InstallLibertyTask.groovy @@ -42,7 +42,7 @@ class InstallLibertyTask extends AbstractLibertyTask { protected String detachedCoords protected String detachedConfigFilePath // default to install the latest Open Liberty kernel from Maven Central repository - protected String defaultRuntime = "io.openliberty:openliberty-kernel:[19.0.0.9,)" + protected String defaultRuntime = "io.openliberty:openliberty-kernel:[23.0.0.3,)" InstallLibertyTask() { configure({ diff --git a/src/test/groovy/io/openliberty/tools/gradle/BaseDevTest.groovy b/src/test/groovy/io/openliberty/tools/gradle/BaseDevTest.groovy index 5bed7228f..e48a4ab39 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/BaseDevTest.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/BaseDevTest.groovy @@ -26,11 +26,9 @@ import java.nio.file.Files; import java.nio.file.Path; class BaseDevTest extends AbstractIntegrationTest { - static final String projectName = "basic-dev-project"; - - static File resourceDir = new File("build/resources/test/dev-test/" + projectName); - static File buildDir = new File(integTestDir, "dev-test/" + projectName + System.currentTimeMillis()); // append timestamp in case previous build was not deleted + static File buildDir; static String buildFilename = "build.gradle"; + final String RUNNING_INSTALL_FEATURE = "Task :installFeature"; final String RUNNING_GENERATE_FEATURES = "Task :generateFeatures"; final String REGENERATE_FEATURES = "Regenerated the following features:"; final String GENERATE_FEATURES = "Generated the following features:"; @@ -56,13 +54,22 @@ class BaseDevTest extends AbstractIntegrationTest { // the correct file. Use logFile for "compilation was successful" // and errFile for "compilation had errors" or Liberty messages like // "CWWKF0011I" or "The server installed the following features". - static File logFile = new File(buildDir, "output.log"); - static File errFile = new File(buildDir, "stderr.log"); + static File logFile; + static File errFile; + static Process process; - protected static void runDevMode() throws IOException, InterruptedException, FileNotFoundException { - System.out.println("Starting dev mode..."); - startProcess("--generateFeatures=true", true); + protected static void runDevMode(File buildDirectory) throws IOException, InterruptedException, FileNotFoundException { + runDevMode("--generateFeatures=true", buildDirectory) + } + + protected static void runDevMode(String params, File buildDirectory) throws IOException, InterruptedException, FileNotFoundException { + buildDir = buildDirectory; + logFile = new File(buildDir, "output.log"); + errFile = new File(buildDir, "stderr.log"); + + System.out.println("Starting dev mode with params..."+params); + startProcess(params, true); System.out.println("Started dev mode"); } @@ -145,13 +152,18 @@ class BaseDevTest extends AbstractIntegrationTest { throws InterruptedException, FileNotFoundException { int waited = 0; int sleep = 10; + int foundOccurrences = 0; while (waited <= timeout) { Thread.sleep(sleep); waited += sleep; - if (countOccurrences(message, file) == occurrences) { + foundOccurrences = countOccurrences(message, file) + if (foundOccurrences == occurrences) { return true; } } + + System.out.println("Log message found "+foundOccurrences+" times, expected to find it "+occurrences+" times."); + return false; } @@ -200,7 +212,7 @@ class BaseDevTest extends AbstractIntegrationTest { // a file has been changed between two instants of time. The problem is that the // method has a resolution of just 2000ms on Windows FAT and 1000ms on MacOS HFS+. protected static void waitLongEnough() throws InterruptedException { - Thread.sleep(2001); + Thread.sleep(3001); // make sure we wait long enough } private static boolean readFile(String str, File file) throws FileNotFoundException { @@ -269,15 +281,8 @@ class BaseDevTest extends AbstractIntegrationTest { protected static void cleanUpAfterClass(boolean isDevMode) throws Exception { stopProcess(isDevMode); if (buildDir != null && buildDir.exists()) { - // FileUtils.deleteDirectory(buildDir); FileUtils.deleteQuietly(buildDir); // try this method that does not throw an exception } - if (logFile != null && logFile.exists()) { - assertTrue(logFile.delete()); - } - if (errFile != null && errFile.exists()) { - assertTrue(errFile.delete()); - } } private static void stopProcess(boolean isDevMode) throws IOException, InterruptedException, FileNotFoundException { @@ -289,8 +294,11 @@ class BaseDevTest extends AbstractIntegrationTest { } else { process.destroy(); // stop run } - writer.flush(); - writer.close(); + try { + writer.close(); // close automatically does a flush + } catch (IOException e) { + System.out.println("Received IOException on writer.close()" + e.getMessage()); + } // test that dev mode has stopped running assertTrue(verifyLogMessage(100000, "CWWKE0036I", errFile, ++serverStoppedOccurrences)); diff --git a/src/test/groovy/io/openliberty/tools/gradle/DevRecompileTest.groovy b/src/test/groovy/io/openliberty/tools/gradle/DevRecompileTest.groovy index 760965948..f2e798ce2 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/DevRecompileTest.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/DevRecompileTest.groovy @@ -30,12 +30,16 @@ import java.nio.file.Files; import java.nio.file.Path; class DevRecompileTest extends BaseDevTest { + static final String projectName = "basic-dev-project"; + + static File resourceDir = new File("build/resources/test/dev-test/" + projectName); + static File buildDir = new File(integTestDir, "dev-test/" + projectName + System.currentTimeMillis()); // append timestamp in case previous build was not deleted @BeforeClass public static void setup() throws IOException, InterruptedException, FileNotFoundException { createDir(buildDir); createTestProject(buildDir, resourceDir, buildFilename); - runDevMode(); + runDevMode(buildDir); } @Test diff --git a/src/test/groovy/io/openliberty/tools/gradle/DevSkipInstallFeatureTest.groovy b/src/test/groovy/io/openliberty/tools/gradle/DevSkipInstallFeatureTest.groovy new file mode 100644 index 000000000..daf2e4152 --- /dev/null +++ b/src/test/groovy/io/openliberty/tools/gradle/DevSkipInstallFeatureTest.groovy @@ -0,0 +1,82 @@ +/* + * (C) Copyright IBM Corporation 2023. + * + * 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 + * + * 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. + */ +package io.openliberty.tools.gradle; + +import static org.junit.Assert.*; + +import java.io.BufferedWriter; +import org.apache.commons.io.FileUtils; +import java.io.File; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.AfterClass; +import org.junit.Test; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; + +class DevSkipInstallFeatureTest extends BaseDevTest { + + static final String projectName = "dev-skip-feature-install"; + static File resourceDir = new File("build/resources/test/dev-test/" + projectName); + static File testBuildDir = new File(integTestDir, "/test-dev-skip-install-feature") + final String RUNNING_INSTALL_LIBERTY = "Task :installLiberty"; + + @BeforeClass + public static void setup() throws IOException, InterruptedException, FileNotFoundException { + createDir(testBuildDir) + createTestProject(testBuildDir, resourceDir, "buildInstallLiberty.gradle", true) + + runTasks(testBuildDir, 'libertyCreate') + + // now copy the build.gradle for dev mode invocation + File buildFile = new File(resourceDir, buildFilename) + copyBuildFiles(buildFile, testBuildDir, false) + + runDevMode("--skipInstallFeature=true", testBuildDir) + } + + @Test + public void restartServerTest() throws Exception { + tagLog("##restartServerTest start"); + int runningInstallLibertyCount = countOccurrences(RUNNING_INSTALL_LIBERTY, logFile); + int runningInstallFeatureCount = countOccurrences(RUNNING_INSTALL_FEATURE, logFile); + + String RESTARTED = "The server has been restarted."; + int restartedCount = countOccurrences(RESTARTED, logFile); + writer.write("r\n"); // command to restart liberty + writer.flush(); + + // TODO reduce wait time once https://github.com/OpenLiberty/ci.gradle/issues/751 is resolved + // depending on the order the tests run in, tests may be triggered before this test resulting in a 30s timeout (bug above) + assertTrue(verifyLogMessage(123000, RESTARTED, ++restartedCount)); + + // not supposed to rerun installFeature or installLiberty task just because of a server restart + assertTrue("Did not find expected log messages for running installLiberty task: "+runningInstallLibertyCount, verifyLogMessage(2000, RUNNING_INSTALL_LIBERTY, logFile, runningInstallLibertyCount)); + assertTrue("Did not find expected log messages for running installFeature task: "+runningInstallFeatureCount, verifyLogMessage(2000, RUNNING_INSTALL_FEATURE, logFile, runningInstallFeatureCount)); + tagLog("##restartServerTest end"); + } + + @AfterClass + public static void cleanUpAfterClass() throws Exception { + String stdout = getContents(logFile, "Dev mode std output"); + System.out.println(stdout); + String stderr = getContents(errFile, "Dev mode std error"); + System.out.println(stderr); + cleanUpAfterClass(true); + } +} diff --git a/src/test/groovy/io/openliberty/tools/gradle/DevTest.groovy b/src/test/groovy/io/openliberty/tools/gradle/DevTest.groovy index 50bd9070a..065da1e44 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/DevTest.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/DevTest.groovy @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corporation 2020, 2022. + * (C) Copyright IBM Corporation 2020, 2023. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,12 +30,16 @@ import java.nio.file.Files; import java.nio.file.Path; class DevTest extends BaseDevTest { + static final String projectName = "basic-dev-project"; + + static File resourceDir = new File("build/resources/test/dev-test/" + projectName); + static File buildDir = new File(integTestDir, "dev-test/" + projectName + System.currentTimeMillis()); // append timestamp in case previous build was not deleted @BeforeClass public static void setup() throws IOException, InterruptedException, FileNotFoundException { createDir(buildDir); createTestProject(buildDir, resourceDir, buildFilename); - runDevMode(); + runDevMode(buildDir); } @Test @@ -121,10 +125,15 @@ class DevTest extends BaseDevTest { tagLog("##testDirectoryTest start"); // create the test directory File testDir = new File(buildDir, "src/test/java"); - assertTrue(testDir.mkdirs()); + File unitTestSrcFile = new File(testDir, "UnitTest.java"); + + if (!testDir.exists()) { + assertTrue("Failed creating directory: "+testDir.getCanonicalPath(), testDir.mkdirs()); + } else if (unitTestSrcFile.exists()) { + assertTrue("Failed deleting file: "+unitTestSrcFile.getCanonicalPath(), unitTestSrcFile.delete()); + } // creates a java test file - File unitTestSrcFile = new File(testDir, "UnitTest.java"); String unitTest = """import org.junit.Test;\n import static org.junit.Assert.*;\n \n @@ -152,7 +161,9 @@ class DevTest extends BaseDevTest { javaWriter.append(' '); javaWriter.append(str); javaWriter.close(); - assertTrue(waitForCompilation(unitTestTargetFile, lastModified, 10000)); + if (!waitForCompilation(unitTestTargetFile, lastModified, 10000)) { // just try again - failing here often + assertTrue(waitForCompilation(unitTestTargetFile, lastModified, 10000)); + } // delete the test file // "The java class .../build/classes/java/test/UnitTest.class was deleted." diff --git a/src/test/groovy/io/openliberty/tools/gradle/PollingDevTest.groovy b/src/test/groovy/io/openliberty/tools/gradle/PollingDevTest.groovy index 5e6bd5b6a..25ad38492 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/PollingDevTest.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/PollingDevTest.groovy @@ -35,13 +35,7 @@ class PollingDevTest extends DevTest { public static void setup() throws IOException, InterruptedException, FileNotFoundException { createDir(buildDir); createTestProject(buildDir, resourceDir, buildFilename); - runDevModePolling(); + runDevMode("--pollingTest --generateFeatures=true", buildDir) } - - private static void runDevModePolling() throws IOException, InterruptedException, FileNotFoundException { - System.out.println("Starting dev mode with polling..."); - startProcess("--pollingTest --generateFeatures=true", true); - System.out.println("Started dev mode with polling"); - } - + } diff --git a/src/test/resources/dev-test/dev-skip-feature-install/build.gradle b/src/test/resources/dev-test/dev-skip-feature-install/build.gradle new file mode 100644 index 000000000..d27e1a022 --- /dev/null +++ b/src/test/resources/dev-test/dev-skip-feature-install/build.gradle @@ -0,0 +1,46 @@ +apply plugin: "liberty" +apply plugin: "war" + +sourceCompatibility = 1.8 +targetCompatibility = 1.8 +tasks.withType(JavaCompile) { + options.encoding = "UTF-8" +} + +// configure liberty-gradle-plugin +buildscript { + repositories { + mavenLocal() + mavenCentral() + // Sonatype repo for getting the latest binary scanner jar snapshot + maven { + url 'https://oss.sonatype.org/content/repositories/snapshots/' + } + } + dependencies { + classpath "io.openliberty.tools:liberty-gradle-plugin:$lgpVersion" + } +} + +repositories { + mavenCentral() +} + +dependencies { + // provided dependencies + providedCompile "jakarta.platform:jakarta.jakartaee-api:8.0.0" + providedCompile "org.eclipse.microprofile:microprofile:3.2" + + // test dependencies + testImplementation "junit:junit:4.13.1" + testImplementation "org.apache.cxf:cxf-rt-rs-client:3.2.6" + testImplementation "org.apache.cxf:cxf-rt-rs-extension-providers:3.2.6" + testImplementation "org.glassfish:javax.json:1.0.4" + testImplementation "javax.xml.bind:jaxb-api:2.3.1" +} + +liberty { + installDir = file("${project.buildDir}/wlp") +} + +clean.dependsOn "libertyStop" \ No newline at end of file diff --git a/src/test/resources/dev-test/dev-skip-feature-install/buildInstallLiberty.gradle b/src/test/resources/dev-test/dev-skip-feature-install/buildInstallLiberty.gradle new file mode 100644 index 000000000..e7d02b432 --- /dev/null +++ b/src/test/resources/dev-test/dev-skip-feature-install/buildInstallLiberty.gradle @@ -0,0 +1,43 @@ +apply plugin: "liberty" +apply plugin: "war" + +sourceCompatibility = 1.8 +targetCompatibility = 1.8 +tasks.withType(JavaCompile) { + options.encoding = "UTF-8" +} + +// configure liberty-gradle-plugin +buildscript { + repositories { + mavenLocal() + mavenCentral() + // Sonatype repo for getting the latest binary scanner jar snapshot + maven { + url 'https://oss.sonatype.org/content/repositories/snapshots/' + } + } + dependencies { + classpath "io.openliberty.tools:liberty-gradle-plugin:$lgpVersion" + } +} + +repositories { + mavenCentral() +} + +dependencies { + // provided dependencies + providedCompile "jakarta.platform:jakarta.jakartaee-api:8.0.0" + providedCompile "org.eclipse.microprofile:microprofile:3.2" + + libertyRuntime "$runtimeGroup:$runtimeArtifactId:$runtimeVersion" + + // test dependencies + testImplementation "junit:junit:4.13.1" + testImplementation "org.apache.cxf:cxf-rt-rs-client:3.2.6" + testImplementation "org.apache.cxf:cxf-rt-rs-extension-providers:3.2.6" + testImplementation "org.glassfish:javax.json:1.0.4" + testImplementation "javax.xml.bind:jaxb-api:2.3.1" +} + diff --git a/src/test/resources/dev-test/dev-skip-feature-install/settings.gradle b/src/test/resources/dev-test/dev-skip-feature-install/settings.gradle new file mode 100644 index 000000000..c2d3edc19 --- /dev/null +++ b/src/test/resources/dev-test/dev-skip-feature-install/settings.gradle @@ -0,0 +1 @@ +//Empty \ No newline at end of file diff --git a/src/test/resources/dev-test/dev-skip-feature-install/src/main/java/com/demo/HelloServlet.java b/src/test/resources/dev-test/dev-skip-feature-install/src/main/java/com/demo/HelloServlet.java new file mode 100644 index 000000000..059233a63 --- /dev/null +++ b/src/test/resources/dev-test/dev-skip-feature-install/src/main/java/com/demo/HelloServlet.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * (c) Copyright IBM Corporation 2020. + * + * 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 + * + * 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. + *******************************************************************************/ +package com.demo; + +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(urlPatterns="/servlet") +public class HelloServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.getWriter().append("hello world"); + } +} \ No newline at end of file diff --git a/src/test/resources/dev-test/dev-skip-feature-install/src/main/java/com/demo/HelloWorld.java b/src/test/resources/dev-test/dev-skip-feature-install/src/main/java/com/demo/HelloWorld.java new file mode 100755 index 000000000..9992f109e --- /dev/null +++ b/src/test/resources/dev-test/dev-skip-feature-install/src/main/java/com/demo/HelloWorld.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * (c) Copyright IBM Corporation 2020. + * + * 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 + * + * 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. + *******************************************************************************/ +package com.demo; + +public class HelloWorld { + + public String helloWorld() { + return "helloWorld"; + } +} diff --git a/src/test/resources/dev-test/dev-skip-feature-install/src/main/liberty/config/bootstrap.properties b/src/test/resources/dev-test/dev-skip-feature-install/src/main/liberty/config/bootstrap.properties new file mode 100644 index 000000000..fa873e6ae --- /dev/null +++ b/src/test/resources/dev-test/dev-skip-feature-install/src/main/liberty/config/bootstrap.properties @@ -0,0 +1,3 @@ +default.http.port = 9080 +default.https.port = 9443 +com.ibm.ws.logging.message.format=json \ No newline at end of file diff --git a/src/test/resources/dev-test/dev-skip-feature-install/src/main/liberty/config/server.xml b/src/test/resources/dev-test/dev-skip-feature-install/src/main/liberty/config/server.xml new file mode 100755 index 000000000..c6319c63b --- /dev/null +++ b/src/test/resources/dev-test/dev-skip-feature-install/src/main/liberty/config/server.xml @@ -0,0 +1,10 @@ + + + + jaxrs-2.1 + + + + + diff --git a/src/test/resources/dev-test/dev-skip-feature-install/src/main/resources/placeHolder.txt b/src/test/resources/dev-test/dev-skip-feature-install/src/main/resources/placeHolder.txt new file mode 100644 index 000000000..e69de29bb