开发者

Including Git Repo Contents As Subdir With Maven

开发者 https://www.devze.com 2023-01-21 14:13 出处:网络
I have a separate git repository fo开发者_StackOverflowr document templates that I have no control over but whose contents need to be included as a folder in my final WAR. The versioning of these do n

I have a separate git repository fo开发者_StackOverflowr document templates that I have no control over but whose contents need to be included as a folder in my final WAR. The versioning of these do not matter and the latest ones should always be used when packaging the war.

Is this possible with Maven or do I need to script something separately? I would very much like to avoid using a git submodule at all costs.


Is this possible with Maven or do I need to script something separately? I would very much like to avoid using a git submodule at all costs.

It should be possible to use the Maven SCM Plugin and its scm:checkout goal to get the content of your git repository (providing all the required information in the configuration like the connectionUrl, the checkoutDirectory, etc) during the prepare-package phase (and get it packaged in your war during package). Something like this:

[...]
<build>
  [...]
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-scm-plugin</artifactId>
      <version>1.1</version>
      <executions>
        <execution>
          <phase>prepare-package</phase>
          <goals>
            <goal>checkout</goal>
          </goals>
          <configuration>
            <checkoutDirectory>${project.build.directory}/${project.build.finalName}/somepath</checkoutDirectory>
            <connectionUrl>scm:git:git://server_name[:port]/path_to_repository</connectionUrl>
            ...
          </configuration>
        </execution>
      </executions>
    </plugin>
    [...]
  </plugins
  [...]
</build>
[...]


checkout the section on war resources here

Just point the webResoruces configuration to your git repo and it will be included in the war. You may alwo want to add an ignore option for the .git folder (unless you want all of git's artifacts in your war as well).

0

精彩评论

暂无评论...
验证码 换一张
取 消