Maven - Pull code from SVN

人盡茶涼 提交于 2019-12-05 16:53:18

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'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.

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?

You probably can, but it is not the 'Maven Way' of doing things.

Take a look at the Maven Release Plugin documentation.

What you'd typically do is:

  • Define your source control repository in your POM
  • Do a release:prepare which verifies everything is OK (no SNAPSHOT dependencies for release, etc.)
  • Do a release:peform. You can do this to a clean empty directory or even on a different machine that doesn't have the project checked out (release:perform can check out sources from source control by specifying an SCM URI on the command line).
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!