Skip to content

Commit a2c8fae

Browse files
committed
release-version: fix Maven project attributes
It is tempting to change all http: strings to https: in this day and age. But the strings that go at the top of a Maven POM are not actually URLs, they are namespace identifiers that must be those exact strings -- including the http: prefix -- for the document to be a valid Maven POM. See also: https://imagesc.zulipchat.com/#narrow/stream/327237-SciJava/topic/release-version.20error.20with.20xsi.20namespace
1 parent 3f0bbdb commit a2c8fae

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

release-version.sh

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,41 @@ then
231231
echo "====================================================================="
232232
sed 's;http://maven.apache.org/xsd/maven-4.0.0.xsd;https://maven.apache.org/xsd/maven-4.0.0.xsd;' pom.xml > pom.new &&
233233
mv -f pom.new pom.xml &&
234-
git commit pom.xml \
235-
-m 'POM: use HTTPS for schema location URL' \
234+
git commit pom.xml -m 'POM: use HTTPS for schema location URL' \
236235
-m 'Maven no longer supports plain HTTP for the schema location.' \
237236
-m 'And using HTTP now generates errors in Eclipse (and probably other IDEs).'
238237
fi
239238

239+
# Check project xmlns, xmlns:xsi, and xsi:schemaLocation attributes.
240+
grep -q 'xmlns="http://maven.apache.org/POM/4.0.0"' pom.xml >/dev/null 2>/dev/null &&
241+
grep -q 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' pom.xml >/dev/null 2>/dev/null &&
242+
grep -q 'xsi:schemaLocation="http://maven.apache.org/POM/4.0.0\b"' pom.xml >/dev/null 2>/dev/null ||
243+
{
244+
echo "====================================================================="
245+
echo "NOTE: Your POM's project attributes are incorrect. Fixing it now."
246+
echo "====================================================================="
247+
sed 's;xmlns="[^"]*";xmlns="http://maven.apache.org/POM/4.0.0";' pom.xml > pom.new &&
248+
mv -f pom.new pom.xml &&
249+
sed 's;xmlns:xsi="[^"]*";xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";' pom.xml > pom.new &&
250+
mv -f pom.new pom.xml &&
251+
sed 's;xsi:schemaLocation="[^"]*";xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd";' pom.xml > pom.new &&
252+
mv -f pom.new pom.xml &&
253+
git commit pom.xml -m 'POM: fix project attributes' \
254+
-m 'The XML schema for Maven POMs is located at:' \
255+
-m ' https://maven.apache.org/xsd/maven-4.0.0.xsd' \
256+
-m 'Its XML namespace is the string:' \
257+
-m ' http://maven.apache.org/POM/4.0.0' \
258+
-m 'So that exact string must be the value of xmlns. It must also
259+
match the first half of xsi:schemaLocation, which maps that
260+
namespace to an actual URL online where the schema resides.
261+
Otherwise, the document is not a Maven POM.' \
262+
-m 'Similarly, the xmlns:xsi attribute of an XML document declaring a
263+
particular schema should always use the string identifier:' \
264+
-m ' http://www.w3.org/2001/XMLSchema-instance' \
265+
-m "because that's the namespace identifier for instances of an XML schema." \
266+
-m "For details, see the specification at: https://www.w3.org/TR/xmlschema-1/"
267+
}
268+
240269
# Change forum references from forum.image.net to forum.image.sc.
241270
if grep -q 'https*://forum.imagej.net' pom.xml >/dev/null 2>/dev/null
242271
then

0 commit comments

Comments
 (0)