From 2ffc5d9b6caa11aa12bb63c3e1d1ea2b2effc94a Mon Sep 17 00:00:00 2001 From: Ondro Mihalyi Date: Tue, 29 Apr 2025 11:54:05 +0200 Subject: [PATCH 01/10] Reordered injected fields --- .../glassfish/maven/AbstractServerMojo.java | 56 ++++++++++++------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/glassfish/maven/AbstractServerMojo.java b/src/main/java/org/glassfish/maven/AbstractServerMojo.java index 0c44e3f..bd5aabc 100644 --- a/src/main/java/org/glassfish/maven/AbstractServerMojo.java +++ b/src/main/java/org/glassfish/maven/AbstractServerMojo.java @@ -72,12 +72,9 @@ public abstract class AbstractServerMojo extends AbstractMojo { private static final String DEFAULT_GF_VERSION = "4.0"; private static String gfVersion; - /** - * The remote repositories where artifacts are located. - * This is automatically injected by the Maven framework. - */ - @Parameter(property = "project.remoteArtifactRepositories") - protected List remoteRepositories; + /******************************************* + * Parameters supplied by configuration + ******************************************/ /** * Identifier of the Embedded GlassFish server. @@ -230,6 +227,33 @@ public abstract class AbstractServerMojo extends AbstractMojo { @Parameter(property = "autoDelete", defaultValue = "true") protected Boolean autoDelete; + /*=============================================== + * End of parameters supplied by configuration + ***********************************************/ + + /** + * @deprecated This is a deprecated and unused configuration. Likely to be removed in the next version of the plugin. + */ + @Parameter(property = "containerType", defaultValue = "all") + protected String containerType; + + /*************************************** + * Dependencies injected by Maven + ***************************************/ + + /** + * This is automatically injected by the Maven framework. + */ + @Parameter(property = "localRepository", required = true) + protected ArtifactRepository localRepository; + + /** + * The remote repositories where artifacts are located. + * This is automatically injected by the Maven framework. + */ + @Parameter(property = "project.remoteArtifactRepositories") + protected List remoteRepositories; + /** * The maven project. */ @@ -245,12 +269,6 @@ public abstract class AbstractServerMojo extends AbstractMojo { @Component protected MavenProjectBuilder projectBuilder; - /** - * This is automatically injected by the Maven framework. - */ - @Parameter(property = "localRepository", required = true) - protected ArtifactRepository localRepository; - @Component protected ArtifactResolver resolver; @@ -260,21 +278,17 @@ public abstract class AbstractServerMojo extends AbstractMojo { @Component protected ArtifactFactory factory; - /** - * @deprecated This is a deprecated and unused configuration. Likely to be removed in the next version of the plugin. - */ - @Parameter(property = "containerType", defaultValue = "all") - protected String containerType; + @Component + private ArtifactMetadataSource artifactMetadataSource; -// protected GlassFish gf; + /*======================================= + * End of dependencies injected by Maven + ***************************************/ // HashMap with Key=serverId, Value=Bootstrap ClassLoader protected static HashMap classLoaders = new HashMap(); private static ClassLoader classLoader; - @Component - private ArtifactMetadataSource artifactMetadataSource; - public abstract void execute() throws MojoExecutionException, MojoFailureException; protected ClassLoader getClassLoader() throws MojoExecutionException { From 181c188d2c749b721f4eed2dfe721d244cc49b26 Mon Sep 17 00:00:00 2001 From: Ondro Mihalyi Date: Tue, 29 Apr 2025 12:58:55 +0200 Subject: [PATCH 02/10] Add glassfishVersion parameter To specify Embedded GlassFish version to use without having to add the whole dependnecy definition --- .../glassfish/maven/AbstractServerMojo.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/glassfish/maven/AbstractServerMojo.java b/src/main/java/org/glassfish/maven/AbstractServerMojo.java index bd5aabc..041ebe7 100644 --- a/src/main/java/org/glassfish/maven/AbstractServerMojo.java +++ b/src/main/java/org/glassfish/maven/AbstractServerMojo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Contributors to the Eclipse Foundation. + * Copyright (c) 2023,2025 Contributors to the Eclipse Foundation. * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -69,7 +69,7 @@ public abstract class AbstractServerMojo extends AbstractMojo { private static final String GF_API_GROUP_ID = "org.glassfish.main.common"; private static final String GF_API_ARTIFACT_ID = "simple-glassfish-api"; - private static final String DEFAULT_GF_VERSION = "4.0"; + private static final String DEFAULT_GF_VERSION = "7.0.0"; private static String gfVersion; /******************************************* @@ -227,16 +227,22 @@ public abstract class AbstractServerMojo extends AbstractMojo { @Parameter(property = "autoDelete", defaultValue = "true") protected Boolean autoDelete; - /*=============================================== - * End of parameters supplied by configuration - ***********************************************/ - /** * @deprecated This is a deprecated and unused configuration. Likely to be removed in the next version of the plugin. */ @Parameter(property = "containerType", defaultValue = "all") protected String containerType; + /** + * Version of Embedded GlassFish to download if Embedded GlassFish dependency is not provided + */ + @Parameter + protected String glassfishVersion; + + /*=============================================== + * End of parameters supplied by configuration + ***********************************************/ + /*************************************** * Dependencies injected by Maven ***************************************/ @@ -371,6 +377,9 @@ private Artifact getUberFromSpecifiedDependency() { // GlassFish should be of same version as simple-glassfish-api as defined in plugin's pom. private String getGlassfishVersion(Artifact gfMvnPlugin) throws Exception { + if (glassfishVersion != null) { + return glassfishVersion; + } if (gfVersion != null) { return gfVersion; } From eae87f150fa1e4467fa09be0d824922df47b83b3 Mon Sep 17 00:00:00 2001 From: Ondro Mihalyi Date: Tue, 29 Apr 2025 13:14:14 +0200 Subject: [PATCH 03/10] Use GlassFish version defined in dependency management --- .../glassfish/maven/AbstractServerMojo.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/glassfish/maven/AbstractServerMojo.java b/src/main/java/org/glassfish/maven/AbstractServerMojo.java index 041ebe7..fda2f1d 100644 --- a/src/main/java/org/glassfish/maven/AbstractServerMojo.java +++ b/src/main/java/org/glassfish/maven/AbstractServerMojo.java @@ -375,11 +375,39 @@ private Artifact getUberFromSpecifiedDependency() { return null; } - // GlassFish should be of same version as simple-glassfish-api as defined in plugin's pom. + private Dependency getDependencyManagementInfoForEmbeddedAll() { + if (project.getDependencyManagement() != null) { + for (Dependency dependency : project.getDependencyManagement().getDependencies()) { + if (EMBEDDED_GROUP_ID.equals(dependency.getGroupId())) { + if (dependency.getArtifactId().equals(EMBEDDED_ALL)) { + return dependency; + } + } + } + } + return null; + } + + /** + * Determines GlassFish version from Maven configuration: + *
    + *
  1. If glassfishVersion parameter defined, return it
  2. + *
  3. If Embedded All depenendy defined in dependency management, return its version
  4. + *
  5. Returns the version of simple-glassfish-api as defined in plugin's pom - the version this plugin was built against
  6. + *
+ * + * @param gfMvnPlugin + * @return Determined version of Embedded GlassFish All artifact + * @throws Exception + */ private String getGlassfishVersion(Artifact gfMvnPlugin) throws Exception { if (glassfishVersion != null) { return glassfishVersion; } + Dependency dependencyManagementInfo = getDependencyManagementInfoForEmbeddedAll(); + if (dependencyManagementInfo != null) { + return dependencyManagementInfo.getVersion(); + } if (gfVersion != null) { return gfVersion; } From 8dd9dc1848780c014a2f2c2995d2e5e7b0affe62 Mon Sep 17 00:00:00 2001 From: Ondro Mihalyi Date: Tue, 29 Apr 2025 13:32:57 +0200 Subject: [PATCH 04/10] Move dependency and plugin versions for management sections --- pom.xml | 87 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 32 deletions(-) diff --git a/pom.xml b/pom.xml index a069287..f5ea8fb 100644 --- a/pom.xml +++ b/pom.xml @@ -40,13 +40,13 @@ ${target.maven.version} - + Bhavanishankar - + yaminikb @@ -58,18 +58,18 @@ - Glassfish dev mailing list - glassfish-dev@eclipse.org - https://dev.eclipse.org/mailman/listinfo/glassfish-dev - https://dev.eclipse.org/mailman/listinfo/glassfish-dev - https://dev.eclipse.org/mhonarc/lists/glassfish-dev + Glassfish dev mailing list + glassfish-dev@eclipse.org + https://dev.eclipse.org/mailman/listinfo/glassfish-dev + https://dev.eclipse.org/mailman/listinfo/glassfish-dev + https://dev.eclipse.org/mhonarc/lists/glassfish-dev github https://github.com/eclipse-ee4j/glassfish-maven-embedded-plugin/issues - + scm:git:https://github.com/eclipse-ee4j/glassfish-maven-embedded-plugin.git @@ -80,11 +80,39 @@ install + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.1 + + + org.apache.maven.plugins + maven-plugin-plugin + 3.15.1 + + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.12.0 + + + org.apache.maven.plugins + maven-release-plugin + 3.1.1 + + + org.apache.maven.plugins maven-compiler-plugin - 3.14.1 11 @@ -92,7 +120,6 @@ org.apache.maven.plugins maven-plugin-plugin - 3.15.1 embedded-glassfish @@ -100,47 +127,44 @@ org.apache.maven.plugins maven-source-plugin - 3.3.1 true - attach-sources - - jar-no-fork - + attach-sources + + jar-no-fork + org.apache.maven.plugins maven-javadoc-plugin - 3.12.0 - - attach-javadocs - - jar - - + + attach-javadocs + + jar + + - org.apache.maven.plugins - maven-release-plugin - 3.1.1 - - forked-path - false + org.apache.maven.plugins + maven-release-plugin + + forked-path + false @{project.version} ${release.arguments} - + org.apache.maven.scm @@ -148,7 +172,7 @@ 2.2.1 - + @@ -184,7 +208,6 @@ org.apache.maven.plugins maven-plugin-plugin - 3.15.1 @@ -201,5 +224,5 @@ repo - + From 8778412b1d96afd3c4667fc720545aff70d7c4f0 Mon Sep 17 00:00:00 2001 From: Ondro Mihalyi Date: Wed, 30 Apr 2025 00:07:44 +0200 Subject: [PATCH 05/10] Added IT tests using invoker plugin Added tests to cover GlassFish version/artifact selection. Moved old tests that were in nested maven modules to invoker tests. --- .github/workflows/maven.yml | 8 +- pom.xml | 26 +++++++ src/it/deploy/invoker.properties | 18 +++++ src/{test => it}/deploy/pom.xml | 62 ++++++++-------- src/it/deploy/postbuild.groovy | 24 ++++++ src/{test => it}/deploy/test.war | Bin .../start-with-dependency/invoker.properties | 18 +++++ src/it/start-with-dependency/pom.xml | 69 ++++++++++++++++++ src/it/start-with-dependency/postbuild.groovy | 29 ++++++++ .../start-with-gf-version/invoker.properties | 18 +++++ src/it/start-with-gf-version/pom.xml | 49 +++++++++++++ src/it/start-with-gf-version/postbuild.groovy | 29 ++++++++ .../invoker.properties | 18 +++++ .../pom.xml | 58 +++++++++++++++ .../postbuild.groovy | 29 ++++++++ src/it/start/invoker.properties | 18 +++++ src/it/start/pom.xml | 48 ++++++++++++ src/it/start/postbuild.groovy | 23 ++++++ src/test/pom.xml | 40 ---------- src/test/start/pom.xml | 52 ------------- 20 files changed, 504 insertions(+), 132 deletions(-) create mode 100644 src/it/deploy/invoker.properties rename src/{test => it}/deploy/pom.xml (50%) create mode 100644 src/it/deploy/postbuild.groovy rename src/{test => it}/deploy/test.war (100%) create mode 100644 src/it/start-with-dependency/invoker.properties create mode 100644 src/it/start-with-dependency/pom.xml create mode 100644 src/it/start-with-dependency/postbuild.groovy create mode 100644 src/it/start-with-gf-version/invoker.properties create mode 100644 src/it/start-with-gf-version/pom.xml create mode 100644 src/it/start-with-gf-version/postbuild.groovy create mode 100644 src/it/start-with-version-in-dep-management/invoker.properties create mode 100644 src/it/start-with-version-in-dep-management/pom.xml create mode 100644 src/it/start-with-version-in-dep-management/postbuild.groovy create mode 100644 src/it/start/invoker.properties create mode 100644 src/it/start/pom.xml create mode 100644 src/it/start/postbuild.groovy delete mode 100644 src/test/pom.xml delete mode 100644 src/test/start/pom.xml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 4779b01..332b919 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -32,15 +32,9 @@ jobs: with: distribution: 'temurin' java-version: ${{ matrix.java_version }} - - name: Maven Build + - name: Maven Build & Test run: | mvn --show-version \ --no-transfer-progress \ --activate-profiles staging \ install - - name: Run test - run: | - mvn --no-transfer-progress \ - --activate-profiles staging \ - --file src/test \ - install diff --git a/pom.xml b/pom.xml index f5ea8fb..a3a854a 100644 --- a/pom.xml +++ b/pom.xml @@ -35,6 +35,8 @@ 3.6.3 + true + 7.0.23 @@ -107,6 +109,10 @@ maven-release-plugin 3.1.1 + + maven-invoker-plugin + 3.9.0 + @@ -124,6 +130,26 @@ embedded-glassfish + + maven-invoker-plugin + + + integration-test + + install + run + + + + + ${project.build.directory}/local-repo + ${skipTests} + ${skipTests} + + ${tested.glassfish.version} + + + org.apache.maven.plugins maven-source-plugin diff --git a/src/it/deploy/invoker.properties b/src/it/deploy/invoker.properties new file mode 100644 index 0000000..0005ec1 --- /dev/null +++ b/src/it/deploy/invoker.properties @@ -0,0 +1,18 @@ +# +# Copyright (c) 2022, 2023 Contributors to Eclipse Foundation. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v. 2.0, which is available at +# http://www.eclipse.org/legal/epl-2.0. +# +# This Source Code may also be made available under the following Secondary +# Licenses when the conditions for such availability set forth in the +# Eclipse Public License v. 2.0 are satisfied: GNU General Public License, +# version 2 with the GNU Classpath Exception, which is available at +# https://www.gnu.org/software/classpath/license.html. +# +# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +# + +invoker.goals=test + diff --git a/src/test/deploy/pom.xml b/src/it/deploy/pom.xml similarity index 50% rename from src/test/deploy/pom.xml rename to src/it/deploy/pom.xml index 422dd76..0915ac9 100644 --- a/src/test/deploy/pom.xml +++ b/src/it/deploy/pom.xml @@ -19,38 +19,34 @@ --> - 4.0.0 - - org.glassfish.embedded.tester - tester-parent - 7.1-SNAPSHOT - - deploy-tester - pom - Glassfish Embedded Maven Plugin Deploy Tester - - - install - - - org.glassfish.embedded - embedded-glassfish-maven-plugin - ${project.version} - - test.war - 8080 - - - - install - - run - deploy - - - - - - + 4.0.0 + org.glassfish.embedded.embedded-glassfish-maven-plugin.its + deploy + @project.version@ + pom + + + + + org.glassfish.embedded + embedded-glassfish-maven-plugin + @project.version@ + + test.war + 8081 + + + + test + + start + deploy + stop + + + + + + diff --git a/src/it/deploy/postbuild.groovy b/src/it/deploy/postbuild.groovy new file mode 100644 index 0000000..4e3ba55 --- /dev/null +++ b/src/it/deploy/postbuild.groovy @@ -0,0 +1,24 @@ +/* + Copyright (c) 2022, 2023 Contributors to Eclipse Foundation. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +*/ + +String [] buildLog = new File(basedir, 'build.log') + +messageLines = buildLog.grep(~/^INFO: myapp was successfully deployed.*/) + +assert messageLines.size() == 1: 'Message about myapp app deployed was expected in build log with level INFO' + +true + diff --git a/src/test/deploy/test.war b/src/it/deploy/test.war similarity index 100% rename from src/test/deploy/test.war rename to src/it/deploy/test.war diff --git a/src/it/start-with-dependency/invoker.properties b/src/it/start-with-dependency/invoker.properties new file mode 100644 index 0000000..0005ec1 --- /dev/null +++ b/src/it/start-with-dependency/invoker.properties @@ -0,0 +1,18 @@ +# +# Copyright (c) 2022, 2023 Contributors to Eclipse Foundation. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v. 2.0, which is available at +# http://www.eclipse.org/legal/epl-2.0. +# +# This Source Code may also be made available under the following Secondary +# Licenses when the conditions for such availability set forth in the +# Eclipse Public License v. 2.0 are satisfied: GNU General Public License, +# version 2 with the GNU Classpath Exception, which is available at +# https://www.gnu.org/software/classpath/license.html. +# +# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +# + +invoker.goals=test + diff --git a/src/it/start-with-dependency/pom.xml b/src/it/start-with-dependency/pom.xml new file mode 100644 index 0000000..d1ede13 --- /dev/null +++ b/src/it/start-with-dependency/pom.xml @@ -0,0 +1,69 @@ + + + + 4.0.0 + + org.glassfish.embedded.embedded-glassfish-maven-plugin.its + start-with-gf-version + @project.version@ + pom + + + + + + org.glassfish.main.extras + glassfish-embedded-all + 7.0.1 + + + + + + + + + org.glassfish.embedded + embedded-glassfish-maven-plugin + @project.version@ + + + test + + start + stop + + + 8081 + + 7.0.0 + + + + + + org.glassfish.main.extras + glassfish-embedded-all + @tested.glassfish.version@ + + + + + + diff --git a/src/it/start-with-dependency/postbuild.groovy b/src/it/start-with-dependency/postbuild.groovy new file mode 100644 index 0000000..9ada9a8 --- /dev/null +++ b/src/it/start-with-dependency/postbuild.groovy @@ -0,0 +1,29 @@ +/* + Copyright (c) 2022, 2023 Contributors to Eclipse Foundation. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +*/ + +String [] buildLog = new File(basedir, 'build.log') + +glassfishVersion = glassfishVersion.replace(".", "\\.") +versionLines = buildLog.grep(~/^.*ClassPath Element.*glassfish-embedded-all-${glassfishVersion}\.jar.*$/) + +assert versionLines.size() == 1: 'Configured message was expected in build log at INFO level' + +startedLines = buildLog.grep(~/^INFO: Started GlassFish.*/) + +assert startedLines.size() == 1: 'Expected messages about GlassFish started at INFO level' + +true + diff --git a/src/it/start-with-gf-version/invoker.properties b/src/it/start-with-gf-version/invoker.properties new file mode 100644 index 0000000..0005ec1 --- /dev/null +++ b/src/it/start-with-gf-version/invoker.properties @@ -0,0 +1,18 @@ +# +# Copyright (c) 2022, 2023 Contributors to Eclipse Foundation. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v. 2.0, which is available at +# http://www.eclipse.org/legal/epl-2.0. +# +# This Source Code may also be made available under the following Secondary +# Licenses when the conditions for such availability set forth in the +# Eclipse Public License v. 2.0 are satisfied: GNU General Public License, +# version 2 with the GNU Classpath Exception, which is available at +# https://www.gnu.org/software/classpath/license.html. +# +# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +# + +invoker.goals=test + diff --git a/src/it/start-with-gf-version/pom.xml b/src/it/start-with-gf-version/pom.xml new file mode 100644 index 0000000..c7c0490 --- /dev/null +++ b/src/it/start-with-gf-version/pom.xml @@ -0,0 +1,49 @@ + + + + 4.0.0 + + org.glassfish.embedded.embedded-glassfish-maven-plugin.its + start-with-gf-version + @project.version@ + pom + + + + + org.glassfish.embedded + embedded-glassfish-maven-plugin + @project.version@ + + + test + + start + stop + + + 8081 + @tested.glassfish.version@ + + + + + + + diff --git a/src/it/start-with-gf-version/postbuild.groovy b/src/it/start-with-gf-version/postbuild.groovy new file mode 100644 index 0000000..9ada9a8 --- /dev/null +++ b/src/it/start-with-gf-version/postbuild.groovy @@ -0,0 +1,29 @@ +/* + Copyright (c) 2022, 2023 Contributors to Eclipse Foundation. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +*/ + +String [] buildLog = new File(basedir, 'build.log') + +glassfishVersion = glassfishVersion.replace(".", "\\.") +versionLines = buildLog.grep(~/^.*ClassPath Element.*glassfish-embedded-all-${glassfishVersion}\.jar.*$/) + +assert versionLines.size() == 1: 'Configured message was expected in build log at INFO level' + +startedLines = buildLog.grep(~/^INFO: Started GlassFish.*/) + +assert startedLines.size() == 1: 'Expected messages about GlassFish started at INFO level' + +true + diff --git a/src/it/start-with-version-in-dep-management/invoker.properties b/src/it/start-with-version-in-dep-management/invoker.properties new file mode 100644 index 0000000..0005ec1 --- /dev/null +++ b/src/it/start-with-version-in-dep-management/invoker.properties @@ -0,0 +1,18 @@ +# +# Copyright (c) 2022, 2023 Contributors to Eclipse Foundation. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v. 2.0, which is available at +# http://www.eclipse.org/legal/epl-2.0. +# +# This Source Code may also be made available under the following Secondary +# Licenses when the conditions for such availability set forth in the +# Eclipse Public License v. 2.0 are satisfied: GNU General Public License, +# version 2 with the GNU Classpath Exception, which is available at +# https://www.gnu.org/software/classpath/license.html. +# +# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +# + +invoker.goals=test + diff --git a/src/it/start-with-version-in-dep-management/pom.xml b/src/it/start-with-version-in-dep-management/pom.xml new file mode 100644 index 0000000..814e004 --- /dev/null +++ b/src/it/start-with-version-in-dep-management/pom.xml @@ -0,0 +1,58 @@ + + + + 4.0.0 + + org.glassfish.embedded.embedded-glassfish-maven-plugin.its + start-with-gf-version + @project.version@ + pom + + + + + org.glassfish.main.extras + glassfish-embedded-all + @tested.glassfish.version@ + + + + + + + + org.glassfish.embedded + embedded-glassfish-maven-plugin + @project.version@ + + + test + + start + stop + + + 8081 + + + + + + + diff --git a/src/it/start-with-version-in-dep-management/postbuild.groovy b/src/it/start-with-version-in-dep-management/postbuild.groovy new file mode 100644 index 0000000..9ada9a8 --- /dev/null +++ b/src/it/start-with-version-in-dep-management/postbuild.groovy @@ -0,0 +1,29 @@ +/* + Copyright (c) 2022, 2023 Contributors to Eclipse Foundation. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +*/ + +String [] buildLog = new File(basedir, 'build.log') + +glassfishVersion = glassfishVersion.replace(".", "\\.") +versionLines = buildLog.grep(~/^.*ClassPath Element.*glassfish-embedded-all-${glassfishVersion}\.jar.*$/) + +assert versionLines.size() == 1: 'Configured message was expected in build log at INFO level' + +startedLines = buildLog.grep(~/^INFO: Started GlassFish.*/) + +assert startedLines.size() == 1: 'Expected messages about GlassFish started at INFO level' + +true + diff --git a/src/it/start/invoker.properties b/src/it/start/invoker.properties new file mode 100644 index 0000000..0005ec1 --- /dev/null +++ b/src/it/start/invoker.properties @@ -0,0 +1,18 @@ +# +# Copyright (c) 2022, 2023 Contributors to Eclipse Foundation. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v. 2.0, which is available at +# http://www.eclipse.org/legal/epl-2.0. +# +# This Source Code may also be made available under the following Secondary +# Licenses when the conditions for such availability set forth in the +# Eclipse Public License v. 2.0 are satisfied: GNU General Public License, +# version 2 with the GNU Classpath Exception, which is available at +# https://www.gnu.org/software/classpath/license.html. +# +# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +# + +invoker.goals=test + diff --git a/src/it/start/pom.xml b/src/it/start/pom.xml new file mode 100644 index 0000000..90dde80 --- /dev/null +++ b/src/it/start/pom.xml @@ -0,0 +1,48 @@ + + + + 4.0.0 + + org.glassfish.embedded.embedded-glassfish-maven-plugin.its + start + @project.version@ + pom + + + + + org.glassfish.embedded + embedded-glassfish-maven-plugin + @project.version@ + + + test + + start + stop + + + 8081 + + + + + + + diff --git a/src/it/start/postbuild.groovy b/src/it/start/postbuild.groovy new file mode 100644 index 0000000..5e40848 --- /dev/null +++ b/src/it/start/postbuild.groovy @@ -0,0 +1,23 @@ +/* + Copyright (c) 2022, 2023 Contributors to Eclipse Foundation. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +*/ + +String [] buildLog = new File(basedir, 'build.log') + +startedLines = buildLog.grep(~/^INFO: Started GlassFish.*/) + +assert startedLines.size() == 1: 'Expected messages about GlassFish started at INFO level' +true + diff --git a/src/test/pom.xml b/src/test/pom.xml deleted file mode 100644 index 144b9d6..0000000 --- a/src/test/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - 4.0.0 - - org.eclipse.ee4j - project - 1.0.7 - - org.glassfish.embedded.tester - tester-parent - pom - 7.1-SNAPSHOT - - Glassfish Embedded Maven Plugin Tester Parent Pom - - - - start - - - diff --git a/src/test/start/pom.xml b/src/test/start/pom.xml deleted file mode 100644 index 242dcab..0000000 --- a/src/test/start/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - 4.0.0 - - org.glassfish.embedded.tester - tester-parent - 7.1-SNAPSHOT - - startstop-tester - pom - Glassfish Embedded Maven Plugin Start Stop Tester - - - install - - - org.glassfish.embedded - embedded-glassfish-maven-plugin - ${project.version} - - - install - - start - stop - - - - - - - - From d1d1261f376f252b8a527db89cb0b4fcd854d986 Mon Sep 17 00:00:00 2001 From: Ondro Mihalyi Date: Fri, 26 Sep 2025 22:17:26 +0200 Subject: [PATCH 06/10] IT Tests - separate execution into different phases --- src/it/deploy/pom.xml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/it/deploy/pom.xml b/src/it/deploy/pom.xml index 0915ac9..4554450 100644 --- a/src/it/deploy/pom.xml +++ b/src/it/deploy/pom.xml @@ -37,10 +37,20 @@ - test + pre-integration-test start + + + + integration-test + deploy + + + + post-integration-test + stop From e5fd779fdc486bd5ea95fc0a9ec4a8f092e5016b Mon Sep 17 00:00:00 2001 From: Ondro Mihalyi Date: Mon, 29 Sep 2025 21:35:38 +0200 Subject: [PATCH 07/10] Split test execution into multiple phases --- pom.xml | 2 +- src/it/deploy/invoker.properties | 2 +- src/it/deploy/pom.xml | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index a3a854a..f9a7762 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ 3.6.3 true - 7.0.23 + 7.0.25 diff --git a/src/it/deploy/invoker.properties b/src/it/deploy/invoker.properties index 0005ec1..4d0b7f0 100644 --- a/src/it/deploy/invoker.properties +++ b/src/it/deploy/invoker.properties @@ -14,5 +14,5 @@ # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 # -invoker.goals=test +invoker.goals=verify diff --git a/src/it/deploy/pom.xml b/src/it/deploy/pom.xml index 4554450..0b5f584 100644 --- a/src/it/deploy/pom.xml +++ b/src/it/deploy/pom.xml @@ -37,18 +37,21 @@ + pre-integration pre-integration-test start + integration integration-test deploy + post-integration post-integration-test stop From 7b87cb3ba990f4e4336ced15bbe462f016c5e495 Mon Sep 17 00:00:00 2001 From: Ondro Mihalyi Date: Mon, 29 Sep 2025 23:12:55 +0200 Subject: [PATCH 08/10] Documentation for the plugin and a test case --- README.md | 260 +++++++++++++++++- .../start-admin-commands/invoker.properties | 18 ++ src/it/start-admin-commands/pom.xml | 53 ++++ src/it/start-admin-commands/postbuild.groovy | 23 ++ 4 files changed, 352 insertions(+), 2 deletions(-) create mode 100644 src/it/start-admin-commands/invoker.properties create mode 100644 src/it/start-admin-commands/pom.xml create mode 100644 src/it/start-admin-commands/postbuild.groovy diff --git a/README.md b/README.md index 88527ba..43a9ce7 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,259 @@ -Pre-requisite +# Maven Embedded GlassFish Plugin -To build this project, JDK 11 is required. +A Maven plugin for managing Embedded GlassFish server instances during the build lifecycle. + +## Quick Start + +Run your project's main artifact on Embedded GlassFish directly from command line without modifying your `pom.xml`: + +```bash +mvn org.glassfish.embedded:embedded-glassfish-maven-plugin:7.1-SNAPSHOT:run -DglassfishVersion=7.0.25 +``` + +Or add the plugin to your `pom.xml`: + +```xml + + org.glassfish.embedded + embedded-glassfish-maven-plugin + 7.1-SNAPSHOT + + 7.0.25 + + +``` + +Start the server with your application and wait until it stops: +```bash +mvn embedded-glassfish:run +``` + +## Prerequisites + +- JDK 11 or higher +- Maven 3.6.3 or higher + +## Basic Usage + +### Command Line + +Start server in background: +```bash +mvn embedded-glassfish:start +``` + +Deploy application: +```bash +mvn embedded-glassfish:deploy +``` + +Stop server: +```bash +mvn embedded-glassfish:stop +``` + +### Integration Testing + +```xml + + org.glassfish.embedded + embedded-glassfish-maven-plugin + 7.1-SNAPSHOT + + + start-server + pre-integration-test + + start + deploy + + + + stop-server + post-integration-test + + undeploy + stop + + + + +``` + +## Goals Overview + +| Goal | Description | Default Phase | +|------|-------------|---------------| +| [`start`](#start) | Starts an Embedded GlassFish server | pre-integration-test | +| [`stop`](#stop) | Stops the Embedded GlassFish server | post-integration-test | +| [`deploy`](#deploy) | Deploys an application to the server | pre-integration-test | +| [`undeploy`](#undeploy) | Undeploys an application from the server | post-integration-test | +| [`run`](#run) | Starts server and keeps it running | none | +| [`admin`](#admin) | Executes admin commands | none | + +## Configuration + +### Basic Configuration + +```xml + + org.glassfish.embedded + embedded-glassfish-maven-plugin + 7.1-SNAPSHOT + + 8080 + ${project.build.directory}/${project.build.finalName}.war + + +``` + +- `port` - HTTP port number for the server (default: 8080) +- `app` - Path to the application artifact to deploy (default: main artifact) + +### Automatic Artifact Deployment + +The plugin automatically detects and deploys your project's main artifact without requiring explicit configuration: + +```xml + + org.glassfish.embedded + embedded-glassfish-maven-plugin + 7.1-SNAPSHOT + + + + +``` + +**Note:** Currently assumes WAR packaging. For other artifact types, specify the `app` parameter explicitly. + +### Admin Commands + +Execute administrative commands on the running server: + +```xml + + org.glassfish.embedded + embedded-glassfish-maven-plugin + 7.1-SNAPSHOT + + + set configs.config.server-config.network-config.protocols.protocol.http-listener.http.websockets-support-enabled=true + create-jdbc-resource --connectionpoolid mypool jdbc/myresource + + + +``` + +Command line usage: +```bash +mvn embedded-glassfish:admin -Dcommands="set server.monitoring-service.module-monitoring-levels.web-container=HIGH" +``` + +## Configuration Reference + +### Server Configuration +- `configFile` - Custom domain configuration file +- `glassfishVersion` - GlassFish version to use +- `port` - HTTP port number (default: 8080) +- `ports` - Map of port configurations +- `serverID` - Server identifier (default: "maven") + +### Application Deployment +- `app` - Path to application artifact to deploy (defaults to `${project.build.directory}/${project.build.finalName}.war`) +- `contextRoot` - Application context root +- `name` - Application name (default: "myapp") + +### Advanced Configuration +- `bootstrapProperties` - Bootstrap properties +- `glassfishProperties` - GlassFish server properties +- `instanceRoot` - Server instance root directory + +## Goal Reference + +### start +Starts an Embedded GlassFish server with the configured parameters. + +**Default Phase:** pre-integration-test + +**Configuration:** +- Uses all server configuration parameters (serverID, port, glassfishProperties, etc.) + +**Example:** +```bash +mvn embedded-glassfish:start +``` + +### stop +Stops the Embedded GlassFish server and cleans up resources. + +**Default Phase:** post-integration-test + +**Configuration:** +- `serverID` - Server identifier to stop (default: "maven") + +**Example:** +```bash +mvn embedded-glassfish:stop +``` + +### deploy +Deploys an application to the running Embedded GlassFish server. + +**Default Phase:** pre-integration-test + +**Configuration:** +- `app` - Application path (auto-detects if not specified) +- `name` - Application name (default: "myapp") +- `contextRoot` - Web application context root +- `deploymentParams` - Additional deployment parameters + +**Example:** +```bash +mvn embedded-glassfish:deploy -Dapp=target/myapp.war +``` + +### undeploy +Undeploys an application from the Embedded GlassFish server. + +**Default Phase:** post-integration-test + +**Configuration:** +- `name` - Application name to undeploy (default: "myapp") +- `undeploymentParams` - Additional undeployment parameters + +**Example:** +```bash +mvn embedded-glassfish:undeploy -Dname=myapp +``` + +### run +Starts the server, deploys applications, and runs interactively. Allows redeployment by pressing Enter or exit by typing 'X'. + +**Default Phase:** none (manual execution) + +**Configuration:** +- Combines all server and deployment configurations +- Executes all configured admin and deploy goals + +**Example:** +```bash +mvn embedded-glassfish:run +``` + +### admin +Executes administrative commands on the running server. + +**Default Phase:** pre-integration-test + +**Configuration:** +- `commands` - Array of admin commands to execute + +**Example:** +```bash +mvn embedded-glassfish:admin -Dcommands="create-jdbc-resource --connectionpoolid mypool jdbc/myresource" +``` + +## License + +Eclipse Public License v. 2.0 diff --git a/src/it/start-admin-commands/invoker.properties b/src/it/start-admin-commands/invoker.properties new file mode 100644 index 0000000..0005ec1 --- /dev/null +++ b/src/it/start-admin-commands/invoker.properties @@ -0,0 +1,18 @@ +# +# Copyright (c) 2022, 2023 Contributors to Eclipse Foundation. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v. 2.0, which is available at +# http://www.eclipse.org/legal/epl-2.0. +# +# This Source Code may also be made available under the following Secondary +# Licenses when the conditions for such availability set forth in the +# Eclipse Public License v. 2.0 are satisfied: GNU General Public License, +# version 2 with the GNU Classpath Exception, which is available at +# https://www.gnu.org/software/classpath/license.html. +# +# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +# + +invoker.goals=test + diff --git a/src/it/start-admin-commands/pom.xml b/src/it/start-admin-commands/pom.xml new file mode 100644 index 0000000..a62b665 --- /dev/null +++ b/src/it/start-admin-commands/pom.xml @@ -0,0 +1,53 @@ + + + + 4.0.0 + + org.glassfish.embedded.embedded-glassfish-maven-plugin.its + start + @project.version@ + pom + + + + + org.glassfish.embedded + embedded-glassfish-maven-plugin + @project.version@ + + + test + + start + admin + stop + + + 8081 + + set configs.config.server-config.network-config.protocols.protocol.http-listener.http.websockets-support-enabled=true + set configs.config.server-config.thread-pools.thread-pool.http-thread-pool.max-thread-pool-size=200 + + + + + + + + diff --git a/src/it/start-admin-commands/postbuild.groovy b/src/it/start-admin-commands/postbuild.groovy new file mode 100644 index 0000000..5b104e7 --- /dev/null +++ b/src/it/start-admin-commands/postbuild.groovy @@ -0,0 +1,23 @@ +/* + Copyright (c) 2022, 2023 Contributors to Eclipse Foundation. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +*/ + +String [] buildLog = new File(basedir, 'build.log') + +startedLines = buildLog.grep(~/^INFO: Ran command.*SUCCESS.*/) + +assert startedLines.size() == 2: 'Expected messages about running admin commands in build log' +true + From 140cfa40563ebafc895b1c6370f049a87d96d2e4 Mon Sep 17 00:00:00 2001 From: Ondro Mihalyi Date: Mon, 29 Sep 2025 23:25:40 +0200 Subject: [PATCH 09/10] Restructure tests to follow the integration tests structure --- src/it/start-admin-commands/invoker.properties | 2 +- src/it/start-admin-commands/pom.xml | 17 +++++++++++++++-- src/it/start-with-dependency/invoker.properties | 2 +- src/it/start-with-dependency/pom.xml | 11 +++++++++-- src/it/start-with-gf-version/invoker.properties | 2 +- src/it/start-with-gf-version/pom.xml | 11 +++++++++-- .../invoker.properties | 2 +- .../pom.xml | 11 +++++++++-- src/it/start/invoker.properties | 2 +- src/it/start/pom.xml | 11 +++++++++-- 10 files changed, 56 insertions(+), 15 deletions(-) diff --git a/src/it/start-admin-commands/invoker.properties b/src/it/start-admin-commands/invoker.properties index 0005ec1..4d0b7f0 100644 --- a/src/it/start-admin-commands/invoker.properties +++ b/src/it/start-admin-commands/invoker.properties @@ -14,5 +14,5 @@ # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 # -invoker.goals=test +invoker.goals=verify diff --git a/src/it/start-admin-commands/pom.xml b/src/it/start-admin-commands/pom.xml index a62b665..5bb3939 100644 --- a/src/it/start-admin-commands/pom.xml +++ b/src/it/start-admin-commands/pom.xml @@ -32,11 +32,17 @@ @project.version@ - test + pre-integration + pre-integration-test start + + + + integration-test + integration-test + admin - stop 8081 @@ -46,6 +52,13 @@ + + post-integration + post-integration-test + + stop + + diff --git a/src/it/start-with-dependency/invoker.properties b/src/it/start-with-dependency/invoker.properties index 0005ec1..4d0b7f0 100644 --- a/src/it/start-with-dependency/invoker.properties +++ b/src/it/start-with-dependency/invoker.properties @@ -14,5 +14,5 @@ # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 # -invoker.goals=test +invoker.goals=verify diff --git a/src/it/start-with-dependency/pom.xml b/src/it/start-with-dependency/pom.xml index d1ede13..3099c99 100644 --- a/src/it/start-with-dependency/pom.xml +++ b/src/it/start-with-dependency/pom.xml @@ -44,10 +44,10 @@ @project.version@ - test + pre-integration + pre-integration-test start - stop 8081 @@ -55,6 +55,13 @@ 7.0.0 + + post-integration + post-integration-test + + stop + + diff --git a/src/it/start-with-gf-version/invoker.properties b/src/it/start-with-gf-version/invoker.properties index 0005ec1..4d0b7f0 100644 --- a/src/it/start-with-gf-version/invoker.properties +++ b/src/it/start-with-gf-version/invoker.properties @@ -14,5 +14,5 @@ # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 # -invoker.goals=test +invoker.goals=verify diff --git a/src/it/start-with-gf-version/pom.xml b/src/it/start-with-gf-version/pom.xml index c7c0490..0a21cb8 100644 --- a/src/it/start-with-gf-version/pom.xml +++ b/src/it/start-with-gf-version/pom.xml @@ -32,16 +32,23 @@ @project.version@ - test + pre-integration + pre-integration-test start - stop 8081 @tested.glassfish.version@ + + post-integration + post-integration-test + + stop + + diff --git a/src/it/start-with-version-in-dep-management/invoker.properties b/src/it/start-with-version-in-dep-management/invoker.properties index 0005ec1..4d0b7f0 100644 --- a/src/it/start-with-version-in-dep-management/invoker.properties +++ b/src/it/start-with-version-in-dep-management/invoker.properties @@ -14,5 +14,5 @@ # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 # -invoker.goals=test +invoker.goals=verify diff --git a/src/it/start-with-version-in-dep-management/pom.xml b/src/it/start-with-version-in-dep-management/pom.xml index 814e004..6e7e823 100644 --- a/src/it/start-with-version-in-dep-management/pom.xml +++ b/src/it/start-with-version-in-dep-management/pom.xml @@ -42,15 +42,22 @@ @project.version@ - test + pre-integration + pre-integration-test start - stop 8081 + + post-integration + post-integration-test + + stop + + diff --git a/src/it/start/invoker.properties b/src/it/start/invoker.properties index 0005ec1..4d0b7f0 100644 --- a/src/it/start/invoker.properties +++ b/src/it/start/invoker.properties @@ -14,5 +14,5 @@ # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 # -invoker.goals=test +invoker.goals=verify diff --git a/src/it/start/pom.xml b/src/it/start/pom.xml index 90dde80..c091de0 100644 --- a/src/it/start/pom.xml +++ b/src/it/start/pom.xml @@ -32,15 +32,22 @@ @project.version@ - test + integration + integration-test start - stop 8081 + + post-integration + post-integration-test + + stop + + From cdffff3dcbaec760ddb116ff86cf5661ef1c7ef2 Mon Sep 17 00:00:00 2001 From: Ondro Mihalyi Date: Mon, 6 Oct 2025 17:57:34 +0200 Subject: [PATCH 10/10] Use glassfish.version instead of glassfishVersion --- README.md | 6 +- .../invoker.properties | 18 ++++++ .../start-with-gf-version-as-property/pom.xml | 55 +++++++++++++++++++ .../postbuild.groovy | 29 ++++++++++ src/it/start-with-gf-version/pom.xml | 2 +- .../glassfish/maven/AbstractServerMojo.java | 3 +- 6 files changed, 108 insertions(+), 5 deletions(-) create mode 100644 src/it/start-with-gf-version-as-property/invoker.properties create mode 100644 src/it/start-with-gf-version-as-property/pom.xml create mode 100644 src/it/start-with-gf-version-as-property/postbuild.groovy diff --git a/README.md b/README.md index 43a9ce7..661eb07 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A Maven plugin for managing Embedded GlassFish server instances during the build Run your project's main artifact on Embedded GlassFish directly from command line without modifying your `pom.xml`: ```bash -mvn org.glassfish.embedded:embedded-glassfish-maven-plugin:7.1-SNAPSHOT:run -DglassfishVersion=7.0.25 +mvn org.glassfish.embedded:embedded-glassfish-maven-plugin:7.1-SNAPSHOT:run -Dglassfish.version=7.0.25 ``` Or add the plugin to your `pom.xml`: @@ -18,7 +18,7 @@ Or add the plugin to your `pom.xml`: embedded-glassfish-maven-plugin 7.1-SNAPSHOT - 7.0.25 + 7.0.25 ``` @@ -154,7 +154,7 @@ mvn embedded-glassfish:admin -Dcommands="set server.monitoring-service.module-mo ### Server Configuration - `configFile` - Custom domain configuration file -- `glassfishVersion` - GlassFish version to use +- `glassfish.version` - GlassFish version to use - `port` - HTTP port number (default: 8080) - `ports` - Map of port configurations - `serverID` - Server identifier (default: "maven") diff --git a/src/it/start-with-gf-version-as-property/invoker.properties b/src/it/start-with-gf-version-as-property/invoker.properties new file mode 100644 index 0000000..6e13223 --- /dev/null +++ b/src/it/start-with-gf-version-as-property/invoker.properties @@ -0,0 +1,18 @@ +# +# Copyright (c) 2022, 2023 Contributors to Eclipse Foundation. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v. 2.0, which is available at +# http://www.eclipse.org/legal/epl-2.0. +# +# This Source Code may also be made available under the following Secondary +# Licenses when the conditions for such availability set forth in the +# Eclipse Public License v. 2.0 are satisfied: GNU General Public License, +# version 2 with the GNU Classpath Exception, which is available at +# https://www.gnu.org/software/classpath/license.html. +# +# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +# + +invoker.goals=verify -Dglassfish.version=${tested.glassfish.version} + diff --git a/src/it/start-with-gf-version-as-property/pom.xml b/src/it/start-with-gf-version-as-property/pom.xml new file mode 100644 index 0000000..f9edbbe --- /dev/null +++ b/src/it/start-with-gf-version-as-property/pom.xml @@ -0,0 +1,55 @@ + + + + 4.0.0 + + org.glassfish.embedded.embedded-glassfish-maven-plugin.its + start-with-gf-version + @project.version@ + pom + + + + + org.glassfish.embedded + embedded-glassfish-maven-plugin + @project.version@ + + + pre-integration + pre-integration-test + + start + + + 8081 + + + + post-integration + post-integration-test + + stop + + + + + + + diff --git a/src/it/start-with-gf-version-as-property/postbuild.groovy b/src/it/start-with-gf-version-as-property/postbuild.groovy new file mode 100644 index 0000000..9ada9a8 --- /dev/null +++ b/src/it/start-with-gf-version-as-property/postbuild.groovy @@ -0,0 +1,29 @@ +/* + Copyright (c) 2022, 2023 Contributors to Eclipse Foundation. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +*/ + +String [] buildLog = new File(basedir, 'build.log') + +glassfishVersion = glassfishVersion.replace(".", "\\.") +versionLines = buildLog.grep(~/^.*ClassPath Element.*glassfish-embedded-all-${glassfishVersion}\.jar.*$/) + +assert versionLines.size() == 1: 'Configured message was expected in build log at INFO level' + +startedLines = buildLog.grep(~/^INFO: Started GlassFish.*/) + +assert startedLines.size() == 1: 'Expected messages about GlassFish started at INFO level' + +true + diff --git a/src/it/start-with-gf-version/pom.xml b/src/it/start-with-gf-version/pom.xml index 0a21cb8..96ad638 100644 --- a/src/it/start-with-gf-version/pom.xml +++ b/src/it/start-with-gf-version/pom.xml @@ -39,7 +39,7 @@ 8081 - @tested.glassfish.version@ + @tested.glassfish.version@ diff --git a/src/main/java/org/glassfish/maven/AbstractServerMojo.java b/src/main/java/org/glassfish/maven/AbstractServerMojo.java index fda2f1d..5646523 100644 --- a/src/main/java/org/glassfish/maven/AbstractServerMojo.java +++ b/src/main/java/org/glassfish/maven/AbstractServerMojo.java @@ -231,12 +231,13 @@ public abstract class AbstractServerMojo extends AbstractMojo { * @deprecated This is a deprecated and unused configuration. Likely to be removed in the next version of the plugin. */ @Parameter(property = "containerType", defaultValue = "all") + @Deprecated protected String containerType; /** * Version of Embedded GlassFish to download if Embedded GlassFish dependency is not provided */ - @Parameter + @Parameter(property = "glassfish.version", alias = "glassfish.version") protected String glassfishVersion; /*===============================================