Merge pull request #2 from asbachb/master

Created a maven-archetype which is able to generate a web application…
diff --git a/netbeans-jakartaee-war-archetype/README.MD b/netbeans-jakartaee-war-archetype/README.MD
new file mode 100644
index 0000000..3e6d8a3
--- /dev/null
+++ b/netbeans-jakartaee-war-archetype/README.MD
@@ -0,0 +1,61 @@
+# Parameters
+
+The archetype can be configured via several system properties:
+
+| Property Name      | Default Value | Allowed Values                                 |
+| ------------------ | ------------- | ---------------------------------------------- |
+| `javaVersion`      | `17`          | `1.8`, `11`, `17`                              |
+| `jakartaEEVersion` | `10.0.0`      | `8.0.0`, `9.0.0`, `9.0.1`, `10.0.0`            |
+| `jakartaEEVariant` | `jakartaee`   | `jakartaee`, `jakartaee-web`, `jakartaee-core` |
+
+# Example Output
+
+`pom.xml`
+```xml
+<?xml version="1.0" encoding="UTF-8"?>
+<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.groupid</groupId>
+    <artifactId>jakartaee-project</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <packaging>war</packaging>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.compiler.source>17</maven.compiler.source>
+        <maven.compiler.target>17</maven.compiler.target>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>jakarta.platform</groupId>
+            <artifactId>jakarta.jakartaee-core-api</artifactId>
+            <version>10.0.0</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>3.1.0</version>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+                <version>3.3.2</version>
+            </plugin>
+        </plugins>
+    </build>
+</project>
+```
+
+# Notes
+
+* `maven-surefire-plugin` is set in order to be prepared for Junit 5 usage
+* `maven-war-plugin` is set as previous versions are not able to compile with Java 17
\ No newline at end of file
diff --git a/netbeans-jakartaee-war-archetype/pom.xml b/netbeans-jakartaee-war-archetype/pom.xml
new file mode 100644
index 0000000..dc43d98
--- /dev/null
+++ b/netbeans-jakartaee-war-archetype/pom.xml
@@ -0,0 +1,36 @@
+<?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
+
+  https://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.netbeans.archetypes</groupId>
+    <artifactId>netbeans-jakartaee-war-archetype</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <packaging>maven-archetype</packaging>
+
+    <name>Apache NetBeans Maven Archetypes: Jakarte EE Web Application Archetype</name>
+
+    <parent>
+        <groupId>org.apache.netbeans.archetypes</groupId>
+        <artifactId>netbeans-archetype-parent</artifactId>
+        <version>1.0.0-SNAPSHOT</version>
+    </parent>
+</project>
diff --git a/netbeans-jakartaee-war-archetype/src/main/resources/META-INF/archetype-post-generate.groovy b/netbeans-jakartaee-war-archetype/src/main/resources/META-INF/archetype-post-generate.groovy
new file mode 100644
index 0000000..6ccef50
--- /dev/null
+++ b/netbeans-jakartaee-war-archetype/src/main/resources/META-INF/archetype-post-generate.groovy
@@ -0,0 +1,21 @@
+projectDir = new File(new File(request.outputDirectory), request.artifactId)
+
+jakartaEEVariant = request.getProperties().get("jakartaEEVariant")
+if ("jakartaee-core".equals(jakartaEEVariant)) {
+    persistenceXml = new File(projectDir.toString(), "src/main/resources/META-INF/persistence.xml")
+
+    persistenceXml.delete()
+}
+
+javaVersionStr = request.getProperties().get("javaVersion")
+double javaVersion = javaVersionStr as double
+def mavenCompilerOption
+if (javaVersion >= 9) {
+    mavenCompilerOption = "\t<maven.compiler.release>${javaVersionStr}</maven.compiler.release>"
+} else {
+    mavenCompilerOption = "\t<maven.compiler.source>${javaVersionStr}</maven.compiler.source>" + System.getProperty("line.separator") + 
+                          "\t<maven.compiler.target>${javaVersionStr}</maven.compiler.target>"
+}
+
+pomXml = new File(projectDir.toString(), "pom.xml")
+pomXml.text = pomXml.text.replace("#mavenCompilerOption", mavenCompilerOption)
diff --git a/netbeans-jakartaee-war-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/netbeans-jakartaee-war-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000..5db397e
--- /dev/null
+++ b/netbeans-jakartaee-war-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,56 @@
+<?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
+
+  https://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<archetype-descriptor
+    xmlns="https://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.1.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="https://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.1.0 https://maven.apache.org/xsd/archetype-descriptor-1.1.0.xsd"
+    name="jakartaee-archetype">
+
+    <requiredProperties>
+        <requiredProperty key="javaVersion" >
+            <defaultValue>17</defaultValue>
+        </requiredProperty>
+        <requiredProperty key="jakartaEEVariant" >
+            <defaultValue>jakartaee</defaultValue>
+            <validationRegex>jakartaee|jakartaee-web|jakartaee-core</validationRegex>
+        </requiredProperty>
+        <requiredProperty key="jakartaEEVersion" >
+            <defaultValue>10.0.0</defaultValue>
+        </requiredProperty>
+    </requiredProperties>
+
+    <fileSets>
+        <fileSet>
+            <directory>src/main/java</directory>
+        </fileSet>
+        <fileSet filtered="true">
+            <directory>src/main/resources</directory>
+        </fileSet>
+        <fileSet filtered="true">
+            <directory>src/main/webapp</directory>
+        </fileSet>
+        <fileSet>
+            <directory>src/test/java</directory>
+        </fileSet>
+        <fileSet>
+            <directory>src/test/resources</directory>
+        </fileSet>
+    </fileSets>
+</archetype-descriptor>
diff --git a/netbeans-jakartaee-war-archetype/src/main/resources/archetype-resources/pom.xml b/netbeans-jakartaee-war-archetype/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000..92533d1
--- /dev/null
+++ b/netbeans-jakartaee-war-archetype/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>${groupId}</groupId>
+    <artifactId>${artifactId}</artifactId>
+    <version>${version}</version>
+    <packaging>war</packaging>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+#mavenCompilerOption
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>jakarta.platform</groupId>
+            <artifactId>jakarta.${jakartaEEVariant}-api</artifactId>
+            <version>${jakartaEEVersion}</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>3.1.0</version>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+                <version>3.3.2</version>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/netbeans-jakartaee-war-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/persistence.xml b/netbeans-jakartaee-war-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..c61853f
--- /dev/null
+++ b/netbeans-jakartaee-war-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+#if( $jakartaEEVersion == '8.0.0')
+    #set( $xmlns = 'https://xmlns.jcp.org/xml/ns/persistence' )
+    #set( $xsiSchemaLocation = 'http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd' )
+    #set( $version = '2.2' )
+#else
+    #set( $xmlns = 'https://jakarta.ee/xml/ns/persistence' )
+    #if( $jakartaEEVersion == '9.0.0' || $jakartaEEVersion == '9.1.0' )
+        #set( $xsiSchemaLocation = 'https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd' )
+        #set( $version = '3.0' )
+    #else
+        #set( $xsiSchemaLocation = 'https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_1.xsd' )
+        #set( $version = '3.1' )
+    #end
+#end
+
+<persistence xmlns="$xmlns"
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+             xsi:schemaLocation="$xsiSchemaLocation"
+             version="$version">
+    <!-- Define Persistence Unit -->
+    <persistence-unit name="my_persistence_unit">
+    </persistence-unit>
+</persistence>
diff --git a/netbeans-jakartaee-war-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/beans.xml b/netbeans-jakartaee-war-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/beans.xml
new file mode 100644
index 0000000..c36f009
--- /dev/null
+++ b/netbeans-jakartaee-war-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+#if( $jakartaEEVersion == '8.0.0')
+    #set( $xmlns = 'https://xmlns.jcp.org/xml/ns/javaee' )
+    #set( $xsiSchemaLocation = 'https://xmlns.jcp.org/xml/ns/javaee https://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd' )
+    #set( $version = '2.0' )
+#else
+    #set( $xmlns = 'https://jakarta.ee/xml/ns/jakartaee' )
+    #if( $jakartaEEVersion == '9.0.0' || $jakartaEEVersion == '9.1.0' )
+        #set( $xsiSchemaLocation = 'https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_3_0.xsd' )
+        #set( $version = '3.0' )
+    #else
+        #set( $xsiSchemaLocation = 'https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd' )
+        #set( $version = '4.0' )
+    #end
+#end
+
+<beans xmlns="$xmlns"
+       xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="$xsiSchemaLocation"
+       bean-discovery-mode="all"
+       version="$version">
+</beans>
diff --git a/netbeans-jakartaee-war-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/netbeans-jakartaee-war-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..90f28ff
--- /dev/null
+++ b/netbeans-jakartaee-war-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+#if( $jakartaEEVersion == '8.0.0')
+    #set( $xmlns = 'https://xmlns.jcp.org/xml/ns/javaee' )
+    #set( $xsiSchemaLocation = 'https://xmlns.jcp.org/xml/ns/javaee https://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd' )
+    #set( $version = '4.0' )
+#else
+    #set( $xmlns = 'https://jakarta.ee/xml/ns/jakartaee' )
+    #if( $jakartaEEVersion == '9.0.0' || $jakartaEEVersion == '9.1.0' )
+        #set( $xsiSchemaLocation = 'https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd' )
+        #set( $version = '5.0' )
+    #else
+        #set( $xsiSchemaLocation = 'https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd' )
+        #set( $version = '6.0' )
+    #end
+#end
+
+<web-app xmlns="$xmlns"
+    xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="$xsiSchemaLocation"
+    version="$version">
+</web-app>
diff --git a/netbeans-jakartaee-war-archetype/src/main/resources/archetype-resources/src/main/webapp/index.html b/netbeans-jakartaee-war-archetype/src/main/resources/archetype-resources/src/main/webapp/index.html
new file mode 100644
index 0000000..3368e9c
--- /dev/null
+++ b/netbeans-jakartaee-war-archetype/src/main/resources/archetype-resources/src/main/webapp/index.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Start Page</title>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    </head>
+    <body>
+        <h1>Hello World!</h1>
+    </body>
+</html>
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..cec4819
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,67 @@
+<?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
+
+  https://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.netbeans.archetypes</groupId>
+    <artifactId>netbeans-archetype-parent</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+
+    <name>Apache NetBeans Maven Archetypes</name>
+    <description>Parent project to build and configure archetype used by Apache NetBeans IDE.</description>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <issueManagement>
+        <system>GitHub Issues</system>
+        <url>https://github.com/apache/netbeans/issues</url>
+    </issueManagement>
+    <scm>
+        <connection>scm:git:https://github.com/apache/netbeans-mavenutils-archetypes.git</connection>
+        <developerConnection>scm:git:https://github.com/apache/netbeans-mavenutils-archetypes.git</developerConnection>
+        <url>https://github.com/apache/netbeans-mavenutils-archetyp</url>
+    </scm>
+
+    <licenses>
+        <license>
+            <name>Apache License 2</name>
+            <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
+            <distribution>repo</distribution>
+        </license>
+    </licenses>
+
+    <modules>
+        <module>netbeans-jakartaee-war-archetype</module>
+    </modules>
+
+    <build>
+        <extensions>
+            <extension>
+                <groupId>org.apache.maven.archetype</groupId>
+                <artifactId>archetype-packaging</artifactId>
+                <version>3.2.1</version>
+            </extension>
+        </extensions>
+    </build>
+</project>