<?xml version="1.0" encoding="UTF-8"?>
<project name="publish-maven-central-only-pom" xmlns:maven="antlib:org.apache.maven.artifact.ant">

    <description>
      This build file publishes to a maven repository and two ways.  
      1. Publish jar, source-jar, and pom artifacts. 
      2. Publish only the pom artifact.  
      The additional complexity in the implementation is due to a bug in the maven ant tasks version 2.0.8 that 
      prevents deploying to a local file repository on windows.  
    </description>


       <condition property="is.windows" value="windows">
         <os family="windows"/>
       </condition>


        <!-- top level targets -->

        <target name="publish-maven-central-only-pom-artifacts" depends="publish-central-only-pom-windows,publish-central-only-pom-unix">
	</target>

	<target name="publish-maven-central-code-artifacts" depends="publish-central-windows,publish-code-unix">
	</target>


	<target name="publish-maven-milestone-only-pom-artifacts" depends="maven.init">
	  <maven:deploy>
	    <remoteRepository url="s3://${publish.bucket}/maven/bundles/${adjusted.release.type}">
	      <authentication username="${accessKey}" passphrase="${secretKey}"/>
	     </remoteRepository>
	    <pom file="${local.pom.output.file}"/>
	  </maven:deploy>
	</target>

	<target name="publish-maven-milestone-code-artifacts" depends="maven.init">
		<maven:deploy file="${jar.output.file}">
			<remoteRepository url="s3://${publish.bucket}/maven/bundles/${adjusted.release.type}">
				<authentication username="${accessKey}" passphrase="${secretKey}"/>
			</remoteRepository>
			<pom file="${pom.output.file}"/>
			<attach file="${source-jar.output.file}" classifier="sources"/>
		</maven:deploy>	
	</target>


	<target name="install-pom" depends="maven.init">
	  <maven:install>
	    <pom file="${local.pom.output.file}"/>
	  </maven:install>
	</target>

	<!-- Supporting targets -->

        <!-- POM only deployment -->

	<target name="publish-central-only-pom-windows" depends="maven.init" if="is.windows">
	  <maven:deploy>
  	    <!-- Due to http://jira.codehaus.org/browse/MANTTASKS-103 in 2.0.8 on windows, fixed in 2.0.9 -->
            <!-- Assuming using local file, value of variable should be of the form L:\temp\maven-repo-test -->
	    <remoteRepository id="localDisk" url="file:${maven.central.repository}"/>
	    <pom file="${local.pom.output.file}"/>
	  </maven:deploy>
	</target>

	<target name="publish-central-only-pom-unix" depends="maven.init" unless="is.windows">
	  <maven:deploy>
  	    <remoteRepository url="${maven.central.repository}"/>
	    <pom file="${local.pom.output.file}"/>
	  </maven:deploy>
	</target>


        <!-- jar, source-jar and POM deployment -->

	<target name="publish-central-windows" depends="maven.init">
		<maven:deploy file="${jar.output.file}">
 	  	    <!-- Due to http://jira.codehaus.org/browse/MANTTASKS-103 in 2.0.8 on windows, fixed in 2.0.9 -->
                    <!-- Assuming using local file, value of variable should be of the form L:\temp\maven-repo-test -->
			<remoteRepository id="localDisk" url="file:${maven.central.repository}"/>
			<pom file="${local.pom.output.file}"/>
			<attach file="${source-jar.output.file}" classifier="sources"/>
		</maven:deploy>
	</target>


	<target name="publish-code-unix" depends="maven.init" unless="is.windows">
		<maven:deploy file="${jar.output.file}">
  	                <remoteRepository url="${maven.central.repository}"/>
			<pom file="${local.pom.output.file}"/>
			<attach file="${source-jar.output.file}" classifier="sources"/>
		</maven:deploy>
	</target>

</project>