4

I have a java application that is in git repo RepoA and has a scm configuration set up for this repo for maven-release plugin etc. I want to fetch one file from another RepoB (it is fine to checkout the whole repo also because there is only 1 file there) and use it as a part of build step. How to do it with maven-scm plugin if scm section is already set up for RepoA?

Thanks.

4
  • Why? What purpose does this file have? Why is it not in your repository? Commented Jul 12, 2018 at 7:46
  • @khmarbaise is a schema file used by client and server application to generate classes. So it is in some separate repo (not client or server). Commented Jul 12, 2018 at 8:05
  • 2
    Best would be to create a separate project which contains the schema file and generates the classes and make in the end a consumable jar file..... Commented Jul 12, 2018 at 8:07
  • We generate for java and c#, so would like to share only schema and generate inside server or client apps Commented Jul 12, 2018 at 8:16

1 Answer 1

1

You can use a separate maven profile for this task.
Here's profile part from pom.xml, assuming that you want to fetch file foo/bar.txt from github repo github-user/some-repo:

<profile>
    <id>checkout-foo-bar</id>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-scm-plugin</artifactId>
                <version>1.11.2</version>
                <configuration>
                    <connectionUrl>scm:git:[email protected]:github-user/some-repo</connectionUrl>
                    <includes>foo/bar.txt</includes>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>

Then run mvn scm:checkout -P checkout-foo-bar

Plugin first fetches all the files from repo and then removes ones that you don't need. This takes extra time, especially if the repo is huge.

I didn't find a way to setup output directory other than default target/checkout. But hopefully this working example can be a good starting point to solve a problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.