public
Description: A maven plugin that will alter the hosts file during a maven build
Homepage: http://github.com/darrinholst/hosts_maven_plugin
Clone URL: git://github.com/darrinholst/hosts_maven_plugin.git
darrinholst (author)
Thu Jun 11 20:27:41 -0700 2009
commit  513b3031529d1b2663aa6cafd62db780272e7830
tree    1ae252a47c3098e531930bb2c0a2a883fa64a057
parent  e3c49179b3bf421b9f5574399b857a77829c0787
name age message
file .gitignore Loading commit data...
file README.textile
file pom.xml
directory src/
README.textile

Description:

A need arose to test mvn releases without actually tagging and pushing artifacts to any “official” repository. Due to a bug in the maven release plugin it’s not possible to use properties in the scm information. This plugin will allow you to keep the same hostnames in the scm and distributionManagement tags, but pull a switch-a-roo with some hosts file magic.

Usage:

Given the following in your pom…

<scm>
    <connection>scm:svn:http://svnhost/trunk</connection>
</scm>

<distributionManagement>
    <repository>
        <id>releases</id>
        <url>http://mvnhost:8081/nexus/content/repositories/releases</url>
    </repository>
</distributionManagement>

add the plugin repository…

<pluginRepositories>
    <pluginRepository>
        <id>darrinholst</id>
        <url>http://darrinholst-maven.googlecode.com/svn/repo/</url>
    </pluginRepository>
</pluginRepositories>

and then add the plugin (most likely to a profile) which is bound to some phase that will get executed before the release, i.e. clean

<profiles>
    <profile>
        <id>local-deploy</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.darrinholst</groupId>
                    <artifactId>hosts-maven-plugin</artifactId>
                    <version>1.0.0</version>
                    <executions>
                        <execution>
                            <phase>clean</phase>
                            <goals>
                                <goal>switch</goal>
                            </goals>
                            <configuration>
                                <hosts>
                                    <svnhost>127.0.0.1</svnhost>
                                    <mvnhost>127.0.0.1</mvnhost>
                                </hosts>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

then when you execute…

mvn clean release:prepare release:perform -P local-deploy

…any traffic going to svnhost or mvnhost will head on over to 127.0.0.1