views:

892

answers:

2

I'm trying to use a custom maven wagon extension to deploy a jar to my own repository. Can I somehow configure in settings.xml that it recognizes the custom url scheme to be used with the specific wagon or do I have to always modify pom files to contain the wagon extension?


There doesn't need to be a base pom or any pom available when using the deploy-file. Settings.xml is the only place which is guaranteed to be there, but I can't figure out how to use it to define extensions.

+2  A: 

OK, ok, a correction: you cannot define the <build> element inside a <profile> defined in settings.xml. You could activate the profile in settings.xml, but define it in your base-pom.

Sorry, the only other way I could think of (probably what are you looking for), is to copy the extension jar directly under $M2_HOME/lib. All $M2_HOME/lib/*.jar are put in the classpath, so this must virtually have the same effect as an <extension>.

The extension however is better, because you can more easily control which version of the extension is used (e.g. trough the base-pom).

OK just try copying the extension jar under

    $M2_HOME/lib
siddhadev
Yeah but how do I define the extension in local settings?
JtR
see my last edit above
siddhadev
Where did you find that it should work as my maven complains about "build" inside a "profile"?
JtR
ok, sorry, see my correction - the profile definitions in settings.xml are somehow limited. User $M2_HOME/lib
siddhadev
This is what I'm doing currently, but it's not very handy as everyone using the extension have to manually download it and place it in the lib directory. Thanks you anyway!
JtR
+1  A: 

You need to add the wagon extension to your top level pom.xml. Most environments have a corporate one at the top of all their projects (best practice), so this generally isn't too painful for individual developers -- they just inherit from the corporate pom.

<build>
  <extensions>
    <extension>
      <groupId>org.apache.maven.wagon</groupId>
      <artifactId>wagon-scm</artifactId>
      <version>1.0-alpha-7-SNAPSHOT</version>
    </extension>
    <extension>
      <groupId>org.apache.maven.scm</groupId>
      <artifactId>maven-scm-manager-plexus</artifactId>
      <version>1.0-beta-3-SNAPSHOT</version>
    </extension>
    <extension>
      <groupId>org.apache.maven.scm</groupId>
      <artifactId>maven-scm-provider-svnexe</artifactId>
      <version>1.0-beta-3-SNAPSHOT</version>
    </extension>
  </extensions>
</build>
<distributionManagement>
  <site>
    <id>my.svn.server</id>
    <url>scm:svn:https://[email protected]/svn/root/module&lt;/url&gt;
  </site>
</distributionManagement>

When you register your provider, it also registers the protocol pattern as well I believe. You can see a full list of the existing providers here.

I believe it is the getScmType() method that registers the extension, but I'm not 100% certain.

/** {@inheritDoc} */
public String getScmType()
{
    return "git";
}

The link to the Git provider's source can be found here.

Matthew McCullough
Developers shouldn't have to have any poms available when using the deploy-file feature. How do I use settings to define extensions?
JtR
I have a feeling you are chasing something that oddly can't be done. I'd try asking the #Maven IRC channel too. I agree; developers shouldn't have to have a pom for deploy-file. Can't do extensions in settings.xml. Surprised even me!
Matthew McCullough
You can't unless you define a pom. It's just not a supported use case at the moment.
Brian Fox