Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WFLY-17651] Add a new "Getting Started" archetype. #47

Merged
merged 17 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
</properties>

<modules>
<module>wildfly-getting-started-archetype</module>
<module>wildfly-jakartaee-ear-archetype</module>
<module>wildfly-jakartaee-webapp-archetype</module>
<module>wildfly-subsystem-archetype</module>
Expand Down Expand Up @@ -109,4 +110,4 @@
</plugins>
</pluginManagement>
</build>
</project>
</project>
65 changes: 65 additions & 0 deletions wildfly-getting-started-archetype/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
WildFly getting started archetype
-----------------------------

[[introduction]]
==== Introduction

This archetype creates a new WAR project which contains a simple Restful web
service and a HTML page to call the web service.

The generated project is configured to dynamically provision a WildFly server
and run the web application on the provisoned server so no manual installation
is required.

It is prepared for running Arquillian unit tests.
More details can be found in the file "src/main/resources/archetype-resources/README.txt", which is end-user doc and added to the resulting project.

[[newwildflyversion]]
==== New WildFly version
To update this archetype to a new WildFly version:
In file "pom.xml":

* update the version
* update to latest "org.jboss:jboss-parent" version found at https://repo.maven.apache.org/maven2/org/jboss/jboss-parent/

In file "src/main/resources/archetype-resources/pom.xml":

* update the version property named "version.jboss.bom"
* check whether dependencies have changed.
* check the plugin versions and update if necessary:
** wildfly-maven-plugin: https://repo.maven.apache.org/maven2/org/wildfly/plugins/wildfly-maven-plugin/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use these links or the project thinks? Most maven plugins show he latest version on the top right of their site. Or in the case of the the wildfly-maven-plugin in it's on the left.

** maven-compiler-plugin: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/
** maven-surefire-plugin: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/
** maven-failsafe-plugin: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-failsafe-plugin/
** maven-war-plugin: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-war-plugin/

Also test whether the Arquillian unit test "SampleIT" still works, see below.

[[build]]
==== Build
To build the archetype, you need at least Java 11. Run this command:
[source,options="nowrap"]
----
$ mvn clean install
----
It will be installed to your local maven repository at "%USERHOME%/.m2/repository/org/wildfly/archetype/wildfly-getting-started-archetype/", and an entry will be added to "%USERHOME%/.m2/repository/archetype-catalog.xml".

[[createproject]]
==== Create project from archetype
To create a new project from this archetype, use this maven command (replace dummy values for "groupId", "artifactId" and "version" with correct values):
----
$ mvn archetype:generate -DgroupId=my.project.org -DartifactId=sampleproject -Dversion=1.0-SNAPSHOT -DarchetypeGroupId=org.wildfly.archetype -DarchetypeArtifactId=wildfly-getting-started-archetype -DarchetypeVersion=28.0.0.Final-SNAPSHOT
----

[[testing]]
==== Test the archetype
After having built the archetype, check whether both profiles "arq-remote" and "arq-managed" work. This is done by using scripts found in the directory "testing".

* Profile "arq-managed": set variable JBOSS_HOME, then execute "runtest_managed.bat/.sh <archetypeVersion>" (replace "<archetypeVersion>" with the current archetype version)
* Profile "arq-remote": start WildFly server, then execute "runtest_remote.bat/.sh <archetypeVersion>" (replace "<archetypeVersion>" with the current archetype version)

Both files create a project from the archetype (in "testing/arq-managed" or "testing/arq-remote"), copy an Arquillian unit test class and an EJB in this project, then build and deploy it to WildFly and execute
the test using the Arquillian profile "arq-managed" or "arq-remote").

After the test is executed, check the server log for error outputs. In case of success, the outputs "Test is invoked..." and "doTest is invoked..." will be printed in the server console.

86 changes: 86 additions & 0 deletions wildfly-getting-started-archetype/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- 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. -->
<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>

<parent>
<groupId>org.wildfly.archetype</groupId>
<artifactId>wildfly-archetypes</artifactId>
<version>30.0.0.Final-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>wildfly-getting-started-archetype</artifactId>
<packaging>maven-archetype</packaging>

<name>WildFly Archetypes: Getting Started</name>
<description>An archetype that generates a starter Jakarta EE project for the WildFly application server.</description>

<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<!--
The pom.xml that is generated by the archetype is filtered
so that we can inject the versions of the various dependencies and
plugins from the parent's pom.xml.

The properties that must not be filtered in that file (eg project.artifactId)
are prefixed with the escape string "\" so that they will be evaluated
when the project is generated by the archetype:generate goal
-->
<directory>src/main/resources-filtered</directory>
<filtering>true</filtering>
</resource>
</resources>

<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>

<extensions>
<extension>
<groupId>org.apache.maven.archetype</groupId>
<artifactId>archetype-packaging</artifactId>
</extension>
</extensions>

<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-archetype-plugin</artifactId>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<escapeString>\</escapeString>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
JBoss, Home of Professional Open Source
Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual
contributors by the @authors tag. See the copyright.txt in the
distribution for a full listing of individual contributors.

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.
-->
<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>\${groupId}</groupId>
<artifactId>\${artifactId}</artifactId>
<version>\${version}</version>

<packaging>war</packaging>
<name>\${artifactId}</name>
<description>Insert description for your project here.</description>

<properties>
<!-- Explicitly declaring the source encoding eliminates the following
message: -->
<!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
resources, i.e. build is platform dependent! -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- JBoss dependency versions -->
<version.wildfly.maven.plugin>${version.wildfly.maven.plugin}</version.wildfly.maven.plugin>
<version.wildfly.bom>${version.wildfly.bom}</version.wildfly.bom>

<!-- other plugin versions -->
<version.compiler.plugin>${version.compiler.plugin}</version.compiler.plugin>
<version.surefire.plugin>${version.surefire.plugin}</version.surefire.plugin>
<version.failsafe.plugin>${version.failsafe.plugin}</version.failsafe.plugin>
<version.war.plugin>${version.war.plugin}</version.war.plugin>

<!-- maven-compiler-plugin -->
<maven.compiler.release>${maven.compiler.release}</maven.compiler.release>
</properties>

<!-- the JBoss community and Red Hat GA Maven repositories -->
<repositories>
<repository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<updatePolicy>never</updatePolicy>
</snapshots>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
</releases>
<snapshots>
</snapshots>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>

<dependencyManagement>
<dependencies>
<!-- JBoss distributes a complete set of Jakarta EE APIs including
a Bill of Materials (BOM). A BOM specifies the versions of a "stack" (or
a collection) of artifacts. We use this here so that we always get the correct
versions of artifacts (you can read this as the WildFly stack of the Jakarta EE APIs,
with some extras tools for your project, such as Arquillian for testing) -->
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>wildfly-ee-with-tools</artifactId>
<version>\${version.wildfly.bom}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>

<!-- Import the CDI API, we use provided scope as the API is included in WildFly -->
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>provided</scope>
</dependency>

<!-- Import the JAX-RS API, we use provided scope as the API is included in WildFly -->
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<scope>provided</scope>
</dependency>

<!-- Test scope dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>6.2.4.Final</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<!-- deploys the quickstart on root web context -->
<finalName>ROOT</finalName>

<plugins>
<!--Configuration
of the maven-compiler-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>\${version.compiler.plugin}</version>
<configuration></configuration>
</plugin>

<!--Build
configuration for the WAR plugin: -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>\${version.war.plugin}</version>
<configuration>
<!-- Jakarta EE doesn't require web.xml, Maven needs to catch up! -->
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>

<!-- The WildFly plugin deploys your war to a local JBoss AS container -->
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>\${version.wildfly.maven.plugin}</version>
<configuration>
<feature-packs>
<feature-pack>
<location>org.wildfly:wildfly-galleon-pack:\${version.wildfly.bom}</location>
</feature-pack>
</feature-packs>
<layers>
<!-- layers may be used to customize the server to provision-->
<layer>cloud-server</layer>
</layers>
</configuration>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>\${version.failsafe.plugin}</version>
<configuration>
<includes>
<include>**/*IT</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading