2013-05-28 41 views
2

我有一個maven項目和一個SBT項目作爲maven項目的一個模塊。我需要創建一個命令maven build,它也執行SBT包任務。從maven使用sbt

有沒有我可以用來將SBT與maven集成的插件?

謝謝。

回答

2

一種選擇是使用「Exec的Maven插件」,這裏是一個例子做一個「玩編譯」

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>exec-maven-plugin</artifactId> 
    <version>1.2.1</version> 
    <executions> 
     <execution> 
     <goals> 
      <goal>exec</goal> 
     </goals> 
     </execution> 
    </executions> 
    <configuration> 
     <executable>${path.to.play}</executable> 
     <workingDirectory>${path.to.project.root}</workingDirectory> 
     <arguments> 
     <argument>compile</argument> 
     </arguments> 
    </configuration> 
    </plugin> 
+0

它在Windows上工作嗎?我想從maven運行sbt,但sbt是一個包裝腳本,不能由Windows上的exec插件運行。 –

0

使用Maven插件antrun(我的例子是構建Scala.js應用程序) 。

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <version>1.8</version> 
      <executions> 
       <execution> 
        <phase>pre-integration-test</phase> 
        <configuration> 
         <target> 
          <exec executable="cmd.exe" 
            spawn="true"> 
           <arg value="/c"/> 
           <arg value="C:\Program Files (x86)\sbt\bin\sbt.bat"/> 
           <arg value="fullOptJS"/> 
          </exec> 
         </target> 
        </configuration> 
        <goals> 
         <goal>run</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

信貸由於@checat在他的評論,並在Launching a windows batch script using Maven exec plugin blocks the build even though the script uses "start"

其他的想法的討論表明這一點;它可能仍然值得在非Windows系統上使用mvn-exec,可能使用maven配置文件。如果我走這條路,我會盡量記住更新答案。