Maven maven-war-plugin not replacing values in web.xml












0














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?










share|improve this question


















  • 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 '18 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 '18 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 '18 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 '18 at 8:16
















0














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?










share|improve this question


















  • 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 '18 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 '18 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 '18 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 '18 at 8:16














0












0








0







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?










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 19 '18 at 19:13









Paul ZepernickPaul Zepernick

1,081717




1,081717








  • 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 '18 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 '18 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 '18 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 '18 at 8:16














  • 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 at 8:16












1 Answer
1






active

oldest

votes


















1














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.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    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

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    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.






    share|improve this answer


























      1














      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.






      share|improve this answer
























        1












        1








        1






        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.






        share|improve this answer












        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 20 '18 at 8:13









        briadeusbriadeus

        43448




        43448






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            SQL update select statement

            'app-layout' is not a known element: how to share Component with different Modules