简体   繁体   中英

Maven War: Filename of deployment descriptor

So I've added the maven-war-plugin to my pom.xml and added:

<configuration>
    <webXml>WEB-INF/glassfish-web.xml</webXml>
</configuration>

Now when I package my app this descriptor gets renamed to web.xml which causes a failure when trying to deploy my application to my glassfish server, since the server thinks the web.xml is malformatted I guess. So how can I tell maven to leave the file name untouched?

<webXml> configuration isn't mandatory for maven-war-plugin . So, If you don't explicitly mention the webXml, It won't rename the file. You will get the expected behaviour if you remove this webXml entry from your pom.xml

Edit 1

I don't think there is an option to skip webXml file renaming. You can try copy-resources task in maven-resources plugin . You can configure a resource file/directory mappings from Project dir to War archive.

    <plugins>
        <-- other plugin configurations.... -->
        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
              <version>3.1.0</version>
                <executions>
                  <execution>
                    <id>copy-resources</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>
                        ${basedir}/target/app/WEB-INF
                        </outputDirectory>
                        <resources>
                          <resource>
                            <directory>WEB-INF</directory>
                            <includes>glassfish-web.xml</includes>
                        </resource>
                        <resource>
                            <directory>{another directory from where all files are copied}
                            </directory>
                        </resource>
                        <resource>
                           <directory>
                           {another directory from where, all but test.properties are copied}
                           </directory>
                           <excludes>test.properties</excludes>
                        </resource>
                    </resources>
                </configuration>
            </execution>
        </executions>
    </plugin>
  <plugins/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM