填充META-INF / context.xml

时间:2013-05-27 11:55:29

标签: deployment build webserver tomcat7 maven-3

我使用maven作为构建和依赖管理工具。我成功通过maven build复制META-INF文件夹中的context.xml。

我想要的是在context.xml文件的标记中动态填充docBase和path属性。

如果有任何办法,请告诉我。最可取的是将war的finalName放在docBase属性中。

我不确定它是否可行。在这方面的任何帮助将不胜感激。

这是我的POM文件:

<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>myproj</groupId>
<artifactId>myproj</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<dependencies>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
</dependencies>

<profiles>
    <profile>
        <id>default-profile</id>
        <activation>
            <activeByDefault>true</activeByDefault>
            <file>
                <exists>${java.home}/../lib/tools.jar</exists>
            </file>
        </activation>
        <properties>
            <toolsjar>${java.home}/../lib/tools.jar</toolsjar>
        </properties>
    </profile>
    <profile>
        <id>mac-profile</id>
        <activation>
            <activeByDefault>false</activeByDefault>
            <file>
                <exists>${java.home}/../Classes/classes.jar</exists>
            </file>
        </activation>
        <properties>
            <toolsjar>${java.home}/../Classes/classes.jar</toolsjar>
        </properties>
    </profile>
</profiles>
<build>
    <sourceDirectory>src</sourceDirectory>
    <defaultGoal>clean</defaultGoal>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <version>1.1</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>create</goal>
                    </goals>
                </execution>
            </executions>

            <configuration>
                <doCheck>true</doCheck>
                <doUpdate>true</doUpdate>

                <format>{0,number} ({1,date,MMM dd, yyyy HH:mm 'PDT'})</format>
                <items>
                    <item>buildNumber0</item>
                    <item>timestamp</item>
                </items>
                <shortRevisionLength>5</shortRevisionLength>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.0</version>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <classpathPrefix>lib/</classpathPrefix>
                    </manifest>
                </archive>

                <webResources>
                    <resource>
                        <!-- this is relative to the pom.xml directory -->
                        <directory>${project.basedir}/src/main/resources
                        </directory>

                    </resource>
                </webResources>

                <warName>mywar</warName>
            </configuration>
        </plugin>

    </plugins>

    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>

    <finalName>${project.artifactId}-${project.version}</finalName>
</build>

 </project>

由于

0 个答案:

没有答案