<!--
The MIT License

Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Stephen Connolly, Tom Huybrechts, Yahoo! Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->

<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>

  <parent>
    <groupId>org.jenkins-ci.main</groupId>
    <artifactId>pom</artifactId>
    <version>1.596.1</version>
    <relativePath>../pom.xml</relativePath>
  </parent>

  <artifactId>jenkins-war</artifactId>
  <packaging>war</packaging>

  <name>Jenkins war</name>
  <description>
    Creates a war file. Also includes additional static web resources, such as images, CSS, JavaScript, and
    some HTML files.
  </description>

  <properties>
    <JENKINS_HOME>${basedir}/work</JENKINS_HOME>
    <contextPath>/jenkins</contextPath><!-- context path during test -->
    <port>8080</port><!-- HTTP listener port -->
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.jenkins-ci</groupId>
      <artifactId>executable-war</artifactId>
      <version>1.29</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.jenkins-ci.main</groupId>
      <artifactId>jenkins-core</artifactId>
      <version>${project.version}</version>
      <exclusions>
        <!--
          jars that are not needed in war. most of the exclusions should happen in the core, to make IDEs happy, not here.
        -->
        <exclusion>
          <groupId>javax.servlet</groupId>
          <artifactId>servlet-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>javax.servlet</groupId>
          <artifactId>jsp-api</artifactId>
        </exclusion>
        <!-- Stapler 1.195 fails to declare this as optional, and the 1.1 version lacks a license: -->
        <exclusion>
          <artifactId>metainf-services</artifactId>
          <groupId>org.kohsuke.metainf-services</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <!-- declare this in reactors, so i can use now directly : mvn install -pl war -am to get the war  -->
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>maven-plugin</artifactId>
      <version>${maven-plugin.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>remoting</artifactId>
      <!-- specified in the parent -->
    </dependency>    
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>cli</artifactId>
      <classifier>jar-with-dependencies</classifier>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <!--
        not actually used by test but used by dependency plugin to include it inside the war.
      -->
      <groupId>org.jenkins-ci</groupId>
      <artifactId>winstone</artifactId>
      <version>2.8</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.modules</groupId>
      <artifactId>instance-identity</artifactId>
      <version>1.4</version>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.modules</groupId>
      <artifactId>ssh-cli-auth</artifactId>
      <version>1.2</version>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.modules</groupId>
      <artifactId>slave-installer</artifactId>
      <version>1.5</version>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.modules</groupId>
      <artifactId>windows-slave-installer</artifactId>
      <version>1.4</version>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.modules</groupId>
      <artifactId>launchd-slave-installer</artifactId>
      <version>1.2</version>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.modules</groupId>
      <artifactId>upstart-slave-installer</artifactId>
      <version>1.1</version>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.modules</groupId>
      <artifactId>systemd-slave-installer</artifactId>
      <version>1.1</version>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.modules</groupId>
      <artifactId>sshd</artifactId>
      <version>1.6</version>
    </dependency>
    <dependency>
      <!--
        We bundle slf4j binding since we got some components (sshd for example)
        that uses slf4j.

        The problem with not shipping any binding in the war is that if the
        servlet container does use slf4j in itself, then we got a classloader
        constraint violation (see JENKINS-12334) as we try to load StaticLoggerBinder
        which resides in the binding jar (this jar would be from container implementation,
        which relies on slf4j api in the container, when we have our own slf4j API jar
        statically depending on the binding jar.)

        We also get tickets like JENKINS-12650 for not reporting logs at all
        (although this is a non-fatal problem.)

        The downside of adding a jar is that we can potentially get "multiple binding jar"
        warning like http://www.slf4j.org/codes.html, but that's at least non-fatal.
      -->
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-jdk14</artifactId>
    </dependency>


    <!-- offline profiler API when we need it -->

    <!--dependency
      <groupId>com.yourkit.api</groupId>
      <artifactId>yjp</artifactId>
      <version>dontcare</version>
      <scope>system</scope>
      <systemPath>/usr/local/yjp/lib/yjp.jar</systemPath>
    </dependency-->
  </dependencies>

  <build>
    <finalName>jenkins</finalName>
    <plugins>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <!-- version specified in grandparent pom -->
        <configuration>
          <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
          <!-- for putting Main-Class into war -->
          <archive>
            <manifest>
              <mainClass>Main</mainClass>
            </manifest>
            <manifestEntries>
              <Implementation-Version>${project.version}</Implementation-Version>
              <Hudson-Version>1.395</Hudson-Version>
              <Jenkins-Version>${project.version}</Jenkins-Version>
            </manifestEntries>
          </archive>
          <!--outputFileNameMapping>@{artifactId}@.@{extension}@</outputFileNameMapping-->
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <!-- version specified in grandparent pom -->
        <executions>
          <execution>
            <id>list-dependencies</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>list</goal>
            </goals>
            <configuration>
              <outputFile>${project.build.outputDirectory}/dependencies.txt</outputFile>
            </configuration>
          </execution>
          <execution>
            <!-- put executable war header -->
            <id>executable-war-header</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <includeGroupIds>org.jenkins-ci</includeGroupIds>
              <includeArtifactIds>executable-war</includeArtifactIds>
              <includeScope>provided</includeScope>
              <includes>**/*.class</includes>
              <outputDirectory>${project.build.directory}/${project.build.finalName}</outputDirectory>
            </configuration>
          </execution>
          <execution>
            <id>resgen</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <artifactItems>
                <!-- dependencies that goes to unusual locations -->
                <artifactItem>
                  <groupId>${project.groupId}</groupId>
                  <artifactId>remoting</artifactId>
                  <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF</outputDirectory>
                  <destFileName>remoting.jar</destFileName>
                </artifactItem>
                <artifactItem>
                  <groupId>${project.groupId}</groupId>
                  <artifactId>remoting</artifactId>
                  <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF</outputDirectory>
                  <destFileName>slave.jar</destFileName>
                </artifactItem>
                <artifactItem>
                  <groupId>${project.groupId}</groupId>
                  <artifactId>cli</artifactId>
                  <classifier>jar-with-dependencies</classifier>
                  <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF</outputDirectory>
                  <destFileName>jenkins-cli.jar</destFileName>
                </artifactItem>
                <artifactItem>
                  <groupId>org.jenkins-ci</groupId>
                  <artifactId>winstone</artifactId>
                  <outputDirectory>${project.build.directory}/${project.build.finalName}</outputDirectory>
                  <destFileName>winstone.jar</destFileName>
                </artifactItem>
                <!-- bundled plugins -->
                <artifactItem>
                  <groupId>${project.groupId}</groupId>
                  <artifactId>maven-plugin</artifactId>
                  <type>hpi</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.jenkins-ci.plugins</groupId>
                  <artifactId>ssh-slaves</artifactId>
                  <version>1.9</version>
                  <type>hpi</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.jenkins-ci.plugins</groupId>
                  <artifactId>credentials</artifactId>
                  <version>1.18</version>
                  <type>hpi</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.jenkins-ci.plugins</groupId>
                  <artifactId>ssh-credentials</artifactId>
                  <version>1.10</version>
                  <type>hpi</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.jenkins-ci.plugins</groupId>
                  <artifactId>subversion</artifactId>
                  <version>1.54</version>
                  <type>hpi</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.jenkins-ci.plugins</groupId>
                  <artifactId>cvs</artifactId>
                  <version>2.11</version>
                  <type>hpi</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.jenkins-ci.plugins</groupId>
                  <artifactId>ant</artifactId>
                  <version>1.2</version>
                  <type>hpi</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.jenkins-ci.plugins</groupId>
                  <artifactId>javadoc</artifactId>
                  <version>1.1</version>
                  <type>hpi</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.jenkins-ci.plugins</groupId>
                  <artifactId>translation</artifactId>
                  <version>1.10</version>
                  <type>hpi</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.jenkins-ci.plugins</groupId>
                  <artifactId>external-monitor-job</artifactId>
                  <version>1.4</version>
                  <type>hpi</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.jenkins-ci.plugins</groupId>
                  <artifactId>ldap</artifactId>
                  <version>1.6</version>
                  <type>hpi</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.jenkins-ci.plugins</groupId>
                  <artifactId>pam-auth</artifactId>
                  <version>1.1</version>
                  <type>hpi</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.jenkins-ci.plugins</groupId>
                  <artifactId>mailer</artifactId>
                  <version>1.11</version>
                  <type>hpi</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.jenkins-ci.plugins</groupId>
                  <artifactId>matrix-auth</artifactId>
                  <version>1.1</version>
                  <type>hpi</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.jenkins-ci.plugins</groupId>
                  <artifactId>windows-slaves</artifactId>
                  <version>1.0</version>
                  <type>hpi</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.jenkins-ci.plugins</groupId>
                  <artifactId>antisamy-markup-formatter</artifactId>
                  <version>1.1</version>
                  <type>hpi</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.jenkins-ci.plugins</groupId>
                  <artifactId>matrix-project</artifactId>
                  <version>${matrix-project.version}</version>
                  <type>hpi</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.jenkins-ci.plugins</groupId>
                  <artifactId>script-security</artifactId>
                  <version>1.13</version>
                  <type>hpi</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.jenkins-ci.plugins</groupId>
                  <artifactId>junit</artifactId>
                  <version>1.2-beta-4</version>
                  <type>hpi</type>
                </artifactItem>
              </artifactItems>
              <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/plugins</outputDirectory>
              <stripVersion>true</stripVersion>
              <overWriteIfNewer>true</overWriteIfNewer>
              <overWriteReleases>false</overWriteReleases>
              <overWriteSnapshots>true</overWriteSnapshots>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <!-- deploy the war as a jar, so that the tests can pull this into the classpath -->
            <id>deploy-war-for-test</id>
            <phase>package</phase>
            <goals>
              <goal>attach-artifact</goal>
            </goals>
            <configuration>
              <artifacts>
                <artifact>
                  <file>${project.build.directory}/${project.build.finalName}.war</file>
                  <type>jar</type>
                  <classifier>war-for-test</classifier>
                </artifact>
              </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin><!-- generate licenses.xml -->
        <groupId>com.cloudbees</groupId>
        <artifactId>maven-license-plugin</artifactId>
        <!-- version specified in grandparent pom -->
        <configuration>
          <generateLicenseXml>${project.build.outputDirectory}/META-INF/licenses.xml</generateLicenseXml>
          <generateLicenseHtml>${project.build.outputDirectory}/META-INF/licenses.html</generateLicenseHtml>
          <attach>true</attach>
          <inlineScript>
            filter {
                // add Winstone since we are bundling it.
                def d = project.dependencies.find { it.artifactId=="winstone" };
                def a = mojo.artifactFactory.createProjectArtifact(d.groupId,d.artifactId,d.version);
                def p = mojo.projectBuilder.buildFromRepository(a, project.getRemoteArtifactRepositories(), mojo.localRepository)
                models.put(a,p);
            }
          </inlineScript>
        </configuration>
      </plugin>
      <plugin>
        <!-- this is really just a patched version of maven-jetty-plugin to workaround issue #932 -->
        <groupId>org.jenkins-ci.tools</groupId>
        <artifactId>maven-jenkins-dev-plugin</artifactId>
        <!-- version specified in grandparent pom -->
        <configuration>
          <!--
            Reload webapp when you hit ENTER. (See JETTY-282 for more)
          -->
          <reload>manual</reload>
          <connectors>
            <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                <port>${port}</port>
            </connector>
          </connectors>
          <additionalClassesDirectories>
            <!-- load resoures straight from source -->
            <additionalClassesDirectory>../core/src/main/resources</additionalClassesDirectory>
            
            <!--
              read directly from core module's output directory,
              so that changes are picked up right away without running mvn.
            -->
            <additionalClassesDirectory>../core/target/classes</additionalClassesDirectory>
          </additionalClassesDirectories>
          <loginServices>
            <loginService implementation="org.eclipse.jetty.security.HashLoginService">
              <name>default</name>
              <config>${basedir}/src/realm.properties</config>
            </loginService>
          </loginServices>
          <systemProperties>
            <systemProperty>
              <name>JENKINS_HOME</name>
              <value>${JENKINS_HOME}</value>
            </systemProperty>
            <systemProperty>
              <!-- always reload views during debugging -->
              <name>stapler.jelly.noCache</name>
              <value>true</value>
            </systemProperty>
            <systemProperty>
              <!-- show the stapler evaluation during execution -->
              <name>stapler.trace</name>
              <value>true</value>
            </systemProperty>
            <systemProperty>
              <!-- always reload scripts during debugging -->
              <name>hudson.script.noCache</name>
              <value>true</value>
            </systemProperty>
            <systemProperty>
              <!-- load view resources from the source directly, again for real time change -->
              <name>stapler.resourcePath</name>
              <value>
                  ../core/src/main/resources;
              </value>
            </systemProperty>
            <systemProperty>
              <!-- enable the plugins in main by default -->
              <name>hudson.bundled.plugins</name>
              <value><!-- run "mvn install" once will generate the.hpl -->
                  ${project.build.directory}/${project.build.finalName}/WEB-INF/plugins/*.hpi
              </value>
            </systemProperty>
            <systemProperty>
              <!-- stat collection pointless -->
              <name>hudson.model.UsageStatistics.disabled</name>
              <value>true</value>
            </systemProperty>
            <systemProperty>
              <name>hudson.Main.development</name>
              <value>true</value>
            </systemProperty>
            <systemProperty>
              <!-- this adds 3 sec to the shutdown, and most likely pointless, too -->
              <name>hudson.DNSMultiCast.disabled</name>
              <value>true</value>
            </systemProperty>
          </systemProperties>
          <webApp>
            <contextPath>${contextPath}</contextPath>
            <configurationDiscovered>false</configurationDiscovered>
          </webApp>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <!-- profile for creating Jenkins IPS package -->
      <id>ips</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.jvnet.updatecenter2</groupId>
            <artifactId>maven-makepkgs-plugin</artifactId>
            <!-- version specified in grandparent pom -->
            <executions>
              <execution>
                <goals>
                  <goal>package</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <python>python2.5</python>
              <proto>../ips/proto.py</proto>
              <attach>false</attach>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <!-- sign war -->
      <id>sign</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-jarsigner-plugin</artifactId>
            <executions>
              <execution>
                <id>signWar</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
                <configuration>
                  <archive>${project.build.directory}/${project.build.finalName}.war</archive>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <!-- profile for running Grunt and optimize static resources -->
      <id>grunt</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>install</id>
                            <phase>validate</phase>
                            <goals>
                                <goal>exec</goal>
                            </goals>
                            <configuration>
                                <executable>npm</executable>
                                <arguments>
                                    <argument>install</argument>
                                </arguments>
                            </configuration>
                        </execution>
                        <execution>
                            <id>grunt</id>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>exec</goal>
                            </goals>
                            <configuration>
                                <executable>grunt</executable>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
  </profiles>
</project>
