summaryrefslogtreecommitdiff
path: root/src/build/maven/maven-deploy.xml
blob: 5146abd830f8545fdfcba3f638e7f83a4600fcb1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?xml version="1.0" encoding="UTF-8"?>

<project name="sabbus-maven-deploy" xmlns:artifact="urn:maven-artifact-ant">

  <description>
    SuperSabbus extension for deploying a distribution to Maven. THIS FILE IS MEANT TO BE RUN STANDALONE IN THE MAVEN "distpack" DIRECTORY
  </description>

  <macrodef name="deploy-remote">
    <attribute name="jar" default=""/>
    <attribute name="pom"/>
    <element name="artifacts" implicit="true" optional="true"/>
    <sequential>
      <artifact:deploy file="@{jar}" settingsFile="${settings.file}">
        <artifact:remoteRepository url="${remote.repository}" id="${repository.credentials.id}" />
        <artifact:pom refid="@{pom}" />
        <artifacts/>
      </artifact:deploy>
    </sequential>
  </macrodef>

  <macrodef name="deploy-local">
    <attribute name="jar" default=""/>
    <attribute name="pom"/>
    <element name="artifacts" implicit="true" optional="true"/>
    <sequential>
    <artifact:install file="@{jar}">
      <artifact:localRepository path="${local.repository}"  id="${repository.credentials.id}" />
      <artifact:pom refid="@{pom}" />
      <artifacts/>
    </artifact:install>
    </sequential>
  </macrodef>

  <macrodef name="deploy-to">
    <attribute name="jar" default=""/>
    <attribute name="pom"/>
    <attribute name="local"/>
    <element name="artifacts" implicit="true" optional="true"/>
    <sequential>
      <if><equals arg1="@{local}" arg2="true"/><then>
        <deploy-local jar="@{jar}" pom="@{pom}"> <artifacts/> </deploy-local>
      </then><else>
        <deploy-remote jar="@{jar}" pom="@{pom}"> <artifacts/> </deploy-remote>
      </else></if>
    </sequential>
  </macrodef>

  <macrodef name="deploy-one">
    <attribute name="dir" default=""/>
    <attribute name="name" />
    <attribute name="local"  default="false"/>
    <attribute name="signed" default="false"/>

    <sequential>
      <local name="path"/> <property name="path" value="@{dir}@{name}/@{name}"/>

      <echo>Deploying ${path}-[pom.xml|src.jar|docs.jar].</echo>

      <copy file="${path}-pom.xml" tofile="${path}-pom-filtered.xml" overwrite="true">
        <filterset>
          <filter token="VERSION"                    value="${maven.version.number}" />
          <filter token="SCALA_BINARY_VERSION"       value="${scala.binary.version}" />
          <filter token="XML_VERSION"                value="${scala-xml.version.number}" />
          <filter token="PARSER_COMBINATORS_VERSION" value="${scala-parser-combinators.version.number}" />
          <filter token="RELEASE_REPOSITORY"         value="${remote.release.repository}" />
          <filter token="SNAPSHOT_REPOSITORY"        value="${remote.snapshot.repository}" />
          <filter token="JLINE_VERSION"              value="${jline.version}" />

          <!-- TODO modularize compiler.
          <filter token="SCALA_COMPILER_DOC_VERSION" value="${scala-compiler-doc.version.number}" />
          <filter token="SCALA_COMPILER_INTERACTIVE_VERSION" value="${scala-compiler-interactive.version.number}" />
          -->
        </filterset>
      </copy>
      <artifact:pom id="@{name}.pom" file="${path}-pom-filtered.xml" />

      <if><equals arg1="@{signed}" arg2="false"/><then>
        <if><isset property="docs.skip"/><then>
          <deploy-to local="@{local}" jar="${path}.jar" pom="@{name}.pom">
            <artifact:attach type="jar" file="${path}-src.jar"  classifier="sources" />
          </deploy-to>
        </then><else>
          <deploy-to local="@{local}" jar="${path}.jar" pom="@{name}.pom">
            <artifact:attach type="jar" file="${path}-src.jar"  classifier="sources" />
            <artifact:attach type="jar" file="${path}-docs.jar" classifier="javadoc" />
          </deploy-to>
        </else></if>
      </then><else>
        <local name="repo"/>
        <if><equals arg1="@{local}" arg2="false"/><then>
          <property name="repo" value="${remote.repository}"/>
        </then><else>
          <property name="repo" value="${local.repository}"/>
        </else></if>
        <artifact:mvn failonerror="true">
          <arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
          <arg value="-Durl=${repo}" />
          <arg value="-DrepositoryId=${repository.credentials.id}" />
          <arg value="-DpomFile=${path}-pom-filtered.xml" />
          <arg value=   "-Dfile=${path}.jar" />
          <arg value="-Dsources=${path}-src.jar" />
          <arg value="-Djavadoc=${path}-docs.jar" />
          <arg value="-Pgpg" />
          <arg value="-Dgpg.useagent=true" />
        </artifact:mvn>
      </else></if>
    </sequential>
  </macrodef>

  <macrodef name="deploy">
    <attribute name="dir"    default=""/>
    <attribute name="local"  default="false"/>
    <attribute name="signed" default="false"/>

    <sequential>
      <deploy-one dir="@{dir}"          name="scala-library"     local="@{local}" signed="@{signed}"/>
      <deploy-one dir="@{dir}"          name="scala-reflect"     local="@{local}" signed="@{signed}"/>
      <deploy-one dir="@{dir}"          name="scala-compiler"    local="@{local}" signed="@{signed}"/>

      <!-- TODO modularize compiler.
      <deploy-one dir="@{dir}"          name="scala-compiler-doc"         local="@{local}" signed="@{signed}"/>
      <deploy-one dir="@{dir}"          name="scala-compiler-interactive" local="@{local}" signed="@{signed}"/>
      -->

      <deploy-one dir="@{dir}"          name="scala-actors"      local="@{local}" signed="@{signed}"/>
      <deploy-one dir="@{dir}"          name="scala-swing"       local="@{local}" signed="@{signed}"/>
      <deploy-one dir="@{dir}"          name="scalap"            local="@{local}" signed="@{signed}"/>
    </sequential>
  </macrodef>

  <target name="boot.maven">
    <!-- Pull in properties from build -->
    <property file="build.properties" />
    <!-- Set up Ant contrib tasks so we can use <if><then><else> instead of the clunky `unless` attribute -->
    <taskdef resource="net/sf/antcontrib/antlib.xml" classpath="ant-contrib.jar"/>

    <!-- Add our maven ant tasks -->
    <path id="maven-ant-tasks.classpath" path="maven-ant-tasks-2.1.1.jar" />
    <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant" classpathref="maven-ant-tasks.classpath" />
  </target>

  <target name="init.maven" depends="boot.maven">
    <property name="remote.snapshot.repository" value="https://oss.sonatype.org/content/repositories/snapshots" />
    <property name="remote.release.repository"  value="https://oss.sonatype.org/service/local/staging/deploy/maven2" />

    <property name="local.snapshot.repository" value="${user.home}/.m2/repository" />
    <property name="local.release.repository"  value="${user.home}/.m2/repository" />

    <property name="repository.credentials.id" value="sonatype-nexus" />
    <property name="settings.file" value="${user.home}/.m2/settings.xml" />

    <if><contains string="${maven.version.number}" substring="-SNAPSHOT"/><then>
      <property name="remote.repository" value="${remote.snapshot.repository}"/>
      <property name="local.repository"  value="${local.snapshot.repository}"/>
    </then><else>
      <property name="remote.repository" value="${remote.release.repository}"/>
      <property name="local.repository"  value="${local.release.repository}"/>
    </else></if>

    <echo>Using server[${repository.credentials.id}] for maven repository credentials.
       Please make sure that your ~/.m2/settings.xml has the needed username/password for this server id
    </echo>
  </target>

  <target name="deploy"        depends="init.maven" description="Deploys unsigned artifacts to the maven repo.">       <deploy/> </target>
  <target name="deploy.local"  depends="init.maven" description="Deploys unsigned artifacts to the local maven repo."> <deploy local="true"/> </target>
  <target name="deploy.signed" depends="init.maven" description="Deploys signed artifacts to the remote maven repo.">  <deploy signed="true"/> </target>
</project>