Question

I am using maven Struts2 blank artifact to create my web application. Here is my pom.xml :-

<?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>
<groupId>com.website.my</groupId>
<artifactId>MyArtifact</artifactId>
<version>3</version>
<packaging>war</packaging>
<name>My Artifact</name>

<properties>
    <struts2.version>2.3.12</struts2.version>
</properties>

<dependencies>

    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-core</artifactId>
        <version>${struts2.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-config-browser-plugin</artifactId>
        <version>${struts2.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-junit-plugin</artifactId>
        <version>${struts2.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.5</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.4</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.0</version>
        <scope>provided</scope>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>8.1.7.v20120910</version>
            <configuration>
                 <war>C:\Users\pranay\Documents\GitHub\MyArtifact\target\myWeb.war</war>                    
                <stopKey>CTRL+C</stopKey>
                <stopPort>8999</stopPort>
                <systemProperties>
                    <systemProperty>
                        <name>log4j.configuration</name>
                        <value>/Users/lukaszlenart/Projects/Apache/STRUTS_2_3_12/target/checkout/archetypes/struts2-archetype-blank/src/main/resources/log4j.properties</value>
                    </systemProperty>
                    <systemProperty>
                        <name>slf4j</name>
                        <value>false</value>
                    </systemProperty>
                </systemProperties>
                <scanIntervalSeconds>10</scanIntervalSeconds>
                <webAppSourceDirectory>/Users/lukaszlenart/Projects/Apache/STRUTS_2_3_12/target/checkout/archetypes/struts2-archetype-blank/src/main/webapp/</webAppSourceDirectory>
               <webApp>
                    <contextPath>/MyArtifact</contextPath>
                    <descriptor>C:\Users\Pranay\Documents\GitHub\MyArtifact\src\main\webapp\WEB-INF</descriptor>
                </webApp>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                    <version>1.2.17</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

above pom.xml uses jetty server for creating war file.So when I run mvn jetty:war-run then it creates war file with name MyArtifact-3.war(artifactId-version), but I want my war file name to be myWeb.war. I used war tag in configuration of pom.xml to specify the war name I want(according to this link http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html#running-assembled-webapp-as-war). But, it is not working. Please let me know how can I change generated war file name.

Était-ce utile?

La solution

Simple enough, just override the <finalName> value.

<project>
  <build>
    <finalName>${project.artifactId}</finalName>
  </build>
</project>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top