Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 283515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:22:48+00:00 2026-05-12T05:22:48+00:00

How can I commit a single artifact like a file or a directory to

  • 0

How can I commit a single artifact like a file or a directory to an arbitrary location in a svn repository in the deploy lifecycle phase? With repository I mean a plain Subversion repository here, not a Maven repository held in a Subversion repository!

I have already evaluated the wagon-svn but it seems it can just be used to commit a whole module build to a Maven repository held in a Subversion repository.

This is my use case: I generate a JAR-file including all dependencies during build. This is to be used in Python scripts, so outside the Maven world. And I want to provide the current release JAR always at the same location in the repository holding the Python framework.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T05:22:48+00:00Added an answer on May 12, 2026 at 5:22 am

    Before you do this I would carefully consider your reasons for doing so.
    Derived artifacts shouldn’t be put into SCM as they can easily be rebuilt, instead you could consider attaching the artifact to your build so it is deployed alongside it.

    This can be done with the build-helper-maven-plugin. The example config below will attach src/assembly/archive.xml as an additional artifact with the classifier "archive".

      <plugin>
        <inherited>true</inherited>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>attach-artifacts</id>
            <phase>deploy</phase>
            <goals>
              <goal>attach-artifact</goal>
            </goals>
            <configuration>
                <artifacts>
                  <artifact>
                    <file>src/assembly/archive.xml</file>
                    <type>xml</type>
                    <classifier>archive</classifier>
                  </artifact>
                </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
    

    This artifact can be referenced directly by specifying the classifier and type in your dependency declaration. For example:

    <dependency>
      <groupId>my.group.id</groupId>
      <artifactId>artifact-id</artifactId>
      <version>1.0.0</version>
      <type>xml</type>
      <classifier>archive</classifier>
    </dependency>
    

    If you are set on doing it this way, the Maven SCM API provides an abstraction layer for common SCM providers and operations. The code below can be added to a mojo. It expects to be provided two parameters, the file to be committed to Subversion and the scm url. When bound to your project, it will commit the file to the Subversion repository.

    package name.seller.rich;
    
    import java.io.File;
    
    import org.apache.maven.plugin.AbstractMojo;
    import org.apache.maven.plugin.MojoExecutionException;
    import org.apache.maven.plugin.MojoFailureException;
    import org.apache.maven.scm.ScmException;
    import org.apache.maven.scm.ScmFileSet;
    import org.apache.maven.scm.command.add.AddScmResult;
    import org.apache.maven.scm.manager.ScmManager;
    import org.apache.maven.scm.provider.ScmProvider;
    import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
    import org.apache.maven.scm.repository.ScmRepository;
    
    /**
     * @goal checkin-file
     */
    public class SVNCheckinMojo extends AbstractMojo {
    
        /**
         * @component
         * @required
         */
        private ScmManager manager;
    
        /**
         * @component
         * @required
         */
        private ScmProvider provider;
    
        /**
         * @parameter
         * @required
         */
        private String connectionUrl;
    
        /**
         * @parameter
         * @required
         */
        private File svnFile;
    
        /**
         * Obtain the SVN repository.
         */
        public ScmRepository getRepository() throws MojoExecutionException {
            try {
                ScmRepository repository = manager.makeScmRepository(connectionUrl);
    
                if (!(repository.getProviderRepository() instanceof SvnScmProviderRepository)) {
                    throw new MojoExecutionException(
                            "the scm provider is not an SVN provider");
                }
    
                return repository;
            } catch (Exception e) {
                throw new MojoExecutionException(
                        "Unable to obtain SCM repositorys", e);
            }
        }
    
        public void execute() throws MojoExecutionException, MojoFailureException {
            ScmRepository repository = getRepository();
    
            File dir = svnFile.getParentFile();
            File file = new File(svnFile.getName());
            ScmFileSet fileSet = new ScmFileSet(dir, file);
            try {
    
                AddScmResult result = provider.add(repository, fileSet);
    
                if (!result.isSuccess()) {
                    throw new MojoExecutionException("unable to add file \""
                            + svnFile + "\" to SCM URL \"" + connectionUrl + "\"");
                }
            } catch (ScmException e) {
                throw new MojoExecutionException(
                        "failed to commit file to repository", e);
            }
        }
    }
    

    Here’s an example pom for the plugin, note the maven-plugin packaging:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-svn-hack-plugin</artifactId>
      <packaging>maven-plugin</packaging>
      <version>0.0.1</version>
      <dependencies>
        <dependency>
          <groupId>org.apache.maven</groupId>
          <artifactId>maven-plugin-api</artifactId>
          <version>2.0</version>
        </dependency>
        <dependency>
          <groupId>org.apache.maven</groupId>
          <artifactId>maven-project</artifactId>
          <version>2.0</version>
        </dependency>
        <dependency>
          <groupId>org.apache.maven.scm</groupId>
          <artifactId>maven-scm-api</artifactId>
          <version>1.2</version>
        </dependency>
        <dependency>
          <groupId>org.apache.maven.scm</groupId>
          <artifactId>maven-scm-provider-svnexe</artifactId>
          <version>1.2</version>
        </dependency>
        <dependency>
          <groupId>org.apache.maven.scm</groupId>
          <artifactId>maven-scm-manager-plexus</artifactId>
          <version>1.2</version>
        </dependency>
        <dependency>
          <groupId>org.codehaus.plexus</groupId>
          <artifactId>plexus-utils</artifactId>
          <version>1.5.1</version>
        </dependency>
      </dependencies>
    </project>
    

    Here’s an example configuration that will check the file in during the package phase.

    <build>
      <plugins>
        <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-svn-hack-plugin</artifactId>
      <version>0.0.1</version>
      <configuration>
        <connectionUrl>scm:svn:http://svn.apache.org/svn/root/module</connectionUrl>
        <svnFile>${project.build.directory}/${artifactId}-${version}-test.txt</svnFile>
      </configuration>
      <executions>
        <execution>
          <id>checkin-file</id>
          <phase>package</phase>
          <goals>
            <goal>checkin-file</goal>
          </goals>
        </execution>
      </executions>
        </plugin>
      </plugins>
    </build>
    

    Or at a pinch you could use the antrun plugin to invoke the ant subversion library

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 132k
  • Answers 133k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I have now definitively fixed this by using an example… May 12, 2026 at 6:32 am
  • Editorial Team
    Editorial Team added an answer As documented: Xmx: default 64M Xms: default 2M That's for… May 12, 2026 at 6:32 am
  • Editorial Team
    Editorial Team added an answer Yes it is, so here's the entry from my blog:… May 12, 2026 at 6:32 am

Related Questions

I'm relatively new to Mercurial and my team is trying it out right now
I've spent 4 years developing C++ using Visual Studio 2008 for a commercial company;
First a bit of background. I have been working on the MS platform for
With SVN, I had a single big repository I kept on a server, and
I'm a single developer using Mercurial to create a program. I have so far

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.