gitmavenversion-controlgitlabmaven-scm

Connect to GitLab with maven-scm-plugin


I'm new to Maven and I've just made some simple app. Now I'm trying to commit my code to GitLab repo and I ran into some problems. I'm using maven-scm-plugin and I just can't push my code to GitLab repo.

part of pom.xml file:

<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>
                <goals>install</goals>
            </configuration>
        </plugin>
    </plugins>
</build>

I already managed to commit code on a remote repo with the following sequence of git commands:

// initialization
git init

// adding files to staging area
git add .

// commit to local repo
git commit -m "Initial commit"

// set remote url
git remote add origin http://path.to.my.repo

// push
git push origin master

Based on maven-scm-plugin docs I just can't figure it out what is the correct order of commands to achieve the same as using git commands listed above. Any help?


Solution

  • maven-scm-plugin can be used to commit change to git repo by the command mvn scm:checkin.

    But for creating a git repo, there is no such maven commands to equal with the command git init.