Skip to content
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
40 changes: 20 additions & 20 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</parent>

<artifactId>maven-war-plugin</artifactId>
<version>3.3.3-SNAPSHOT</version>
<version>3.4.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>Apache Maven WAR Plugin</name>
Expand Down Expand Up @@ -62,9 +62,9 @@
</distributionManagement>

<properties>
<mavenArchiverVersion>3.5.0</mavenArchiverVersion>
<mavenFilteringVersion>3.1.1</mavenFilteringVersion>
<mavenVersion>3.1.0</mavenVersion>
<mavenArchiverVersion>3.5.1</mavenArchiverVersion>
<mavenFilteringVersion>3.2.0</mavenFilteringVersion>
<mavenVersion>3.2.5</mavenVersion>
<javaVersion>7</javaVersion>
<project.build.outputTimestamp>2021-09-05T09:31:59Z</project.build.outputTimestamp>
</properties>
Expand All @@ -89,16 +89,25 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand All @@ -110,15 +119,10 @@
<artifactId>maven-plugin-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>${mavenVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
<version>3.2.1</version>
<version>3.3.4</version>
</dependency>

<dependency>
Expand All @@ -129,7 +133,7 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>4.2.2</version>
<version>4.2.5</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand All @@ -151,18 +155,14 @@
<artifactId>maven-mapping</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<version>0.9.0.M2</version>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
<version>0.0.0.M2a</version>
<version>0.3.5</version>
<scope>provided</scope>
</dependency>

<dependency>
<dependency> <!-- looks up RepositorySystem -->
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>${mavenVersion}</version>
Expand All @@ -171,13 +171,13 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
55 changes: 55 additions & 0 deletions src/it/MWAR-450/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?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>
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.its.war</groupId>
<artifactId>mwar450</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<finalName>mwar450</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<!-- Without this configuration the test fails -->
<propertiesEncoding>ISO-8859-1</propertiesEncoding>
<webResources>
<resource>
<targetPath>WEB-INF/classes</targetPath>
<filtering>true</filtering>
<directory>src/main/webapp/WEB-INF/classes</directory>
Copy link
Member

Choose a reason for hiding this comment

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

Aren't they in src/main/resources?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No they don't in our use case. We like to separate our config files from our resources. This way the config files end up readable in the exploded war, instead of being packaged in the jar file of the project.

</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</project>
30 changes: 30 additions & 0 deletions src/it/MWAR-450/src/main/webapp/WEB-INF/classes/log4j.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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.
-->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<!-- This file is encoded in UTF-8 and should remain so after filtering - åäö -->
</appender>
<root>
<priority value="info"/>
<appender-ref ref="console"/>
</root>
</log4j:configuration>
18 changes: 18 additions & 0 deletions src/it/MWAR-450/src/main/webapp/WEB-INF/classes/my.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.

my.property=Characters that should be encoded in ISO-8859-1: ���
18 changes: 18 additions & 0 deletions src/it/MWAR-450/src/main/webapp/WEB-INF/classes/myfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.

Characters that should be encoded in UTF-8: åäö
26 changes: 26 additions & 0 deletions src/it/MWAR-450/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -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.
-->
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
23 changes: 23 additions & 0 deletions src/it/MWAR-450/src/main/webapp/index.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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.
*/
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
94 changes: 94 additions & 0 deletions src/it/MWAR-450/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@

/*
* 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.
*/

import java.io.*;

import org.codehaus.plexus.util.*;

boolean result = true;

try
{
File target = new File( basedir, "target/mwar450/WEB-INF/classes" );
if ( !target.exists() || !target.isDirectory() )
{
System.err.println( "target/mwar450/WEB-INF/classes is missing or is not a directory." );
return false;
}

// Load and check log4j.xml
File log4jxml = new File( target, "log4j.xml" );
if ( !log4jxml.exists() || log4jxml.isDirectory() )
{
System.err.println( "log4j.xml is missing or is a directory." );
return false;
}
FileInputStream fis = new FileInputStream ( log4jxml );
String paramContent = IOUtil.toString ( fis, "UTF-8" );
System.out.println( "content='" + paramContent + "'" );
Copy link
Member

Choose a reason for hiding this comment

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

This output will be mangled if run on non-UTF-8.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have tried this on both Windows (CP-1252) and Linux (UTF-8), and the output from the integration test looks fine for us, without mangled characters. Which platform did you have problems on?

int indexOf = paramContent.indexOf( "This file is encoded in UTF-8 and should remain so after filtering - åäö" );
if ( indexOf < 0 )
{
System.err.println( "Non-ascii characters changed encoding during filtering" );
return false;
}

// Load and check my.properties
File myProperties = new File( target, "my.properties" );
if ( !myProperties.exists() || myProperties.isDirectory() )
{
System.err.println( "my.properties is missing or is a directory." );
return false;
}
Properties properties = new Properties();
Copy link
Member

Choose a reason for hiding this comment

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

In jdk9 encoding of properties was changed.
https://docs.oracle.com/javase/9/intl/internationalization-enhancements-jdk-9.htm

Maybe good assertions will be length of file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is true that changes were made in Java 9. From what I understand the changes were made with regards to internationalization in PropertyResourceBundle, but not to regular Properties. https://docs.oracle.com/javase/9/docs/api/java/util/Properties.html

The assertions that are in place should work fine regardless of Java version since we specify the encoding to use when reading the files, in the plugin's code. The only exception som that rule is when reading the properties file in the verify.bsh file in the integration test.

FileInputStream fis = new FileInputStream( myProperties );
properties.load( fis );
fis.close();
String property = properties.get( "my.property" );
System.out.println( "my.property='" + property + "'" );
Copy link
Member

Choose a reason for hiding this comment

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

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above

if ( !"Characters that should be encoded in ISO-8859-1: åäö".equals( property ) )
{
System.err.println( "Non-ascii characters has wrong encoding after filtering" );
return false;
}

File myfile = new File( target, "myfile.txt" );
if ( !myfile.exists() || myfile.isDirectory() )
{
System.err.println( "myfile.txt is missing or is a directory." );
return false;
}
FileInputStream fis = new FileInputStream ( myfile );
String paramContent = IOUtil.toString ( fis, "UTF-8" );
System.out.println( "content='" + paramContent + "'" );
Copy link
Member

Choose a reason for hiding this comment

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

And here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above

int indexOf = paramContent.indexOf( "Characters that should be encoded in UTF-8: åäö" );
if ( indexOf < 0 )
{
System.err.println( "Non-ascii characters changed encoding during filtering" );
return false;
}
}
catch( IOException e )
{
e.printStackTrace();
result = false;
}

return result;
Loading