<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.infradna.tool</groupId>
    <artifactId>bridge-method-injector-parent</artifactId>
    <version>1.8</version>
    <relativePath>../pom.xml</relativePath>
  </parent>
  <artifactId>bridge-method-injector</artifactId>
  <packaging>maven-plugin</packaging>

  <name>bridge-method-injector</name>
  <description>Evolve your classes without breaking compatibility</description>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <version>2.0</version>
        <dependencies>
          <dependency>
            <groupId>org.apache.maven.scm</groupId>
            <artifactId>maven-scm-provider-gitexe</artifactId>
            <version>1.2</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>run</goal>
            </goals>
            <phase>test</phase>
            <configuration>
              <tasks>
                <delete dir="target/test-classes" />
                <mkdir dir="target/test-classes/v1" />
                <mkdir dir="target/test-classes/v2" />
                <mkdir dir="target/test-classes/client" />

                <!-- basic sanity. unmodified client and v1 should work as expected -->
                <javac source="1.6" target="1.6" srcdir="src/test/v1" destdir="target/test-classes/v1" />
                <javac source="1.6" target="1.6" srcdir="src/test/client" destdir="target/test-classes/client" classpath="target/test-classes/v1" />
                <java classname="Main" args="foo" failonerror="true">
                  <classpath>
                    <pathelement path="target/test-classes/v1" />
                    <pathelement path="target/test-classes/client" />
                  </classpath>
                </java>

                <!-- compile v2 -->
                <javac source="1.6" target="1.6" srcdir="src/test/v2" destdir="target/test-classes/v2" classpath="${maven.compile.classpath}">
                  <compilerarg value="-XprintProcessorInfo" />
                  <classpath>
                    <pathelement path="target/classes" />
                    <path refid="maven.compile.classpath" />
                  </classpath>
                </javac>

                <!-- post process v2 -->
                <java classname="com.infradna.tool.bridge_method_injector.MethodInjector" args="${project.basedir}/target/test-classes/v2" failonerror="true">
                  <classpath refid="maven.compile.classpath" />
                </java>

                <!-- verify that unmodified client code continue to work with v2 binary -->
                <java classname="Main" args="bar" failonerror="true">
                  <classpath>
                    <pathelement path="target/test-classes/v2" />
                    <pathelement path="target/test-classes/client" />
                  </classpath>
                </java>

                <!-- was testing source compatibility, but with widening change it won't work anymore -->
                <!--
                <mkdir dir="target/test-classes/client-on-v2" />
                <javac source="1.6" target="1.6" srcdir="src/test/client" destdir="target/test-classes/client-on-v2">
                  <classpath>
                    <pathelement path="target/test-classes/v2" />
                  </classpath>
                </javac>
                <java classname="Main" args="bar" failonerror="true">
                  <classpath>
                    <pathelement path="target/test-classes/v2" />
                    <pathelement path="target/test-classes/client-on-v2" />
                  </classpath>
                </java>
                -->
              </tasks>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>com.sun</groupId>
            <artifactId>tools</artifactId>
            <version>1.6</version>
            <scope>system</scope>
            <systemPath>${java.home}/../lib/tools.jar</systemPath>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
    <extensions>
      <extension>
        <groupId>org.jvnet.wagon-svn</groupId>
        <artifactId>wagon-svn</artifactId>
        <version>1.9</version>
      </extension>
    </extensions>
  </build>

  <scm>
    <connection>scm:git:git@github.com:infradna/bridge-method-injector.git</connection>
  </scm>

  <developers>
    <developer>
      <id>kohsuke</id>
      <name>Kohsuke Kawaguchi</name>
    </developer>
  </developers>

  <licenses>
    <license>
      <name>MIT License</name>
      <distribution>repository</distribution>
      <url>http://www.opensource.org/licenses/mit-license.php</url>
    </license>
  </licenses>

  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>bridge-method-annotation</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>asm</groupId>
      <artifactId>asm-debug-all</artifactId>
      <version>3.2</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-plugin-api</artifactId>
      <version>2.0.1</version>
    </dependency>
  </dependencies>
  
</project>
