Skip to content

Commit 429858f

Browse files
authored
Adjust build for Maven bundles to stricter rules (jython#455)
We conform to requirements newly enforced by Sonatype on the contents of a bundle file. We also switch to using a ZIP containing JARs, and greatly reduce the size of source JARs, which until now included much unintended material.
1 parent 18c4d31 commit 429858f

2 files changed

Lines changed: 69 additions & 41 deletions

File tree

build.xml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,12 +1080,10 @@ The text for an official release would continue like ...
10801080

10811081
<target name="jar-sources" depends="init">
10821082
<jar destfile="dist/${jython.sources.jar}" update="${jar.update}">
1083-
<fileset dir="${basedir}">
1084-
<exclude name="build/**" />
1085-
<exclude name="dist/**" />
1086-
<exclude name="extlibs/**" />
1087-
<exclude name="Doc/**" />
1083+
<fileset dir="${basedir}/src">
1084+
<exclude name="*.exe" /> <!-- launcher -->
10881085
</fileset>
1086+
<fileset dir="${basedir}/build/gensrc" />
10891087
</jar>
10901088
</target>
10911089

maven/build.xml

Lines changed: 66 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -134,34 +134,41 @@
134134
<attribute name="version" />
135135
<attribute name="fromDir" default="${dist.dir}" />
136136
<attribute name="stageDir" default="${build.maven}" />
137+
<attribute name="artifact" default="@{stageDir}/${m2.groupDir}/@{artifactId}/@{version}" />
137138
<attribute name="basename" default="@{artifactId}-@{version}" />
138139
<sequential>
139140
<!-- Clean the staging directory. -->
140-
<delete dir="@{stageDir}" />
141-
<mkdir dir="@{stageDir}" />
141+
<delete dir="@{stageDir}/${m2.groupDir}" />
142+
<mkdir dir="@{artifact}" />
142143

143144
<!-- Copy over the primary artifact from @{fromDir} to the staging area. -->
144-
<copy file="@{fromDir}/@{artifactId}.jar" tofile="@{stageDir}/@{basename}.jar" />
145+
<copy file="@{fromDir}/@{artifactId}.jar" tofile="@{artifact}/@{basename}.jar" />
145146

146147
<!-- The source and Javadoc are already prepared (but add the version to the name). -->
147-
<copy file="@{fromDir}/sources.jar" tofile="@{stageDir}/@{basename}-sources.jar" />
148-
<copy file="@{fromDir}/javadoc.jar" tofile="@{stageDir}/@{basename}-javadoc.jar" />
148+
<copy file="@{fromDir}/sources.jar" tofile="@{artifact}/@{basename}-sources.jar" />
149+
<copy file="@{fromDir}/javadoc.jar" tofile="@{artifact}/@{basename}-javadoc.jar" />
149150

150151
<!-- Create the POM from the given template with placeholders replaced. -->
151-
<copy file="maven/pom-template.xml" tofile="@{stageDir}/@{basename}.pom">
152+
<copy file="maven/pom-template.xml" tofile="@{artifact}/@{basename}.pom">
152153
<filterset>
153154
<filter token="PROJECT-VERSION" value="@{version}" />
154155
<filter token="ARTIFACT-ID" value="@{artifactId}" />
155156
</filterset>
156157
</copy>
157158

158159
<!-- Sign everything. -->
159-
<sign-all stageDir="@{stageDir}" artifactId="@{artifactId}" version="@{version}" />
160+
<sign-detached artifact="@{artifact}" file="@{basename}.pom" />
161+
<sign-detached artifact="@{artifact}" file="@{basename}.jar" />
162+
<sign-detached artifact="@{artifact}" file="@{basename}-sources.jar" />
163+
<sign-detached artifact="@{artifact}" file="@{basename}-javadoc.jar" />
160164

161-
<!-- JAR-up the entire contents of the staging directory. -->
162-
<jar jarfile="${pubs.dir}/@{basename}-bundle.jar">
165+
<!-- Checksum JARs and POMs -->
166+
<checksum-pom-jar artifact="@{artifact}" />
167+
168+
<!-- ZIP-up the entire contents of the staging directory. -->
169+
<zip destfile="${pubs.dir}/@{basename}-bundle.zip">
163170
<fileset dir="@{stageDir}" />
164-
</jar>
171+
</zip>
165172
</sequential>
166173
</macrodef>
167174

@@ -171,61 +178,84 @@
171178
<macrodef name="m2-bundle-gradle">
172179
<attribute name="artifactId" />
173180
<attribute name="version" />
174-
<attribute name="fromDir" default="${gradle.repo}/${m2.groupDir}/@{artifactId}/@{version}" />
181+
<attribute name="fromDir" default="${gradle.repo}" />
175182
<attribute name="stageDir" default="${build.maven}" />
183+
<attribute name="artifact" default="@{stageDir}/${m2.groupDir}/@{artifactId}/@{version}" />
176184
<attribute name="basename" default="@{artifactId}-@{version}" />
177185
<sequential>
178-
<!-- Validate the POM -->
179-
<validate-pom file="@{fromdir}/@{basename}.pom" />
180-
181186
<!-- Clean the staging directory. -->
182-
<delete dir="@{stageDir}" />
183-
<mkdir dir="@{stageDir}" />
187+
<delete dir="@{stageDir}/${m2.groupDir}" />
188+
<mkdir dir="@{artifact}" />
184189

185190
<!-- Copy over all the artifacts from @{fromDir} to the staging area. -->
186191
<copy todir="@{stageDir}">
187192
<fileset dir="@{fromDir}">
188-
<include name="*.jar" />
189-
<include name="*.pom" />
193+
<include name="**/*.jar" />
194+
<include name="**/*.pom" />
190195
</fileset>
191196
</copy>
192197

198+
<!-- Validate the POM -->
199+
<validate-pom file="@{artifact}/@{basename}.pom" />
200+
193201
<!-- Sign everything. -->
194-
<sign-all stageDir="@{stageDir}" artifactId="@{artifactId}" version="@{version}" />
202+
<sign-detached artifact="@{artifact}" file="@{basename}.pom" />
203+
<sign-detached artifact="@{artifact}" file="@{basename}.jar" />
204+
<sign-detached artifact="@{artifact}" file="@{basename}-sources.jar" />
205+
<sign-detached artifact="@{artifact}" file="@{basename}-javadoc.jar" />
195206

196-
<!-- JAR-up the entire contents of the staging directory. -->
197-
<jar jarfile="${pubs.dir}/@{basename}-bundle.jar">
207+
<!-- Checksum JARs and POMs -->
208+
<checksum-pom-jar artifact="@{artifact}" />
209+
210+
<!-- ZIP-up the entire contents of the staging directory. -->
211+
<zip destfile="${pubs.dir}/@{basename}-bundle.zip">
198212
<fileset dir="@{stageDir}" />
199-
</jar>
213+
</zip>
200214
</sequential>
201215
</macrodef>
202216

203-
<!-- Add detached signature for single artifact in staging directory. -->
217+
<!-- Add detached signature for single artifact in artifact directory. -->
204218
<macrodef name="sign-detached">
205219
<attribute name="file" />
206-
<attribute name="stageDir" />
220+
<attribute name="artifact" />
207221
<sequential>
208222
<!-- Generate a detached signature for each artifact in the bundle. -->
209-
<exec executable="gpg" dir="@{stageDir}">
223+
<exec executable="gpg" dir="@{artifact}">
210224
<arg value="-ab" />
211225
<arg value="@{file}" />
212226
</exec>
213227
</sequential>
214228
</macrodef>
215229

216-
<!-- Add detached signatures for group of artifacts in staging directory. -->
217-
<macrodef name="sign-all">
218-
<attribute name="artifactId" />
219-
<attribute name="version" />
220-
<attribute name="stageDir" />
221-
<attribute name="basename" default="@{artifactId}-@{version}" />
230+
<!-- Add checksums for for JAR and POM files in specified arifact directory. -->
231+
<macrodef name="checksum-pom-jar">
232+
<attribute name="artifact" />
222233
<sequential>
223-
<sign-detached stageDir="@{stageDir}" file="@{basename}.pom" />
224-
<sign-detached stageDir="@{stageDir}" file="@{basename}.jar" />
225-
<sign-detached stageDir="@{stageDir}" file="@{basename}-sources.jar" />
226-
<sign-detached stageDir="@{stageDir}" file="@{basename}-javadoc.jar" />
234+
<!-- MD5 Checksum everything -->
235+
<checksum algorithm="MD5" fileext=".md5">
236+
<fileset dir="@{artifact}">
237+
<include name="*.jar" />
238+
<include name="*.pom" />
239+
</fileset>
240+
</checksum>
241+
242+
<!-- SHA-1 Checksum everything -->
243+
<checksum algorithm="SHA-1" fileext=".sha1">
244+
<fileset dir="@{artifact}">
245+
<include name="*.jar" />
246+
<include name="*.pom" />
247+
</fileset>
248+
</checksum>
249+
250+
<!-- SHA-256 Checksum everything -->
251+
<checksum algorithm="SHA-256" fileext=".sha256">
252+
<fileset dir="@{artifact}">
253+
<include name="*.jar" />
254+
<include name="*.pom" />
255+
</fileset>
256+
</checksum>
227257
</sequential>
228-
</macrodef>
258+
</macrodef>
229259

230260
<!-- Validate a Maven POM . -->
231261
<macrodef name="validate-pom">

0 commit comments

Comments
 (0)