Maven - 从SVN拉取代码 [英] Maven - Pull code from SVN

查看:1245
本文介绍了Maven - 从SVN拉取代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将J2ee项目从Ant迁移到Maven,

其中一个Ant任务是从SVN存储库拉取现有源代码

编译它,并将其jar添加到我当前的构建为Jar

I am migrating J2ee Project from Ant to Maven,
One of The ant tasks is to pull existing source from SVN Repository
Compile it, and add its jar to my current build as Jar

是否可以获取源代码并在Maven中编译?

Is it possible to do the get the source and compile it in Maven?

谢谢!

<target name="checkoutBuild" description="Pulls code from SVN into the build directory">
    <exec executable="svn">
        <arg line="co ${svn.projecturl} ${project.build.root} -r ${svn.revision} --username ${svn.username} --password ${svn.password}"/>
    </exec>
</target>


推荐答案

在预编译阶段之一,在 exec-maven-plugin 中执行 svn -sources 。我会尝试这样的东西(这是一个大脑转储,可能包含一些小错误):

Yes, in a similar way as in Ant. Execute the svn command in exec-maven-plugin in one of pre-compile phases, perhaps in generate-sources. I'd try something like this (it's a brain-dump, may contain minor mistakes):

<build>
 <plugins>
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>...</version>
    <executions>
      <execution>
        <id>svn</id>
        <goals>
          <goal>exec</goal>
        </goals>
        <phase>generate-sources</phase>
      </execution>
    </executions>
    <configuration>
      <executable>svn</executable>
      <arguments>
        <argument>co</argument>
        <argument>${svn.projecturl}</argument>
        <argument>${project.build.root}</argument>
        ...
      </arguments>
    <configuration>
  </plugin>
 </plugins>
</build>

EDIT

Prunge的回答让我想到了—你想要真正实现什么?如果项目总是作为构建的一部分,一个更好的方法是mavenize它(为它写一个POM),并将其作为一个模块/依赖。

Prunge's answer made me think — what do you want to really achieve? If the project is always to be the part of the build, a far better way would be to "mavenize" it (write a POM for it) and include it as a module/dependency.

如果SVN检出是一次性动作,也许最好保持原样,使用 mvn install:install-file (分配组ID和工件ID),并将其用作依赖项?

If the SVN checkout is to be a one-time action, maybe it's better to leave it as it is, add the jar to the repository with mvn install:install-file (assigning a group id and artifact id), and use it as a dependency?

这篇关于Maven - 从SVN拉取代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆