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
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