2013-05-28 40 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配置文件。如果我走这条路,我会尽量记住更新答案。