代码之家  ›  专栏  ›  技术社区  ›  Greg

在Maven2 Web应用程序中使用JSBuilder2.jar

  •  1
  • Greg  · 技术社区  · 16 年前

    我已经开始使用Maven2,我正在尝试将我的一个项目从ant移植到maven。我已经成功地构建了ear文件,使用了jaxb和其他bits,但是还有一件事我不知道如何处理。

    我有一个带有ExtJS代码的WAR模块,我使用JSBuilder很好地创建和打包代码。这是作为ant任务完成的,如下所示:

    <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:exec plugin 但是有点困惑)或者我必须从maven打电话给ant才能实现这个目标吗?

    谢谢

    1 回复  |  直到 16 年前
        1
  •  2
  •   Dominic Mitchell    16 年前

    这个 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 central repo。把他们指向 OSS Repository Hosting .