Skip to content

Commit ba28889

Browse files
committed
travis-build.sh: bootstrap settings.xml internally
Rather than relying on every repository always having its own (in all cases so far identical) .travis/settings.xml, the script can generate one itself for its own use. If a .travis/settings.xml does exist, however, we use that. This way, individual repositories can still customize the settings if they need to do so for some reason -- although doing so runs the risk of getting "out of sync" with this script's requirements, if they change in the future.
1 parent 3a675ec commit ba28889

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

travis-build.sh

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,46 @@ echo "== Configuring Maven =="
1212
# See: https://stackoverflow.com/a/35653426/1207769
1313
export MAVEN_OPTS=-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
1414

15+
# Populate the settings.xml configuration.
16+
mkdir -p "$HOME/.m2"
17+
settingsFile="$HOME/.m2/settings.xml"
18+
customSettings=.travis/settings.xml
19+
test -f "$customSettings" && cp "$customSettings" "$settingsFile" ||
20+
cat >"$settingsFile" <<EOL
21+
<settings>
22+
<servers>
23+
<server>
24+
<id>imagej.releases</id>
25+
<username>travis</username>
26+
<password>${env.MAVEN_PASS}</password>
27+
</server>
28+
<server>
29+
<id>imagej.snapshots</id>
30+
<username>travis</username>
31+
<password>${env.MAVEN_PASS}</password>
32+
</server>
33+
<server>
34+
<id>sonatype-nexus-releases</id>
35+
<username>scijava-ci</username>
36+
<password>${env.OSSRH_PASS}</password>
37+
</server>
38+
</servers>
39+
</settings>
40+
EOL
41+
42+
# Run the build.
1543
if [ "$TRAVIS_SECURE_ENV_VARS" = true \
1644
-a "$TRAVIS_PULL_REQUEST" = false \
1745
-a "$TRAVIS_BRANCH" = master ]
1846
then
1947
echo "== Building and deploying master SNAPSHOT =="
20-
mvn -B -Pdeploy-to-imagej deploy --settings "$dir/.travis/settings.xml"
48+
mvn -B -Pdeploy-to-imagej deploy
2149
elif [ "$TRAVIS_SECURE_ENV_VARS" = true \
2250
-a "$TRAVIS_PULL_REQUEST" = false \
2351
-a -f release.properties ]
2452
then
2553
echo "== Cutting and deploying release version =="
26-
mvn -B --settings "$dir/.travis/settings.xml" release:perform
54+
mvn -B release:perform
2755
else
2856
echo "== Building the artifact locally only =="
2957
mvn -B install

0 commit comments

Comments
 (0)