2010-07-30 17 views
1

我已經開始玩Maven2,我試圖將我的一個項目從ant移植到maven。我已經設法建立ear文件,使用jaxb和其他位,但還有一件事我不知道該怎麼辦。在Maven2中使用JSBuilder2.jar Web應用程序

我有WAR模塊,ExtJS代碼,我用JSBuilder很好地創建和打包代碼。這是作爲螞蟻任務和看起來像這樣:

<target name="-pre-compile" description="Building Frontend Libraries"> 
    <java jar="web/lib/dev/JSBuilder2.jar" failonerror="true" fork="true" > 
     <arg line="--projectFile web/lib/dev/frontend.jsb2 --homeDir web/lib"/> 
    </java> 
</target> 

我想知道什麼是'maven'的方式來做到這一點?有沒有一種方法可以純粹在maven中完成(看看maven:exec插件,但有點令人困惑),還是我必須從maven調用ant來實現此目的?

感謝

回答

2

exec-maven-plugin是正確的答案(儘管你想java的目標)。您需要將其綁定到生命週期階段。以usage page爲例。在你的情況,你需要這樣的事:

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>exec-maven-plugin</artifactId> 
    <version>1.1</version> 
    <executions> 
    <execution> 
     <id>jsbuilder</id> 
     <goals> 
     <goal>java</goal> 
     </goals> 
     <phase>compile</phase> 
     <configuration> 
     <mainClass><!-- fill in from jar's META-INF/MANIFEST.MF --></mainClass> 
     <argument>--projectFile</argument> 
     <argument>web/lib/dev/frontend.jsb2</argument> 
     <argument>--homedir</argument> 
     <argument>web/lib</argument> 
     </configuration> 
    </execution> 
    </executions> 
    <configuration> 
    <includeProjectDependencies>false</includeProjectDependencies> 
    <includePluginDependencies>true</includePluginDependencies> 
    </configuration> 
    <dependencies> 
    <!-- a bit nasty, would be better if jsbuilder2 available in a maven repo. --> 
    <dependency> 
     <groupId>com.extjs</groupId> 
     <artifactId>jsbuilder2</artifactId> 
     <version>2.0.0</version> 
     <scope>system</scope> 
     <systemPath>web/lib/dev/JSBuilder2.jar</systemPath> 
    </dependency> 
    </dependencies> 
</plugin> 

如果你是JSBuilder2的一大用戶,這將會是值得一問Cencha如果他們可以將其發佈到Maven的中央回購。將它們指向OSS Repository Hosting

+0

嗨多米尼克, 感謝您的重播。我調整了你的例子,我可以從Maven調用JSBuilder,但是現在我遇到了一個小問題。似乎腳本中描述的參數對於jsbuilder不可見。調用返回幫助打印輸出,這表明所有參數都沒有傳遞。我確實看過你提到的例子,看着它們看起來應該沒問題,所以有點困惑。我想我會嘗試使用不同版本的maven exec插件,但結果相同。 我不知道可能是什麼問題。 – Greg 2010-08-02 10:00:46

+0

更多的研究和神祕解決! :) 我不得不使用作爲一個字符串傳遞命令行參數。非常感謝您的幫助! – Greg 2010-08-02 10:07:35

相關問題