• Home
  • LLMs
  • Docker
  • Kubernetes
  • Java
  • Maven
  • About
Install | Subversion (a version control server to manage your code revisions)
  1. References
  2. Installation (Ubuntu 18.04)
  3. Create the SVN repository
  4. Create the project structure: trunk/branches/tags
  5. Create a maven project
  6. Create a new branch
  7. Release the project
  8. Backup a local SVN repository
  9. Delete the project from SVN
  10. Access Subversion via the http protocol (http://)
  11. Configure SCM to use http
  12. Uninstall Subversion

  1. References
    See these pages for more details on how to install Subversion:
    https://help.ubuntu.com/lts/serverguide/subversion.html
    https://help.ubuntu.com/community/Subversion

    Prerequisites:
    • Install Apache Maven
    • Install Apache HTTP Server
    • Install Nexus Repository Manager
  2. Installation (Ubuntu 18.04)
    Run the following command to install Subversion:
    $ sudo apt install subversion subversion-tools libapache2-mod-svn

    Verify the version of Subversion:
    $ svnserve --version
    svnserve, version 1.9.7 (r1800392)
       compiled Mar 28 2018, 08:49:13 on x86_64-pc-linux-gnu
    ...
  3. Create the SVN repository
    Create a local directory that will hold the SVN repository:
    $ sudo mkdir /data /data/subversion /data/subversion/repositories /data/subversion/repositories/myproject
    # $ sudo mkdir -p /data/subversion/repositories/myproject
    
    $ sudo chmod -R 775 /data/subversion/
    $ sudo chown -R mtitek:mtitek /data/subversion/

    You should replace mtitek:mtitek with your actual user/group names.

    Run the following command "svnadmin create" to create the SVN repository:
    $ svnadmin create /data/subversion/repositories/myproject

    Verify that the SVN repository is created:
    $ svn info file://localhost/data/subversion/repositories/myproject
    Path: myproject
    URL: file://localhost/data/subversion/repositories/myproject
    Relative URL: ^/
    Repository Root: file://localhost/data/subversion/repositories/myproject
    ...

    $ ls -1 /data/subversion/repositories/myproject
    conf
    db
    format
    hooks
    locks
    README.txt
  4. Create the SVN project structure: trunk/branches/tags
    Create a local directory that will hold the SVN project structure:
    $ sudo mkdir /data/svn /data/svn/mtitek-svn-test /data/svn/mtitek-svn-test/trunk /data/svn/mtitek-svn-test/branches /data/svn/mtitek-svn-test/tags
    
    $ sudo chmod -R 775 /data/svn/mtitek-svn-test/
    $ sudo chown -R mtitek:mtitek /data/svn/mtitek-svn-test/

    Run the following command "svn import" to create the SVN project structure:
    $ svn import /data/svn/mtitek-svn-test file://localhost/data/subversion/repositories/myproject/mtitek-svn-test -m "Initial creation of 'mtitek-svn-test'"
    Adding         /data/svn/mtitek-svn-test/branches
    Adding         /data/svn/mtitek-svn-test/tags
    Adding         /data/svn/mtitek-svn-test/trunk
    Committing transaction...
    Committed revision 1.

    Verify that the SVN folders are created:
    $ svn ls file://localhost/data/subversion/repositories/myproject/mtitek-svn-test
    branches/
    tags/
    trunk/

    Notes: You can also use the following path "file:///data/subversion/repositories/myproject/mtitek-svn-test"
  5. Create a maven project
    Create a local directory that will hold the maven project:
    $ sudo mkdir /data/workspace
    
    $ sudo chmod -R 755 /data/workspace/
    $ sudo chown -R mtitek:mtitek /data/workspace/

    Run the following command "mvn archetype:generate" to create the maven project:
    $ cd /data/workspace/
    
    $ mvn archetype:generate \
    -DarchetypeGroupId=org.apache.maven.archetypes \
    -DarchetypeArtifactId=maven-archetype-quickstart \
    -DarchetypeVersion=1.4 \
    -DgroupId=mtitek.svn.test \
    -DartifactId=mtitek-svn-test-a \
    -Dpackage=mtitek.svn.test \
    -Dversion=1.0.0-SNAPSHOT \
    -DinteractiveMode=false

    Commit the maven project to SVN:
    $ svn import /data/workspace/mtitek-svn-test-a \
    file://localhost/data/subversion/repositories/myproject/mtitek-svn-test/trunk/mtitek-svn-test-a \
    -m "Initial creation of 'mtitek-svn-test-a'"

    Verify that the project is commited:
    $ svn ls file://localhost/data/subversion/repositories/myproject/mtitek-svn-test/trunk/mtitek-svn-test-a/
    pom.xml
    src/

    Checkout the project from SVN:
    $ rm -rf /data/workspace/mtitek-svn-test-a
    $ svn co file://localhost/data/subversion/repositories/myproject/mtitek-svn-test/trunk/mtitek-svn-test-a/ /data/workspace/mtitek-svn-test-a
  6. Create a new branch
    Add the scm configuration to "pom.xml" file:
    $ cd /data/workspace/mtitek-svn-test-a/
    $ vi pom.xml

    <scm>
        <connection>scm:svn:file://localhost/data/subversion/repositories/myproject/mtitek-svn-test/trunk/mtitek-svn-test-a</connection>
        <developerConnection>scm:svn:file://localhost/data/subversion/repositories/myproject/mtitek-svn-test/trunk/mtitek-svn-test-a</developerConnection>
        <url>file://localhost/data/subversion/repositories/myproject/mtitek-svn-test/trunk/mtitek-svn-test-a</url>
    </scm>

    Commit the modifications to SVN:
    $ svn ci -m "Adding scm configuration"

    Create a new branch:
    $ mvn release:branch \
    -DbranchName="mtitek-svn-test-a-branch-1.0.1-SNAPSHOT" \
    -DreleaseVersion="1.0.1-SNAPSHOT" \
    -DupdateBranchVersions=true \
    -DupdateWorkingCopyVersions=false \
    -DautoVersionSubmodules=true

    Verify that the new branch is created:
    $ svn ls file://localhost/data/subversion/repositories/myproject/mtitek-svn-test/branches/mtitek-svn-test-a-branch-1.0.1-SNAPSHOT
    pom.xml
    src/

    Checkout the new branch:
    $ cd /data/workspace
    $ svn co file://localhost/data/subversion/repositories/myproject/mtitek-svn-test/branches/mtitek-svn-test-a-branch-1.0.1-SNAPSHOT /data/workspace/mtitek-svn-test-a-branch-1.0.1-SNAPSHOT

    Verify the project version and the scm configuration in the "pom.xml":
    $ cd /data/workspace/mtitek-svn-test-a-branch-1.0.1-SNAPSHOT
    $ vi pom.xml

    <version>1.0.1-SNAPSHOT</version>
    
    <scm>
        <connection>scm:svn:file://localhost/data/subversion/repositories/myproject/mtitek-svn-test/branches/mtitek-svn-test-a-branch-1.0.1-SNAPSHOT</connection>
        <developerConnection>scm:svn:file://localhost/data/subversion/repositories/myproject/mtitek-svn-test/branches/mtitek-svn-test-a-branch-1.0.1-SNAPSHOT</developerConnection>
        <url>file://localhost/data/subversion/repositories/myproject/mtitek-svn-test/branches/mtitek-svn-test-a-branch-1.0.1-SNAPSHOT</url>
    </scm>
  7. Release the project
    Before you start this section, please note that you might get this error if run the command mvn release:perform:
    [INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project mtitek-svn-test-a: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]

    This might happen if your Nexus or equivalent repository manager is not configured, or your maven project doesn't have a distribution management element. See this page for more details on how to configure Nexus: Nexus Repository Manager

    Run the following commands to release the project:

    • Go to "mtitek-svn-test-a" project:
      $ cd /data/workspace/mtitek-svn-test-a

    • Configure the "pom.xml" file of the project "mtitek-svn-test-a".
      Add a "distributionManagement" element to configure the nexus repositories Snapshots and Releases:
      $ vi pom.xml
      <distributionManagement>
          <snapshotRepository>
              <id>httpNexusSnapshots</id>
              <name>Snapshots repository</name>
              <url>http://localhost:8081/repository/maven-snapshots</url>
          </snapshotRepository>
      
          <repository>
              <id>httpNexusReleases</id>
              <name>Releases repository</name>
              <url>http://localhost:8081/repository/maven-releases</url>
          </repository>
      </distributionManagement>

      Commit the modifications to SVN:
      $ svn ci -m "Adding nexus repositories configuration"

    • Run "mvn versions:use-releases" command:
      $ mvn versions:use-releases -DgenerateBackupPoms=false -DexcludeReactor=true

    • Run "mvn release:prepare" command:
      $ mvn release:prepare -DautoVersionSubmodules=true

      ...
      What is the release version for "mtitek-svn-test-a"? (mtitek.svn.test:mtitek-svn-test-a) 1.0.0: :
      What is SCM release tag or label for "mtitek-svn-test-a"? (mtitek.svn.test:mtitek-svn-test-a) mtitek-svn-test-a-1.0.0: :
      What is the new development version for "mtitek-svn-test-a"? (mtitek.svn.test:mtitek-svn-test-a) 2.0.1-SNAPSHOT: :
      ...

      Verify the project version in the "pom.xml" file:
      <version>1.0.1-SNAPSHOT</version>

      Verify the project version in the "pom.xml.releaseBackup" file:
      <version>1.0.0-SNAPSHOT</version>

    • Run "mvn release:perform" command:
      $ mvn release:perform

      [INFO] [INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) @ mtitek-svn-test-a ---
      
      [INFO] Uploaded to httpNexusReleases: http://localhost:8081/repository/maven-releases/mtitek/svn/test/mtitek-svn-test-a/1.0.0/mtitek-svn-test-a-1.0.0.jar
      
      [INFO] Uploaded to httpNexusReleases: http://localhost:8081/repository/maven-releases/mtitek/svn/test/mtitek-svn-test-a/1.0.0/mtitek-svn-test-a-1.0.0.pom
      
      [INFO] Uploaded to httpNexusReleases: http://localhost:8081/repository/maven-releases/mtitek/svn/test/mtitek-svn-test-a/maven-metadata.xml
      
      [INFO] Uploaded to httpNexusReleases: http://localhost:8081/repository/maven-releases/mtitek/svn/test/mtitek-svn-test-a/1.0.0/mtitek-svn-test-a-1.0.0-sources.jar
      
      [INFO] Uploaded to httpNexusReleases: http://localhost:8081/repository/maven-releases/mtitek/svn/test/mtitek-svn-test-a/1.0.0/mtitek-svn-test-a-1.0.0-javadoc.jar

      Verify that the released component was deployed to Nexus:
      Deployment - Nexus

    Verify that the new release is created:
    $ svn ls file://localhost/data/subversion/repositories/myproject/mtitek-svn-test/tags/mtitek-svn-test-a-1.0.0
    pom.xml
    src/

    Checkout the new release:
    $ cd /data/workspace
    $ svn co file://localhost/data/subversion/repositories/myproject/mtitek-svn-test/tags/mtitek-svn-test-a-1.0.0 /data/workspace/mtitek-svn-test-a-1.0.0

    Verify the project version and the scm configuration in the 'pom.xml':
    $ cd /data/workspace/mtitek-svn-test-a-1.0.0
    $ vi pom.xml

    <version>1.0.0</version>
    
    <scm>
        <connection>scm:svn:file://localhost/data/subversion/repositories/myproject/mtitek-svn-test/tags/mtitek-svn-test-a-1.0.0</connection>
        <developerConnection>scm:svn:file://localhost/data/subversion/repositories/myproject/mtitek-svn-test/tags/mtitek-svn-test-a-1.0.0</developerConnection>
        <url>file://localhost/data/subversion/repositories/myproject/mtitek-svn-test/tags/mtitek-svn-test-a-1.0.0</url>
    </scm>
  8. Backup the SVN repository
    Run the following command (svnadmin dump) to backup the SVN repository:
    $ sudo mkdir /data/subversion_dump/
    
    $ sudo chmod -R 775 /data/subversion_dump/
    $ sudo chown -R mtitek:mtitek /data/subversion_dump/
    
    $ cd /data/subversion/repositories/myproject
    $ svnadmin dump . --incremental > /data/subversion_dump/dump-incremental
    * Dumped revision 0.
    * Dumped revision 1.
    * Dumped revision 2.
    ...
  9. Delete the project from SVN
    Run the following command (svn delete) to delete a project from SVN:
    $ svn delete -m "Deleting project 'mtitek-svn-test-a-1.0.0'" file://localhost/data/subversion/repositories/myproject/mtitek-svn-test/tags/mtitek-svn-test-a-1.0.0
  10. Access Subversion via the http protocol (http://)
    See this page for more details on how to install and configure Apache HTTP Server: Install Apache HTTP Server

    Configure Apache httpd to allow access to Subversion repositories:
    $ sudo vi /etc/apache2/sites-available/000-default.conf

    Add the following inside "VirtualHost" element:
    <Location /svn>
        DAV svn
        SVNParentPath /data/subversion/repositories
        SVNListParentPath On
        AuthType Basic
        AuthName "Subversion Repository"
        AuthUserFile /etc/subversion/passwd
        Require valid-user
    </Location>

    Configure a username/password to enforce authentication:
    $ sudo htpasswd -c /etc/subversion/passwd svnmtitek
    New password:
    Re-type new password:
    Adding password for user svnmtitek

    Enable the 'dav_svn' apache module (if not already enabled):
    $ sudo a2enmod dav_svn
    Considering dependency dav for dav_svn:
    Enabling module dav.
    Enabling module dav_svn.
    To activate the new configuration, you need to run:
      service apache2 restart

    Create a new group 'subversion':
    $ sudo addgroup subversion
    $ sudo adduser www-data subversion
    $ sudo adduser mtitek subversion
    
    $ sudo chown -R mtitek:subversion /data/subversion/

    Restart Apache:
    $ sudo service apache2 restart

    Verify that the http protocol is working:
    $ svn ls http://localhost/svn/myproject/mtitek-svn-test --username svnmtitek
    Authentication realm: <http://localhost:80> Subversion Repository
    Password for 'svnmtitek': *********
    
    branches/
    tags/
    trunk/

    You can use the browser: http://localhost/svn/myproject/mtitek-svn-test/

    HTTP Access
  11. Configure SCM to use http
    Modify the 'pom.xml' file:
    $ cd /data/workspace/mtitek-svn-test-a
    $ vi pom.xml

    <scm>
        <connection>scm:svn:http://localhost/svn/myproject/mtitek-svn-test/trunk/mtitek-svn-test-a</connection>
        <developerConnection>scm:svn:http://localhost/svn/myproject/mtitek-svn-test/trunk/mtitek-svn-test-a</developerConnection>
        <url>http://localhost/svn/myproject/mtitek-svn-test/trunk/mtitek-svn-test-a</url>
    </scm>

    Commit the modifications to SVN:
    $ svn ci -m "Updating scm connection to use http protocol"

    Checkout the project:
    $ rm -rf /data/workspace/mtitek-svn-test-a
    $ cd /data/workspace
    $ svn co http://localhost/svn/myproject/mtitek-svn-test/trunk/mtitek-svn-test-a/ /data/workspace/mtitek-svn-test-a

    Verify the SVN information:
    $ cd /data/workspace/mtitek-svn-test-a
    $ svn info
    Path: .
    Working Copy Root Path: /data/workspace/mtitek-svn-test-a
    URL: http://localhost/svn/myproject/mtitek-svn-test/trunk/mtitek-svn-test-a
    Relative URL: ^/mtitek-svn-test/trunk/mtitek-svn-test-a
    Repository Root: http://localhost/svn/myproject
    ...
  12. Uninstall Subversion
    List Subversion installed packages:
    $ apt list --installed | grep subversion

    Uninstall Subversion:
    $ sudo apt remove subversion

    Uninstall Subversion and its dependencies:
    $ sudo apt remove --auto-remove subversion
© 2025  mtitek