Maven maven-war-plugin not replacing values in web.xml
up vote
0
down vote
favorite
Maven version: 3.5.4
My web directory is not in the standard location. It is in /web
Maven War config
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<webResources>
<!--
Filter these files to look for ${my.maven.property} to replace them
at build time with a maven property value
-->
<resource>
<filtering>true</filtering>
<directory>web/WEB-INF</directory>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
</webResources>
<warSourceDirectory>web</warSourceDirectory>
<failOnMissingWebXml>true</failOnMissingWebXml>
<webXml>web/WEB-INF/web.xml</webXml>
<packagingExcludes>
${exclude.files.on.build}
</packagingExcludes>
</configuration>
</plugin>
properties snippet from pom.xml
<properties>
...
<!-- web.xml vars -->
<web.session.cookie.secure>true</web.session.cookie.secure> <!-- session cookie only sent over https -->
...
</properties>
web.xml snippet
<cookie-config>
...
<secure>${web.session.cookie.secure}</secure>
...
</cookie-config>
The property "${web.session.cookie.secure}" is not being replaced in the web.xml, and the property name is retained in the war file generated. I have not been able to pinpoint the configuration error. I am working in Intellij and get the same result whether I build the artifact off the intellij menu, or issue the mvn war:exploded command.
I am assuming that it may have something to do with the web directory location and a missing configuration item. The maven build runs as expected other than the issue with the properties not being replaced in the output.
Any ideas as to why the replacements would not be taking place using the filtering of the maven-war-plugin?
java maven intellij-idea
add a comment |
up vote
0
down vote
favorite
Maven version: 3.5.4
My web directory is not in the standard location. It is in /web
Maven War config
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<webResources>
<!--
Filter these files to look for ${my.maven.property} to replace them
at build time with a maven property value
-->
<resource>
<filtering>true</filtering>
<directory>web/WEB-INF</directory>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
</webResources>
<warSourceDirectory>web</warSourceDirectory>
<failOnMissingWebXml>true</failOnMissingWebXml>
<webXml>web/WEB-INF/web.xml</webXml>
<packagingExcludes>
${exclude.files.on.build}
</packagingExcludes>
</configuration>
</plugin>
properties snippet from pom.xml
<properties>
...
<!-- web.xml vars -->
<web.session.cookie.secure>true</web.session.cookie.secure> <!-- session cookie only sent over https -->
...
</properties>
web.xml snippet
<cookie-config>
...
<secure>${web.session.cookie.secure}</secure>
...
</cookie-config>
The property "${web.session.cookie.secure}" is not being replaced in the web.xml, and the property name is retained in the war file generated. I have not been able to pinpoint the configuration error. I am working in Intellij and get the same result whether I build the artifact off the intellij menu, or issue the mvn war:exploded command.
I am assuming that it may have something to do with the web directory location and a missing configuration item. The maven build runs as expected other than the issue with the properties not being replaced in the output.
Any ideas as to why the replacements would not be taking place using the filtering of the maven-war-plugin?
java maven intellij-idea
1
Have you checked your target directory path? Try <directory>${basedir}/web/WEB-INF</directory> and also look in the effective-pom how the path is being interpreted.
– briadeus
Nov 19 at 20:49
@briadeus wow, unbelievable, spent 4+ hours on that today! That has resolved the issue. Please post as the answer and I will accept it. Thank you
– Paul Zepernick
Nov 20 at 0:08
Well, this did work in my local env, but it is not working on the jenkins build which is on a Linux box. Separate issue.... ugg
– Paul Zepernick
Nov 20 at 1:05
Glad it helped. I added the answer for reference. It behaves the same on Linux, so the problem is probably something else. Try checking the effective-pom or running "mvn clean install -X" for debug.
– briadeus
Nov 20 at 8:16
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Maven version: 3.5.4
My web directory is not in the standard location. It is in /web
Maven War config
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<webResources>
<!--
Filter these files to look for ${my.maven.property} to replace them
at build time with a maven property value
-->
<resource>
<filtering>true</filtering>
<directory>web/WEB-INF</directory>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
</webResources>
<warSourceDirectory>web</warSourceDirectory>
<failOnMissingWebXml>true</failOnMissingWebXml>
<webXml>web/WEB-INF/web.xml</webXml>
<packagingExcludes>
${exclude.files.on.build}
</packagingExcludes>
</configuration>
</plugin>
properties snippet from pom.xml
<properties>
...
<!-- web.xml vars -->
<web.session.cookie.secure>true</web.session.cookie.secure> <!-- session cookie only sent over https -->
...
</properties>
web.xml snippet
<cookie-config>
...
<secure>${web.session.cookie.secure}</secure>
...
</cookie-config>
The property "${web.session.cookie.secure}" is not being replaced in the web.xml, and the property name is retained in the war file generated. I have not been able to pinpoint the configuration error. I am working in Intellij and get the same result whether I build the artifact off the intellij menu, or issue the mvn war:exploded command.
I am assuming that it may have something to do with the web directory location and a missing configuration item. The maven build runs as expected other than the issue with the properties not being replaced in the output.
Any ideas as to why the replacements would not be taking place using the filtering of the maven-war-plugin?
java maven intellij-idea
Maven version: 3.5.4
My web directory is not in the standard location. It is in /web
Maven War config
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<webResources>
<!--
Filter these files to look for ${my.maven.property} to replace them
at build time with a maven property value
-->
<resource>
<filtering>true</filtering>
<directory>web/WEB-INF</directory>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
</webResources>
<warSourceDirectory>web</warSourceDirectory>
<failOnMissingWebXml>true</failOnMissingWebXml>
<webXml>web/WEB-INF/web.xml</webXml>
<packagingExcludes>
${exclude.files.on.build}
</packagingExcludes>
</configuration>
</plugin>
properties snippet from pom.xml
<properties>
...
<!-- web.xml vars -->
<web.session.cookie.secure>true</web.session.cookie.secure> <!-- session cookie only sent over https -->
...
</properties>
web.xml snippet
<cookie-config>
...
<secure>${web.session.cookie.secure}</secure>
...
</cookie-config>
The property "${web.session.cookie.secure}" is not being replaced in the web.xml, and the property name is retained in the war file generated. I have not been able to pinpoint the configuration error. I am working in Intellij and get the same result whether I build the artifact off the intellij menu, or issue the mvn war:exploded command.
I am assuming that it may have something to do with the web directory location and a missing configuration item. The maven build runs as expected other than the issue with the properties not being replaced in the output.
Any ideas as to why the replacements would not be taking place using the filtering of the maven-war-plugin?
java maven intellij-idea
java maven intellij-idea
asked Nov 19 at 19:13
Paul Zepernick
1,071717
1,071717
1
Have you checked your target directory path? Try <directory>${basedir}/web/WEB-INF</directory> and also look in the effective-pom how the path is being interpreted.
– briadeus
Nov 19 at 20:49
@briadeus wow, unbelievable, spent 4+ hours on that today! That has resolved the issue. Please post as the answer and I will accept it. Thank you
– Paul Zepernick
Nov 20 at 0:08
Well, this did work in my local env, but it is not working on the jenkins build which is on a Linux box. Separate issue.... ugg
– Paul Zepernick
Nov 20 at 1:05
Glad it helped. I added the answer for reference. It behaves the same on Linux, so the problem is probably something else. Try checking the effective-pom or running "mvn clean install -X" for debug.
– briadeus
Nov 20 at 8:16
add a comment |
1
Have you checked your target directory path? Try <directory>${basedir}/web/WEB-INF</directory> and also look in the effective-pom how the path is being interpreted.
– briadeus
Nov 19 at 20:49
@briadeus wow, unbelievable, spent 4+ hours on that today! That has resolved the issue. Please post as the answer and I will accept it. Thank you
– Paul Zepernick
Nov 20 at 0:08
Well, this did work in my local env, but it is not working on the jenkins build which is on a Linux box. Separate issue.... ugg
– Paul Zepernick
Nov 20 at 1:05
Glad it helped. I added the answer for reference. It behaves the same on Linux, so the problem is probably something else. Try checking the effective-pom or running "mvn clean install -X" for debug.
– briadeus
Nov 20 at 8:16
1
1
Have you checked your target directory path? Try <directory>${basedir}/web/WEB-INF</directory> and also look in the effective-pom how the path is being interpreted.
– briadeus
Nov 19 at 20:49
Have you checked your target directory path? Try <directory>${basedir}/web/WEB-INF</directory> and also look in the effective-pom how the path is being interpreted.
– briadeus
Nov 19 at 20:49
@briadeus wow, unbelievable, spent 4+ hours on that today! That has resolved the issue. Please post as the answer and I will accept it. Thank you
– Paul Zepernick
Nov 20 at 0:08
@briadeus wow, unbelievable, spent 4+ hours on that today! That has resolved the issue. Please post as the answer and I will accept it. Thank you
– Paul Zepernick
Nov 20 at 0:08
Well, this did work in my local env, but it is not working on the jenkins build which is on a Linux box. Separate issue.... ugg
– Paul Zepernick
Nov 20 at 1:05
Well, this did work in my local env, but it is not working on the jenkins build which is on a Linux box. Separate issue.... ugg
– Paul Zepernick
Nov 20 at 1:05
Glad it helped. I added the answer for reference. It behaves the same on Linux, so the problem is probably something else. Try checking the effective-pom or running "mvn clean install -X" for debug.
– briadeus
Nov 20 at 8:16
Glad it helped. I added the answer for reference. It behaves the same on Linux, so the problem is probably something else. Try checking the effective-pom or running "mvn clean install -X" for debug.
– briadeus
Nov 20 at 8:16
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
The maven-war-plugin
uses ${basedir}
as the location of the pom, so the target directory for filtering should be referenced via relative path from there.
<resource>
<filtering>true</filtering>
<directory>${basedir}/web/WEB-INF</directory>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
The actuall path could be examined in mvn help:effective-pom
.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
The maven-war-plugin
uses ${basedir}
as the location of the pom, so the target directory for filtering should be referenced via relative path from there.
<resource>
<filtering>true</filtering>
<directory>${basedir}/web/WEB-INF</directory>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
The actuall path could be examined in mvn help:effective-pom
.
add a comment |
up vote
1
down vote
accepted
The maven-war-plugin
uses ${basedir}
as the location of the pom, so the target directory for filtering should be referenced via relative path from there.
<resource>
<filtering>true</filtering>
<directory>${basedir}/web/WEB-INF</directory>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
The actuall path could be examined in mvn help:effective-pom
.
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
The maven-war-plugin
uses ${basedir}
as the location of the pom, so the target directory for filtering should be referenced via relative path from there.
<resource>
<filtering>true</filtering>
<directory>${basedir}/web/WEB-INF</directory>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
The actuall path could be examined in mvn help:effective-pom
.
The maven-war-plugin
uses ${basedir}
as the location of the pom, so the target directory for filtering should be referenced via relative path from there.
<resource>
<filtering>true</filtering>
<directory>${basedir}/web/WEB-INF</directory>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
The actuall path could be examined in mvn help:effective-pom
.
answered Nov 20 at 8:13
briadeus
30928
30928
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53381173%2fmaven-maven-war-plugin-not-replacing-values-in-web-xml%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Have you checked your target directory path? Try <directory>${basedir}/web/WEB-INF</directory> and also look in the effective-pom how the path is being interpreted.
– briadeus
Nov 19 at 20:49
@briadeus wow, unbelievable, spent 4+ hours on that today! That has resolved the issue. Please post as the answer and I will accept it. Thank you
– Paul Zepernick
Nov 20 at 0:08
Well, this did work in my local env, but it is not working on the jenkins build which is on a Linux box. Separate issue.... ugg
– Paul Zepernick
Nov 20 at 1:05
Glad it helped. I added the answer for reference. It behaves the same on Linux, so the problem is probably something else. Try checking the effective-pom or running "mvn clean install -X" for debug.
– briadeus
Nov 20 at 8:16