darrinholst / hosts_maven_plugin

A maven plugin that will alter the hosts file during a maven build

This URL has Read+Write access

darrinholst (author)
Thu Jun 11 20:21:07 -0700 2009
commit  e3c49179b3bf421b9f5574399b857a77829c0787
tree    3d8e20a38821d4abd39fa42a381c09c70dd119e7
parent  5c033231d0135c16aae3744d8e9566c9692efb1a
name age message
file .gitignore Loading commit data...
file README.textile
file pom.xml
directory src/
README.textile

Description:

The need to test out our mvn releases without actually tagging and pushing artifacts to the repository. Due to a bug(http://jira.codehaus.org/browse/MRELEASE-128) 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 tag, 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