This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-ear-plugin.git
The following commit(s) were added to refs/heads/master by this push: new 55abbb3 [MEAR-329] Support JakartaEE 11 schema 55abbb3 is described below commit 55abbb3211db81496287f31b1aaf6cecb0e43297 Author: Piotrek Żygieło <pzygi...@users.noreply.github.com> AuthorDate: Thu Oct 3 19:42:47 2024 +0200 [MEAR-329] Support JakartaEE 11 schema --- .../maven/plugins/ear/ApplicationXmlWriter.java | 14 +++++++ .../maven/plugins/ear/util/JavaEEVersion.java | 10 ++++- .../org/apache/maven/plugins/ear/it/EarMojoIT.java | 7 ++++ .../project-102/expected-META-INF/application.xml | 26 ++++++++++++ src/test/resources/projects/project-102/pom.xml | 49 ++++++++++++++++++++++ 5 files changed, 105 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/maven/plugins/ear/ApplicationXmlWriter.java b/src/main/java/org/apache/maven/plugins/ear/ApplicationXmlWriter.java index 1d36845..58b64b7 100644 --- a/src/main/java/org/apache/maven/plugins/ear/ApplicationXmlWriter.java +++ b/src/main/java/org/apache/maven/plugins/ear/ApplicationXmlWriter.java @@ -67,6 +67,8 @@ final class ApplicationXmlWriter extends AbstractXmlWriter { writer = initializeRootElementNine(w); } else if (JavaEEVersion.TEN.eq(version)) { writer = initializeRootElementTen(w); + } else if (JavaEEVersion.ELEVEN.eq(version)) { + writer = initializeRootElementEleven(w); } // writer is still on root element, so we can still add this attribute @@ -254,4 +256,16 @@ final class ApplicationXmlWriter extends AbstractXmlWriter { writer.addAttribute("version", "10"); return writer; } + + private XMLWriter initializeRootElementEleven(Writer w) { + XMLWriter writer = initializeXmlWriter(w, null); + writer.startElement(APPLICATION_ELEMENT); + writer.addAttribute("xmlns", "https://jakarta.ee/xml/ns/jakartaee"); + writer.addAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); + writer.addAttribute( + "xsi:schemaLocation", + "https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/application_11.xsd"); + writer.addAttribute("version", "11"); + return writer; + } } diff --git a/src/main/java/org/apache/maven/plugins/ear/util/JavaEEVersion.java b/src/main/java/org/apache/maven/plugins/ear/util/JavaEEVersion.java index f50b0bf..45a0dc6 100644 --- a/src/main/java/org/apache/maven/plugins/ear/util/JavaEEVersion.java +++ b/src/main/java/org/apache/maven/plugins/ear/util/JavaEEVersion.java @@ -44,6 +44,8 @@ public class JavaEEVersion implements Comparable<JavaEEVersion> { private static final String VERSION_10 = "10"; + private static final String VERSION_11 = "11"; + private static final Map<String, JavaEEVersion> VERSION_MAP = new HashMap<>(); /** @@ -86,6 +88,11 @@ public class JavaEEVersion implements Comparable<JavaEEVersion> { */ public static final JavaEEVersion TEN = new JavaEEVersion(Integer.valueOf(7), VERSION_10); + /** + * Represents the JakartaEE 11 version. + */ + public static final JavaEEVersion ELEVEN = new JavaEEVersion(Integer.valueOf(8), VERSION_11); + private final Integer index; private final String version; @@ -185,7 +192,8 @@ public class JavaEEVersion implements Comparable<JavaEEVersion> { || VERSION_7.equals(paramVersion) || VERSION_8.equals(paramVersion) || VERSION_9.equals(paramVersion) - || VERSION_10.equals(paramVersion); + || VERSION_10.equals(paramVersion) + || VERSION_11.equals(paramVersion); // @formatter:on } diff --git a/src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java b/src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java index 9499124..dd65d04 100644 --- a/src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java +++ b/src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java @@ -1325,4 +1325,11 @@ public class EarMojoIT extends AbstractEarPluginIT { doTestProject("project-101", expectedArtifacts, true); doTestProject("project-101", expectedArtifacts, false); } + + /** + * Builds an EAR with deployment descriptor configuration for JakartaEE 11. + */ + public void testProject102() throws Exception { + doTestProject("project-102", new String[] {"eartest-ejb-sample-one-1.0.jar"}); + } } diff --git a/src/test/resources/projects/project-102/expected-META-INF/application.xml b/src/test/resources/projects/project-102/expected-META-INF/application.xml new file mode 100644 index 0000000..5384950 --- /dev/null +++ b/src/test/resources/projects/project-102/expected-META-INF/application.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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. +--> +<application xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/application_11.xsd" version="11"> + <display-name>maven-ear-plugin-test-project-102</display-name> + <module> + <ejb>eartest-ejb-sample-one-1.0.jar</ejb> + </module> +</application> + diff --git a/src/test/resources/projects/project-102/pom.xml b/src/test/resources/projects/project-102/pom.xml new file mode 100644 index 0000000..9b8ceef --- /dev/null +++ b/src/test/resources/projects/project-102/pom.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>ear</groupId> + <artifactId>maven-ear-plugin-test-project-102</artifactId> + <version>99.0</version> + <name>Maven</name> + <packaging>ear</packaging> + <dependencies> + <dependency> + <groupId>eartest</groupId> + <artifactId>ejb-sample-one</artifactId> + <version>1.0</version> + <type>ejb</type> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-ear-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <version>11</version> + </configuration> + </plugin> + </plugins> + </build> +</project>