<?xml version="1.0" encoding="UTF-8"?>
<!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
-->

<!-- This pom serves as the the Apache UIMA Addons common parent pom,
     and may include overrides to the project-wide parent-pom.
     Over time, things in this pom which apply to
     other projects within UIMA are migrated to the
     project-wide parent pom.
 -->

<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.apache.uima</groupId>
    <artifactId>parent-pom</artifactId>
    <version>2</version>
    <relativePath />
  </parent>

  <groupId>org.apache.uima</groupId>
  <artifactId>uima-addons-parent</artifactId>
  <packaging>pom</packaging>
  <version>2.3.1</version>
  <name>UIMA-AddOns: ${project.artifactId}</name>
  <description>The common parent pom for uima-addons</description>
  <url>${uimaWebsiteUrl}</url>

  <issueManagement>
    <system>Jira</system>
    <!-- the form of the url is from http://maven.apache.org/plugins/maven-changes-plugin/usage.html -->
    <!--url>https://issues.apache.org/jira/BrowseProject.jspa?projectId=12310570</url-->
    <url>https://issues.apache.org/jira/browse/UIMA?projectId=12310570</url>
        
  </issueManagement>

  <scm>
    <connection>
      scm:svn:http://svn.apache.org/repos/asf/uima/addons/tags/uima-addons-2.3.1-rc5/uima-addons-parent
    </connection>
    <developerConnection>
      scm:svn:https://svn.apache.org/repos/asf/uima/addons/tags/uima-addons-2.3.1-rc5/uima-addons-parent
    </developerConnection>
    <url>
      http://svn.apache.org/viewvc/uima/sandbox/addons/uima-addons-parent/tags/uima-addons-2.3.1-rc5/uima-addons-parent
    </url>
  </scm>

  <!-- The repositories section is duplicated from
       the parent pom one, and adds the Apache Snapshot Nexus repository
       where UIMA snapshots are deployed.  This is needed if for instance,
       a project depends on some new SNAPSHOT level of a build tool,
       where the users hasn't checked out the build tooling.

       This allows maven to find the snapshots when looking for the parent of
       this pom -->
  <repositories>
    <repository>
      <id>eclipsePlugins</id>
      <name>Eclipse components</name>
      <layout>default</layout>
      <url>http://repo1.maven.org/eclipse</url>

      <releases>
        <updatePolicy>never</updatePolicy>
        <checksumPolicy>fail</checksumPolicy>
      </releases>

      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>

    <!-- modify central repository access:
         Turn on checksum checking-->
    <repository>
      <id>central</id>
      <name>Maven Repository Switchboard</name>
      <layout>default</layout>
      <url>http://repo1.maven.org/maven2</url>

      <releases>
        <enabled>true</enabled>
        <checksumPolicy>fail</checksumPolicy>
        <updatePolicy>never</updatePolicy>
      </releases>

      <snapshots>
        <enabled>false</enabled>
      </snapshots>

    </repository>
  </repositories>
  
  <pluginRepositories>
    <pluginRepository>
      <id>apache.snapshots.plugins</id>
      <name>Apache Snapshot Repository - Maven plugins</name>
      <url>http://repository.apache.org/snapshots</url>
      <layout>default</layout>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
        <checksumPolicy>fail</checksumPolicy>
        <updatePolicy>never</updatePolicy>
      </snapshots>
    </pluginRepository>
  
  </pluginRepositories>

  <properties>
    <uimaScmRoot>addons</uimaScmRoot>
    <uimaScmProject>${project.artifactId}</uimaScmProject>
    <uimaDependencyVersion>2.3.1</uimaDependencyVersion>   
  </properties>

  <build>
    <!-- temp fix until parent-pom-3 is released -->
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>2.7</version>
          <configuration>
            <source>5</source> <!-- needed to do Enums -->
            <encoding>UTF-8</encoding>
            <!-- if next is omitted, causes all projects in reactor that don't
                     already have full javadocs built, to have them built -->
            <detectOfflineLinks>false</detectOfflineLinks>
            <quiet>true</quiet>            
            <!-- fix java api links because Oracle bought Sun -->
            <javaApiLinks>
              <property>
                <name>api_1.5</name>
                <value>http://download.oracle.com/javase/1.5.0/docs/api/</value>
              </property>
            </javaApiLinks>
            <!-- identify tags we use so we don't get warning messages for them -->
            <tags>
              <tag>
                <name>generated</name>
                <placement>X</placement>
              </tag>
              <tag>
                <name>ordered</name>
                <placement>X</placement>
              </tag>
              <tag>
                <name>modifiable</name>
                <placement>X</placement>
              </tag>
              <tag>
                <name>model</name>
                <placement>X</placement>
              </tag>
              <tag>
                <name>pre</name>
                <placement>X</placement>
              </tag>
            </tags>                          
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <configuration>
            <mavenExecutorId>forked-path</mavenExecutorId>
            <tagBase>https://svn.apache.org/repos/asf/uima/sandbox/tags/</tagBase>
          </configuration>
        </plugin>

      </plugins>
    </pluginManagement>
    
    <plugins>
      

      
    </plugins>
  </build>
  
  
  <profiles>
    
    <!-- ************************************ -->
    <!-- * Build single-project zip/tar     * -->
    <!-- ************************************ -->

    <profile>
      <id>single project common and binary build</id>
      <activation>
        <file>
          <exists>marker-file-identifying-single-project</exists>
        </file>
      </activation>
      <build>
        <plugins>

          <!-- ********************************************* -->
          <!-- * Common Build                                -->
          <!-- *   *** FOR addons only ***                   -->
          <!-- ********************************************* -->
          <!-- *   Base Jar is built,                        --> 
          <!-- *     has no dependencies included            -->
          <!-- *     has basic LICENSE/NOTICE files          -->
          <!-- *   Base augmented dir built                  -->
          <!-- *     has Base Jar in lib/                    -->
          <!-- *     has dependencies in lib/                -->
          <!-- *     has other things that go into PEAR      -->
          <!-- *       except the pear install.xml           -->
          <!-- *     has augmented LICENSE/NOTICE files      -->
          <!-- *                                             -->
          <!-- *     This base is reused to make packages:   -->
          <!-- *       PEAR - adds the install.xml           -->
          <!-- *            - actually, the PEAR builder     -->
          <!-- *              will redo the copies, itself   -->
          <!-- *       OSGi - adds the OSGi manifest         -->
          <!-- *            - removes the doc, javadocs      -->
          <!-- *       individual zip/tar                    -->
          <!-- *       addons aggregate binary zip/tar       -->
          <!-- ********************************************* -->
              
          <!-- Build  base -->
            <!-- populate the lib dir with all needed dependencies
                 that will be distributed with this component
                 
                 NOTE: TRANSITIVE DEPENDENIES ARE NOT INCLUDED
                       ANYTHING YOU WANT INCLUDED IN THE JAR 
                       PLEASE LIST EXPLICITLY AND MODIFY THE LICENSE/NOTICE
                       APPROPRIATELY
                  
                 Runs during process-resources -->
                         
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <!-- Copy the dependencies to the target/base-bin/lib folder -->
              <execution>
                <id>copy dependencies to base-bin/lib</id>
                <goals><goal>copy-dependencies</goal></goals>
                <phase>process-resources</phase>
                <configuration>
                  <outputDirectory>${project.build.directory}/base-bin/lib</outputDirectory>
                  <includeScope>runtime</includeScope>
                  <excludeTransitive>true</excludeTransitive>
                </configuration>
              </execution>
            </executions>
          </plugin>
          
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
              
              <!-- add directories if they exist -->
              <execution>
                <id>copy standard dirs and files to base-bin</id>
                <goals><goal>copy-resources</goal></goals>
                <phase>process-resources</phase>  <!-- required -->
                <configuration>
                  <outputDirectory>${project.build.directory}/base-bin</outputDirectory>
                  <resources>
                    <resource>
                      <directory>.</directory>
                      <includes>
                        <include>desc/**</include>
                        <include>conf/**</include>
                        <include>data/**</include>
                        <include>doc/**</include>
                        <include>docs/**</include>
                        <include>resources/**</include>
                        <include>bin/**</include>
                        <include>LICENSE*</include>
                        <include>NOTICE*</include>
                        <include>README*</include>
                        <include>readme*</include>
                        <include>RELEASE_NOTES*</include>
                        <include>ReleaseNotes*</include>
                        <include>issuesFixed/**</include> 
                      </includes>
                    </resource>
                    <resource>
                      <directory>src/main/readme</directory>
                    </resource>
                  </resources>
                </configuration>
              </execution>
              
              
              <!-- copy generated Jar to base-bin/lib spot -->
              <execution>
                <id>copy standard target jar to base-bin/lib</id>
                <goals><goal>copy-resources</goal></goals>
                <phase>pre-integration-test</phase>  <!-- a phase after jar -->
                <configuration>
                  <outputDirectory>${project.build.directory}/base-bin/lib</outputDirectory>
                  <resources>
                    <resource>
                      <directory>${project.build.directory}</directory>
                      <includes><include>*.jar</include></includes>
                      <excludes>
                        <exclude>*-sources.jar</exclude>
                        <exclude>*-osgi.jar</exclude>
                      </excludes>     
                    </resource>
                  </resources>
                </configuration>
              </execution>
              
              <!-- copy generated docbook artifacts -->        
              <execution>
                <id>copy generated docbook artifacts to base-bin/doc folder</id>
                <goals><goal>copy-resources</goal></goals>
                <phase>pre-integration-test</phase>  <!-- a phase after docbkx (package) phase -->
                <configuration>
                  <outputDirectory>${project.build.directory}/base-bin/doc</outputDirectory>
                  <resources>
                    <resource>
                      <directory>${project.build.directory}/site/d</directory>
                    </resource>
                  </resources>
                </configuration>
              </execution>          
            </executions>
          </plugin>
              
          <!-- override the parent-pom with same id -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
              <execution>
                <id>binary-release</id> <!-- is "classifier" - match maven convention -->
                <configuration>
                  <runOnlyAtExecutionRoot>true</runOnlyAtExecutionRoot>
                  <descriptorRefs>
                    <descriptorRef>
                      uima-single-project-bin2
                    </descriptorRef>
                  </descriptorRefs>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      <properties>
        <uimaBuildResourcesVersion>2</uimaBuildResourcesVersion> 
      </properties>
    </profile>

    <!-- ********************************** -->
    <!-- *   Build OSGi bundle            * -->
    <!-- ********************************** -->     
    <profile>
      <id>build OSGi bundle for annotator</id>
      <activation>
        <file>
          <exists>marker-file-identifying-osgi-project-ignored-for-2.3.1</exists>
        </file>
      </activation>
           
      <build>  
        <plugins> 
        
          <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
                            
              <!-- copy the base-bin dir to the osgi dir -->
              <execution>
                <id>Copy base-bin to osgi</id>
                <goals><goal>copy-resources</goal></goals>
                <phase>integration-test</phase>
                <configuration>
                  <outputDirectory>${project.build.directory}/osgi</outputDirectory>
                  <resources>
                    <resource>
                      <directory>${project.build.directory}/base-bin</directory>
                      <includes><include>**</include></includes>
                      <excludes>
                        <exclude>doc/**</exclude>
                        <exclude>docs/**</exclude>
                        <exclude>**/*-javadoc.jar</exclude>
                        <exclude>issuesFixed/**</exclude>
                      </excludes>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>
          
          <!-- copy any uima dependencies needed to osgi/lib
               beyond what is done for the common build.
               NOTE: can't just add dependencies, because
                 a) local projects override scope to "provided" and
                 b) this would result in the jars being copied for
                    the common build -->
         
          <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>Copy uima dependencies to osgi/lib</id>
                <goals><goal>copy</goal></goals>
		            <phase>process-resources</phase>
		            <configuration>
		              <outputDirectory>${project.build.directory}/osgi/lib</outputDirectory>
		              <artifactItems>
		                <artifactItem>
		                  <groupId>org.apache.uima</groupId>
                      <artifactId>uimaj-core</artifactId>
                      <version>${uimaDependencyVersion}</version>
		                </artifactItem>
		              </artifactItems>
		            </configuration>
              </execution>
            </executions>
          </plugin> 
          
          <plugin>
            <groupId>org.apache.felix</groupId>
	          <artifactId>maven-bundle-plugin</artifactId>
	          <!-- 2.3.5 accidentally required Java 6 -->
            <!-- 2.3.4 doesn't put in the version string for the export-packages-->
            <version>2.1.0</version>
	          <executions>
	            <execution>
	              <id>uima-bundle</id>
	              <phase>integration-test</phase>
	              <goals><goal>manifest</goal></goals>
	              <configuration>
	                <buildDirectory>${project.build.directory}/osgi</buildDirectory>
	                <manifestLocation>${project.build.directory}/osgi/META-INF</manifestLocation>
	                <instructions>
	                  <Import-Package>org.apache.log.*;resolution:=optional</Import-Package>
	                  <Embed-Dependency>*;scope=compile;</Embed-Dependency>
	                  <Embed-Directory>lib</Embed-Directory>
	                  <Bundle-RequiredExecutionEnvironment>J2SE-1.5</Bundle-RequiredExecutionEnvironment>
	                  <Eclipse-ExtensibleAPI>true</Eclipse-ExtensibleAPI>
                    <Bundle-ClassPath>.,lib/${project.build.finalName}.jar,{maven-dependencies},lib/uimaj-core-${uimaDependencyVersion}.jar</Bundle-ClassPath>
                    <Include-Resource>
                      {maven-resources}, {maven-dependencies},
                      lib/uimaj-core-${uimaDependencyVersion}.jar=${settings.localRepository}/org/apache/uima/uimaj-core/${uimaDependencyVersion}/uimaj-core-${uimaDependencyVersion}.jar
                    </Include-Resource>
	                  <Bundle-Version>${parsedVersion.osgiVersion}</Bundle-Version>
	                  <Bundle-SymbolicName>${project.groupId}.${project.artifactId};singleton:=true</Bundle-SymbolicName>
	                </instructions>
	              </configuration>
	            </execution>
	          </executions>

	        </plugin>

          <!-- Run JAR to create OSGi Jar -->          
          <plugin>
		        <artifactId>maven-jar-plugin</artifactId>
		        <executions>
		          <execution>
		            <id>Create OSGi Jar</id>
		            <goals><goal>jar</goal></goals>
		            <phase>integration-test</phase> <!-- after above build step -->
		            <configuration>
		              <finalName>${project.groupId}.${project.artifactId}_${parsedVersion.osgiVersion}</finalName>
		              <classifier>osgi</classifier>
		              <classesDirectory>${project.build.directory}/osgi</classesDirectory>
		              <archive>
		                <manifestFile>${project.build.directory}/osgi/META-INF/MANIFEST.MF</manifestFile>
		              </archive>
		            </configuration>		            
		          </execution>
		        </executions>
		      </plugin>
                             
        </plugins>
      </build>             
    </profile>
    
    <!-- ********************************** -->
    <!-- *   Build Standard PEAR          * -->
    <!-- ********************************** -->
    <profile>
      <id>build standard PEAR</id>
      <activation>
        <file>
          <exists>marker-file-identifying-standard-pear</exists>
        </file>
      </activation>
      <build>
        
        <plugins>  
        
          <!-- turn off parent pom build parts not used -->
          <!-- all this will go away when next parent pom released -->
          
          <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>copy dependencies to lib</id>
                <phase />
              </execution>
            </executions>
          </plugin>
          
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
            
              <execution>
                <id>copy generated docbook artifacts to pearPackaging/doc folder</id>
                <phase />
              </execution>
              
              <execution>
                <id>copy standard sandbox target jar to pearPackaging/lib</id>
                <phase />
              </execution>
              
              <execution>
                <id>Copy Pear Lic/Not/Readme/Relnotes</id>
                <phase />
              </execution>             
                            
              <!-- copy the base-bin dir to the pearPackaging dir -->
              <execution>
                <id>Copy base-bin to pearPackaging</id>
                <goals><goal>copy-resources</goal></goals>
                <phase>integration-test</phase> <!-- after first copies from jar/docbk pkg -->
                <configuration>
                  <outputDirectory>${project.build.directory}/pearPackaging</outputDirectory>
                  <resources>
                    <resource>
                      <directory>${project.build.directory}/base-bin</directory>
                      <includes><include>**</include></includes>
                      <excludes>
                        <exclude>**/*-javadoc.jar</exclude>
                      </excludes>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>
          
          <!-- build the PEAR -->
          <plugin>
            <groupId>org.apache.uima</groupId>
            <artifactId>PearPackagingMavenPlugin</artifactId>
            <version>2.3.1</version>
            <extensions>true</extensions>        
            <executions>
              <execution>
                <id>build uima annnotator Pear</id>
                <goals><goal>package</goal></goals>
                   <!-- needs to run after the jar is built
                        after docbooks are packaged and copied to pearPackaging/doc folder -->
                <phase>integration-test</phase>  <!-- after first copies from jar/docbk pkg -->
                <configuration> 
                  <datapath>$main_root/resources</datapath>
                  <componentId>${project.artifactId}</componentId>
                  <mainComponentDesc>${pearMainDescriptor}</mainComponentDesc>
                </configuration>
              </execution>
            </executions>
          </plugin>
          
          <!-- after PEAR is built -->
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
		          <execution>
		            <id>attach-pear-artifact</id>
		            <phase>post-integration-test</phase>  
		            <goals><goal>attach-artifact</goal></goals>
		            <configuration>
		              <artifacts>
		                <artifact>
		                  <file>${project.build.directory}/${project.artifactId}.pear</file>
		                  <type>pear</type>
		                </artifact>
		              </artifacts>
		            </configuration>
		          </execution>
		        </executions>
          </plugin>
                         
        </plugins>
        
      </build>
    </profile>
    
  </profiles>
</project>
