<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>net.jangaroo</groupId>
  <artifactId>jangaroo-compiler</artifactId>
  <packaging>jar</packaging>
  <version>0.8.3</version>
  <name>Joo Compiler</name>

  <parent>
    <artifactId>jangaroo-parent</artifactId>
    <groupId>net.jangaroo</groupId>
    <version>0.8.3</version>
    <relativePath>../../jangaroo-parent/pom.xml</relativePath>
  </parent>


  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
    </resources>

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>

      <plugin>
        <groupId>de.jflex</groupId>
        <artifactId>maven-jflex-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <skeleton>src/main/jflex/skeleton.nested</skeleton>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.4</version>
        <executions>
          <execution>
            <id>generate-parser</id>
            <phase>generate-sources</phase>
            <configuration>
              <tasks>

                <property name="cup.input.filename" value="joo.cup" />
                <property name="cup.files.reldir" value="net/jangaroo/jooc" />
                <property name="cup.output.dir" value="${generated.cup.sources.dir}/${cup.files.reldir}" />
                <property name="cup.parser.classname" value="parser" />
                <property name="cup.output.filename" value="${cup.output.dir}/${cup.parser.classname}.java" />

                <mkdir dir="${cup.output.dir}" />

                <!-- forked java process may hang otherwise?! -->
                <delete file="${cup.output.filename}" />

                <java classname="java_cup.Main" fork="true" dir="${cup.output.dir}" failonerror="true">
                  <!-- arg value="-dump_states" /> -->
                  <arg value="-interface" />
                  <arg value="-expect" />
                  <arg value="1" />
                  <!--arg value="-dump"/-->
                  <arg value="${cup.sources.dir}/${cup.files.reldir}/${cup.input.filename}" />
                  <classpath>
                    <path refid="maven.plugin.classpath" />
                  </classpath>
                </java>

              </tasks>
              <sourceRoot>
                ${generated.cup.sources.dir}
              </sourceRoot>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>edu.princeton.cup</groupId>
            <artifactId>java-cup</artifactId>
            <version>10k</version>
          </dependency>
        </dependencies>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>net/jangaroo/test/integration/**/*</exclude>
          </excludes>
          <systemProperties>
            <property>
              <name>net.jangaroo.jooc.test.source</name>
              <value>${basedir}/target/test-classes</value>
            </property>
            <property>
              <name>net.jangaroo.jooc.test.destination</name>
              <value>${basedir}/target/temp/js</value>
            </property>
          </systemProperties>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
      </plugin>

      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <id>create-archives</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <appendAssemblyId>false</appendAssemblyId>
              <attach>true</attach>
              <descriptors>
                <descriptor>src/main/assembly/examples.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
          <archive>
            <manifest>
              <mainClass>net.jangaroo.jooc.Jooc</mainClass>
              <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
            </manifest>
          </archive>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>retrotranslator-maven-plugin</artifactId>
        <version>1.0-alpha-4</version>
        <executions>
          <execution>
            <phase>process-classes</phase>
            <goals>
              <goal>translate</goal>
            </goals>
            <configuration>
              <filesets>
                <fileset>
                  <directory>${project.build.outputDirectory}</directory>
                  <includes>
                    <include>**/*.class</include>
                  </includes>
                </fileset>
              </filesets>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>

  </build>

  <properties>
    <generated.cup.sources.dir>${project.build.directory}/generated-sources/cup</generated.cup.sources.dir>
    <cup.sources.dir>${basedir}/src/main/cup</cup.sources.dir>
    <!-- the runtime API version the current jooc version relies on, included into the generated *.js files: -->
    <jangaroo.runtime-api.version>0.8.0</jangaroo.runtime-api.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>net.jangaroo</groupId>
      <artifactId>jangaroo-utils</artifactId>
      <version>0.8.3</version>
    </dependency>

    <dependency>
      <groupId>edu.princeton.cup</groupId>
      <artifactId>java-cup</artifactId>
      <version>10k</version>
    </dependency>

    <dependency>
      <groupId>commons-cli</groupId>
      <artifactId>commons-cli</artifactId>
    </dependency>

    <dependency>
      <groupId>ant</groupId>
      <artifactId>ant</artifactId>
      <scope>compile</scope>
    </dependency>

  </dependencies>

</project>
