如何更改从mvn eclipse创建的.project中的项目名称:eclipse?

时间:2015-10-29 09:30:56

标签: maven maven-2 maven-plugin maven-eclipse-plugin

以下是我的pom.xml的内容

<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/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <url>http://maven.apache.org</url>

    <name>SomeProject</name>

    <groupId>com.test.te</groupId>
    <artifactId>testjar</artifactId>
    <version>1.1.6</version>
    <packaging>jar</packaging>

    <dependencies>
    ....
    ....
    </dependencies>
    <build>        
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

我正在通过执行以下命令创建eclipse的.project文件。

mvn eclipse:clean
mvn eclipse:eclipse

以下是我的.project文件的内容

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>testjar</name>
    <comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>

它正在创建项目名称testjar而不是SomeProject。

如何以maven的方式改变它?

1 个答案:

答案 0 :(得分:3)

添加了另一个支持此插件的插件,并提供了项目名称

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-eclipse-plugin</artifactId>
        <configuration>
            <projectNameTemplate>SomeProject</projectNameTemplate>
        </configuration>
    </plugin>