2013-03-28 135 views
1

我有一個原型項目與這個樣子的(有兩個模塊,__artifactId__-1__artifactId__-2):Maven的重命名模塊名稱

Parent 
     pom.xml 
     __artifactId__-1 
      pom.xml 
     __artifactId__-2 
      pom.xml 

,當我生成使用這個原型僞像ID的項目說「 Infra',它應該產生這樣的結構:

Parent 
     pom.xml 
     Infra-1 
      pom.xml 
     Infra-2 
      pom.xml 

它它做什麼。所以這是行得通的。

什麼不工作是在父pom.xml中,我已經包括此模塊爲:

<modules> 
     <module>__artifactId__-1</module> 
     <module>__artifactId__-2</module> 
</modules> 

這些模塊條目沒有得到重命名爲像(上一代):

<modules> 
     <module>Infra-1</module> 
     <module>Infra-2</module> 
</modules> 

這就是我想要的。

任何想法如何做到這一點,謝謝。

UPDATE 我在這裏添加元數據的XML文件要求,但我不希望修改原型-metadata.xml文件。 由於我想使用create-from-project命令創建原型,因此安裝並生成時不需要任何手動干預或返工。

<?xml version="1.0" encoding="UTF-8"?> 
<archetype-descriptor xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" name="archetype-1" 
    xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <fileSets> 
    <fileSet filtered="true" encoding="UTF-8"> 
     <directory>__artifactId__-1/src</directory> 
     <includes> 
     <include>**/*.xml</include> 
     </includes> 
    </fileSet> 
    <fileSet filtered="true" encoding="UTF-8"> 
     <directory>support</directory> 
     <includes> 
     <include>**/*.xml</include> 
     <include>**/*.properties</include> 
     <include>**/*.txt</include> 
     </includes> 
    </fileSet> 
    <fileSet filtered="true" encoding="UTF-8"> 
     <directory>properties/deploy</directory> 
     <includes> 
     <include>**/*.xml</include> 
     </includes> 
    </fileSet> 
    <fileSet filtered="true" encoding="UTF-8"> 
     <directory>__artifactId__-2/target</directory> 
     <includes> 
     <include>**/*.xml</include> 
     </includes> 
    </fileSet> 
    <fileSet filtered="true" encoding="UTF-8"> 
     <directory>__artifactId__-2/src</directory> 
     <includes> 
     <include>**/*.jsp</include> 
     <include>**/*.java</include> 
     <include>**/*.xml</include> 
     <include>**/*.properties</include> 
     </includes> 
    </fileSet> 
    <fileSet filtered="true" encoding="UTF-8"> 
     <directory>properties</directory> 
     <includes> 
     <include>**/*.properties</include> 
     </includes> 
    </fileSet> 
    <fileSet filtered="true" encoding="UTF-8"> 
     <directory>__artifactId__-2</directory> 
     <includes> 
     <include>**/*.project</include> 
     <include>**/*.xml</include> 
     <include>**/*.classpath</include> 
     </includes> 
    </fileSet> 
    <fileSet filtered="true" encoding="UTF-8"> 
     <directory>__artifactId__-1</directory> 
     <includes> 
     <include>**/*.xml</include> 
     </includes> 
    </fileSet> 
    <fileSet filtered="true" encoding="UTF-8"> 
     <directory>support/lib</directory> 
     <includes> 
     <include>**/*.txt</include> 
     </includes> 
    </fileSet> 
    <fileSet encoding="UTF-8"> 
     <directory>__artifactId__-2/.settings</directory> 
     <includes> 
     <include>**/*.prefs</include> 
     </includes> 
    </fileSet> 
    <fileSet encoding="UTF-8"> 
     <directory>support</directory> 
     <includes> 
     <include>**/*.jar</include> 
     </includes> 
    </fileSet> 
    <fileSet encoding="UTF-8"> 
     <directory>__artifactId__-2/src</directory> 
     <includes> 
     <include>**/*.jpg</include> 
     <include>**/*.MF</include> 
     <include>**/*.md</include> 
     <include>**/*.png</include> 
     <include>**/*.jar</include> 
     <include>**/*.js</include> 
     <include>**/*.ftl</include> 
     <include>**/*.xsd</include> 
     <include>**/*.XML</include> 
     <include>**/*.TXT</include> 
     <include>**/*.gif</include> 
     <include>**/*.css</include> 
     </includes> 
    </fileSet> 
    <fileSet encoding="UTF-8"> 
     <directory>__artifactId__-2</directory> 
     <includes> 
     <include>**/*.checkstyle</include> 
     <include>**/*.pmd</include> 
     <include>**/*.log</include> 
     </includes> 
    </fileSet> 
    <fileSet encoding="UTF-8"> 
     <directory>support/bin</directory> 
     <includes> 
     <include>**/*.bat</include> 
     <include>**/*.log</include> 
     </includes> 
    </fileSet> 
    <fileSet encoding="UTF-8"> 
     <directory>support/lib</directory> 
     <includes> 
     <include>**/*.jar</include> 
     </includes> 
    </fileSet> 
    </fileSets> 
</archetype-descriptor> 
+0

你可以發佈archetype-metadata.xml嗎? – ben75

+0

我可以,而且我在Google上看到一個例子。但我不想修改archetype-metadata.xml文件。由於我想使用create-from-project命令創建原型,因此安裝並生成時不需要任何手動干預或返工。 – adi

+0

archetype-metadata.xml缺少模塊部分。看到這個http://maven.apache.org/archetype/maven-archetype-plugin/specification/archetype-metadata.html。我不知道它爲什麼會丟失,但我確定這就是爲什麼你的根目錄無效。 – ben75

回答

0

現在已經修復。

在父pom.xml中,模塊聲明位於配置文件中。

+0

hey @adi「模塊聲明在配置文件中」的含義是什麼。我也面臨同樣的問題。 –