<?xml version="1.0" encoding="UTF-8"?>
<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>

  <!-- ************************************************************* -->
  <!-- *** POM Relationships *************************************** -->
  <!-- ************************************************************* -->

  <parent>
    <groupId>org.nuiton.js</groupId>
    <artifactId>nuiton-js-lib</artifactId>
    <version>1.0.2</version>
  </parent>

  <artifactId>nuiton-js-bootstrap</artifactId>
  <version>3.2.0-1</version>

  <name>Nuiton JS :: Bootstrap</name>
  <description>bootstrap packaging</description>

  <url>http://twitter.github.com/bootstrap/</url>

  <scm>
    <connection>scm:svn:https://svn.nuiton.org/nuiton-js/nuiton-js-bootstrap/tags/nuiton-js-bootstrap-3.2.0-1</connection>
    <developerConnection>scm:svn:https://svn.nuiton.org/nuiton-js/nuiton-js-bootstrap/tags/nuiton-js-bootstrap-3.2.0-1</developerConnection>
    <url>https://forge.nuiton.org/projects/nuiton-js/repository/show/nuiton-js-bootstrap/tags/nuiton-js-bootstrap-3.2.0-1</url>
  </scm>

  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>

  <properties>
    <license.licenseName>apache_v2</license.licenseName>

    <upstreamVersion>3.2.0</upstreamVersion>
    <upstreamUrl>https://github.com/twbs/bootstrap/archive/</upstreamUrl>
    <upstreamFile>v${upstreamVersion}.zip</upstreamFile>
    <destDir>${project.build.outputDirectory}/META-INF/resources/${project.artifactId}</destDir>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.nuiton.js</groupId>
      <artifactId>nuiton-js-test</artifactId>
      <version>1.0.2</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>wagon-maven-plugin</artifactId>
        <executions>
          <execution>
            <phase>process-resources</phase>
            <goals>
              <goal>download-single</goal>
            </goals>
            <configuration>
              <url>${upstreamUrl}</url>
              <fromFile>${upstreamFile}</fromFile>
              <toFile>${project.build.directory}/${project.artifactId}.zip</toFile>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>process-resources</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <echo message="unzip archive" />
                <unzip src="${project.build.directory}/${project.artifactId}.zip" dest="${project.build.directory}" />
                <echo message="moving resources" />
                <copy todir="${destDir}">
                  <fileset dir="${project.build.directory}/bootstrap-${upstreamVersion}/dist" includes="*">
                    <filename regex="angular-?[a-z]*.(js|css)" />
                    <filename name="angular-scenario.js" negate="true" />
                  </fileset>
                  <fileset dir="${project.build.directory}/bootstrap-${upstreamVersion}/dist" includes="css/bootstrap.css" />
                  <fileset dir="${project.build.directory}/bootstrap-${upstreamVersion}/dist" includes="css/bootstrap-theme.css" />
                  <fileset dir="${project.build.directory}/bootstrap-${upstreamVersion}/dist" includes="fonts/*" />
                  <fileset dir="${project.build.directory}/bootstrap-${upstreamVersion}/dist" includes="js/bootstrap.js" />
                </copy>
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
         <groupId>com.google.code.maven-replacer-plugin</groupId>
         <artifactId>replacer</artifactId>
         <version>1.5.3</version>
         <executions>
             <execution>
                 <phase>prepare-package</phase>
                 <goals>
                     <goal>replace</goal>
                 </goals>                   
             </execution>
         </executions>
         <configuration>
             <file>${destDir}/css/bootstrap.css</file>
             <regex>false</regex>
             <replacements>
               <replacement>
                 <token>?#iefix</token>
               </replacement>
               <replacement>
                 <token>#glyphicons_halflingsregular</token>
               </replacement>
             </replacements>
         </configuration>
       </plugin>
    </plugins>
  </build>
</project>