Skip to content

Commit

Permalink
Resolve variables in app location and fix app configuration validatio…
Browse files Browse the repository at this point in the history
…n logic
  • Loading branch information
cherylking committed Mar 30, 2023
1 parent b8803c3 commit ee79ac2
Show file tree
Hide file tree
Showing 16 changed files with 495 additions and 33 deletions.
28 changes: 28 additions & 0 deletions liberty-maven-plugin/src/it/alt-outputdir-it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
</dependencies>

<build>
<filters>
<filter>${project.basedir}/src/main/filters/test.properties</filter>
</filters>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -56,6 +59,31 @@
<packagingExcludes>pom.xml</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>default-cli</id>
<phase>none</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<!-- This location can persist across a server recreate, where the refresh can annoyingly wipe out your earlier copy -->
<outputDirectory>target/liberty/wlp/usr/shared/config</outputDirectory>
<resources>
<resource>
<directory>src/main/filtered-config</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# prove the variables in server.xml can be resolved correctly
invoker.goals.1 = clean liberty:create resources:copy-resources install
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.openliberty.tools.it</groupId>
<artifactId>tests</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>appsdirectory-apps-configured-variables-include-it</artifactId>
<packaging>war</packaging>

<dependencies>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_3.0_spec</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
<filters>
<filter>${project.basedir}/src/main/filters/test.properties</filter>
</filters>

<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
<configuration>
<supportedProjectTypes>
<supportedProjectType>war</supportedProjectType>
</supportedProjectTypes>
<instructions>
<Web-ContextPath>/test-wab</Web-ContextPath>
<Bundle-ClassPath>WEB-INF/classes</Bundle-ClassPath>
<Import-Package>
javax.servlet.jsp.el,
javax.servlet.jsp,
javax.servlet.jsp.tagext,
*
</Import-Package>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>@pom.version@</version>
<extensions>true</extensions>
<configuration>
<stripVersion>true</stripVersion>
<assemblyArtifact>
<groupId>${project.groupId}</groupId>
<artifactId>assembly-server</artifactId>
<version>${project.version}</version>
<type>zip</type>
</assemblyArtifact>
<serverName>test</serverName>
<looseApplication>false</looseApplication>
</configuration>
<executions>
<!-- execution>
<id>install-liberty</id>
<phase>package</phase>
<goals>
<goal>install-server</goal>
</goals>
</execution>
<execution>
<id>create-liberty-server</id>
<phase>package</phase>
<goals>
<goal>create</goal>
</goals>
</execution -->
<execution>
<id>install-artifact</id>
<phase>package</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<looseApplication>false</looseApplication>
<appsDirectory>apps</appsDirectory>
<stripVersion>true</stripVersion>
</configuration>
</execution>
<execution>
<id>start-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>clean-server</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
<!-- goal>clean</goal -->
</goals>
<configuration>
<cleanDropins>false</cleanDropins>
<cleanApps>false</cleanApps>
<cleanLogs>false</cleanLogs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>default-cli</id>
<phase>none</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<!-- This location can persist across a server recreate, where the refresh can annoyingly wipe out your earlier copy -->
<outputDirectory>target/liberty/usr/shared/config</outputDirectory>
<resources>
<resource>
<directory>src/main/filtered-config</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<forkMode>once</forkMode>
<forkedProcessTimeoutInSeconds>300</forkedProcessTimeoutInSeconds>
<argLine>-enableassertions</argLine>
<workingDirectory>${project.build.directory}</workingDirectory>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<phase>verify</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
metadata-complete="false"
version="2.5">

<servlet>
<display-name>TestServlet</display-name>
<servlet-name>TestServlet</servlet-name>
<servlet-class>net.wasdev.wlp.test.servlet.TestServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/TestServlet</url-pattern>
<url-pattern>/TestServlet/*</url-pattern>
</servlet-mapping>

</web-app>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<server description="environment">
<variable name="tidal.url" value="${tidal.url}"/>
<variable name="project.artifactId" value="${project.artifactId}"/>
</server>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tidal.url=http://test.ibm.com:9080
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package net.wasdev.wlp.test.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class TestServlet extends HttpServlet {

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
}

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("<html><head><title>Sample Wab Application Bundle</title></head></html>");
out.println("<body><h1>");
out.println("Web Application Bundle");
out.println("</h1></body></html>");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<server description="default server">
<featureManager>
<feature>jsp-2.3</feature>
</featureManager>

<include location="${shared.config.dir}/environment.xml"/>

<!-- webApplication location="${project.artifactId}.war"/ -->
<webApplication location="${server.config.dir}/apps/${project.artifactId}.war"/>
</server>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<jsp:useBean id="datetime" class="java.util.Date" />
<title>Hello IBM WebSphere Application Server Liberty</title>
</head>
<body>
<h2>Welcome to IBM Liberty</h2>
<p>Congratulations on running this very simple demo application on ${datetime}.</p>
</body>
</html>
Loading

0 comments on commit ee79ac2

Please sign in to comment.