0

I've got a couple of problems with code update from GitLab repo using Maven SCM plugin. First, here's a part of my pom.xml with SCM and plugin configuration:

<scm>
    <url>http://path.to.my.repo</url>
    <connection>scm:git:http://path.to.my.repo.git</connection>
   <developerConnection>scm:git:http://path.to.my.repo.git</developerConnection>
</scm>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-scm-plugin</artifactId>
                <version>1.9.5</version>
            </plugin>
        </plugins>
    </pluginManagement>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-scm-plugin</artifactId>
            <configuration>
                <username>user</username>
                <password>pass</password>
            </configuration>
        </plugin>
    </plugins>
</build>

I've managed to push my code to remote repo like this:

git init
git add .
mvn -Dmessage="initial commit" scm:checkin

Now, these are my questions:

  1. I've done multiple changes in my working directory, but I've come to a dead end and I need to update my code with the one from remote repo. I've tried with git add . and mvn scm:update but the code is not updated. All changed files stay in a staging area. What am I doing wrong here? According to documentation this should be the right way. Basically I'm looking for an equivalent of git checkout . command.

  2. I've tried using mvn scm:add instead of git add ., but I just can't figure it out, how to add all files from current directory in a staging area.

I've tried mvn -Dincludes="." scm:add and it says Cannot run add command : Exception while executing SCM command. You must provide at least one file/directory to add.

Executing mvn -Dincludes="*" scm:add also causes error: [ERROR] The following paths are ignored by one of your .gitignore files: .project Use -f if you really want to add them. I don't really know why this command wants to add .project file to staging area since I've exclude it in .gitignore file.

So what should be the right way to add all changed files from current directory to a staging area using Maven SCM plugin (without excluded files from .gitignore, of course)?

Thank you for your suggestions.

peterremec
  • 488
  • 1
  • 15
  • 46
  • What is the reason to use maven-scm-plugin ? – khmarbaise May 28 '18 at 06:33
  • @khmarbaise is there a reason not to use it? – peterremec May 28 '18 at 06:35
  • No I just want to know why you use maven-scm-plugin for checking in etc ? What kind of problem do you have? What kind of issue are you trying to solve? Apart from answering a question with another question does not make sense... – khmarbaise May 28 '18 at 07:18
  • @khmarbaise At the moment I'm not trying to solve any particular issue, I'm just curious about using that plugin in order to know how to use it in the future projects. – peterremec May 28 '18 at 09:13
  • The question is: For what kind of use case would you like to use the plugin? – khmarbaise May 28 '18 at 09:55
  • I really don't know how to explain it in other words. I need to update my local copy with remote repo code. I'm trying to use plugin instead of git commands directly because it provides independent way of managing code. So if I change SCM provider, the same syntax is used. I could be wrong, I'm quite new to Maven, but can't I use that plugin in my case? Is it meant to be used for another purpose? – peterremec May 31 '18 at 13:06

0 Answers0