开发者

Automated replacement of the scm part properties of a pom

At the moment we're going to migrating all of our cvs projects to git. Our custom script is using the git converter and everything is fine. Now i would like to incorporate the aut开发者_Python百科omated replacement of the scm part properties with the new values.

Is there a plugin similar to org.codehaus.mojo:versions-maven-plugin but appling to the scm part?


No, but it would be a trivial plugin to implement.

Just define search and replace patterns:

/**
 * @parameter expression="${project}"
 * @readonly
 */
private MavenProject project;

/**
 * @parameter expression="${searchPattern}"
 * @required
 */
private String searchPattern;


/**
 * @parameter expression="${replacePattern}"
 * @required
 */
private String replacePattern;

/**
 * @component
 */
private ModelWriter modelWriter;

public void execute(){
    final Model model = project.getModel();
    model.getScm().setConnection(
            model.getScm()
            .getConnection()
            .replaceFirst(searchPattern, replacePattern));
    // do the same for scm.getDeveloperConnection()

    modelWriter.write(
        new File(project.getBasedir(),"pom.xml"),
        Collections.<String,Object>emptyMap(), model);
}


No there is no plugin for this kind of purpose. (May be someone else knows one?)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜