<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>
  <prerequisites>
    <maven>3.0</maven>
  </prerequisites>

  <groupId>de.informaticum</groupId>
  <artifactId>syntaxhighlighter</artifactId>
  <version>3.0.90</version>

  <name>SyntaxHighlighter v3.0.90</name>
  <description>Mavenising the SyntaxHighlighter Project (by Alex Gorbatchev)</description>
  <url>https://github.com/informaticum/syntaxhighlighter-build</url>

  <licenses>
    <license>
      <name>GPLv2</name> 
      <comments>The GPLv2 license can be found within the SyntaxHighlighter archive (${syntaxhighlighter.release.url}) and is provided in this project's root folder too.</comments>
    </license>
    <license>
      <name>MIT</name>
      <comments>The MIT license can be found within the SyntaxHighlighter archive (${syntaxhighlighter.release.url}) and is provided in this project's root folder too.</comments>
    </license>
  </licenses>

  <developers>
    <developer>
      <id>SGA</id>
      <name>Stefan Gasterstädt</name>
      <email>stefan@gasterstädt.de</email>
      <url>http://stefan.gasterstädt.de</url>
    </developer>
  </developers>

  <properties>
    <syntaxhighlighter.release.version>3.0.90</syntaxhighlighter.release.version>
    <syntaxhighlighter.release.tag>v${syntaxhighlighter.release.version}</syntaxhighlighter.release.tag>
    <syntaxhighlighter.release.file>${syntaxhighlighter.release.tag}.zip</syntaxhighlighter.release.file>
    <syntaxhighlighter.release.url>https://github.com/syntaxhighlighter/syntaxhighlighter/archive/${syntaxhighlighter.release.file}</syntaxhighlighter.release.url>
    <syntaxhighlighter.sourcefolder>${project.build.directory}/download/syntaxhighlighter-${syntaxhighlighter.release.version}</syntaxhighlighter.sourcefolder>
    <syntaxhighlighter.dockerfolder>src/main/docker/syntaxhighlighter</syntaxhighlighter.dockerfolder>
    <syntaxhighlighter.build.folder>/home/bob/workspace/syntaxhighlighter</syntaxhighlighter.build.folder>
    <syntaxhighlighter.build.script>build-syntaxhighlighter-${syntaxhighlighter.release.tag}.sh</syntaxhighlighter.build.script>
    <docker.showLogs>true</docker.showLogs>
  </properties>

  <scm>
    <connection>scm:git:git@github.com:informaticum/syntaxhighlighter.git</connection>
    <developerConnection>scm:git:git@github.com:informaticum/syntaxhighlighter.git</developerConnection>
    <url>https://github.com/informaticum/syntaxhighlighter-build.git</url>
    <tag>HEAD</tag>
  </scm>

  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

  <profiles>
    <profile>
      <id>gpg-signing</id>
      <activation>
        <property>
          <name>gpg.keyname</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>download-syntaxhighlighter</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <mkdir dir="${syntaxhighlighter.sourcefolder}" />
                <get src="${syntaxhighlighter.release.url}"
                     dest="${syntaxhighlighter.sourcefolder}/" />
                <unzip src="${syntaxhighlighter.sourcefolder}/${syntaxhighlighter.release.file}"
                       dest="${syntaxhighlighter.sourcefolder}">
                  <cutdirsmapper dirs="1" />
                </unzip>
                <copy file="${syntaxhighlighter.dockerfolder}/${syntaxhighlighter.build.script}"
                      todir="${syntaxhighlighter.sourcefolder}" />
              </target>
            </configuration>
          </execution>
          <execution>
            <id>provide-syntaxhighlighter</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <copy todir="${project.build.outputDirectory}/syntaxhighlighter/${syntaxhighlighter.release.version}">
                  <fileset dir="${syntaxhighlighter.sourcefolder}/pkg/" />
                  <fileset dir="${syntaxhighlighter.sourcefolder}/" includes="GPL-LICENSE MIT-LICENSE" />
                </copy>
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>io.fabric8</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <version>0.20.1</version>
        <executions>
          <execution>
            <id>syntaxhighlighter</id>
            <phase>process-resources</phase>
            <goals>
              <goal>build</goal>
              <goal>start</goal>
            </goals>
            <configuration>
              <verbose>true</verbose>
              <images>
                <image>
                  <name>node-build-env</name>
                  <build>
                    <dockerFileDir>${project.basedir}/${syntaxhighlighter.dockerfolder}</dockerFileDir>
                  </build>
                  <run>
                    <hostname>build-host</hostname>
                      <volumes>
                      <bind>${syntaxhighlighter.sourcefolder}:${syntaxhighlighter.build.folder}</bind>
                    </volumes>
                    <log>
                      <enabled>true</enabled>
                    </log>
                    <workingDir>${syntaxhighlighter.build.folder}</workingDir>
                    <cmd>bash ${syntaxhighlighter.build.script}</cmd>
                    <wait>
                      <log>Done, without errors</log>
                      <time>120000</time>
                    </wait>
                  </run>
                </image>
              </images>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <!-- MAVEN LIFECYCLE: default -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.8</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-gpg-plugin</artifactId>
          <version>1.6</version>
          <executions>
            <execution>
              <id>sign-artifacts</id>
              <phase>verify</phase>
              <goals>
                <goal>sign</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
          <configuration>
            <forceCreation>true</forceCreation>
            <archive>
              <manifest>
                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
              </manifest>
            </archive>
          </configuration>
        </plugin>
        <!-- MAVEN LIFECYCLE: clean -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.0.0</version>
          <configuration>
            <failOnError>true</failOnError>
          </configuration>
        </plugin>
        <!-- MAVEN LIFECYCLE: site -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-site-plugin</artifactId>
          <version>3.5.1</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

</project>
