2016-04-29 64 views
0

我使用Build Helper Maven Plugin構造屬性,是與版本「 - 」對......我有它配置如下。「」:建立幫助Maven插件財產不工作的資源TARGETPATH

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>build-helper-maven-plugin</artifactId> 
    <version>1.10</version> 
    <executions> 
     <execution> 
     <id>regex-property</id> 
     <goals> 
      <goal>regex-property</goal> 
     </goals> 
     <configuration> 
      <name>webscript.version</name> 
      <value>${project.version}</value> 
      <regex>\.</regex> 
      <replacement>-</replacement> 
      <failIfNoMatch>false</failIfNoMatch> 
     </configuration> 
    </execution> 
    </executions> 
</plugin> 

這時候我建立包含${webscript.version}財產資源(在文件中預期它們正確地取代)正常工作,所以這是工作:

<resource> 
    <targetPath>./alfresco/site-webscripts/org/alfresco/aikau/${project.version}/webscripts</targetPath> 
    <filtering>true</filtering> 
    <directory>${basedir}/src/main/resources/webscripts</directory> 
</resource> 

不過,我遇到的問題是使用該屬性的任何其他地方項目......我想要做的就是使用屬性的目標文件夾,如:

<resource> 
    <targetPath>./alfresco/site-webscripts/customizations/${webscript.version}</targetPath> 
    <filtering>true</filtering> 
    <directory>${basedir}/src/main/resources/extension-webscripts</directory> 
</resource> 

有了這個代碼,創建的文件夾簡直是「$ {} webscript.version」而不是「1 -0-66「(在當前版本爲1.0.66的情況下)。

這兩個工作和非工作的例子都在相同<build>元素,所以我假設在同一階段。

有人可以告訴我如何調整配置以使其發揮作用,或者建議替代方法來替代「。」。與「 - 」作爲一個新的財產,將在這種情況下工作?

+0

我無法重現你的錯誤。當我嘗試時,該物業已被正確地更換。使用Maven 3.3.3。 – Tunaki

+0

啊,有趣...我在Maven 3.2.5上 - 謝謝,我會嘗試升級。 –

回答

0

我能解決這個使用Maven的antrun-插件具有以下執行:

<execution> 
    <id>rename-extensions-folder</id> 
    <phase>prepare-package</phase> 
    <goals> 
    <goal>run</goal> 
    </goals> 
    <configuration> 
    <target> 
     <echo>Renaming folder</echo> 
     <move file="${project.build.outputDirectory}/alfresco/site-webscripts/customizations/${project.version}" 
       tofile="${project.build.outputDirectory}/alfresco/site-webscripts/customizations/${webscript.version}"/> 
     </target> 
    </configuration> 
</execution> 

...雖然我還是真的想知道如何利用自定義屬性的不需要這一步!

0

您可以使用gmaven-plugin是常規的Maven插件真的很強大

<plugin> 
<groupId>org.codehaus.groovy.maven</groupId> 
<artifactId>gmaven-plugin</artifactId> 
<version>1.4</version> 
<executions> 
    <execution> 
    <id>change-properties</id> 
    <phase>initialize</phase> 
    <goals> 
     <goal>execute</goal> 
    </goals> 
    <configuration> 
     <source> 
     if (something) { 
      project.properties.myProperty = 'myPropertyValue' 
     } 
     </source> 
    </configuration> 
    </execution> 
</executions> 

這裏另一個Example

希望這有助於