This repository has been archived by the owner on Mar 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 145
/
mvnLoftuxWrapper.sh
executable file
·139 lines (116 loc) · 5.34 KB
/
mvnLoftuxWrapper.sh
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
#!/bin/bash
#Set the name and build number
versionedition="Community by Loftux AB"
buildnumber="LX102"
buildAlfresco="5.2-SNAPSHOT"
# Add url in format id::layout::url, see http://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html
snapshotID=""
snapshotURL=""
releaseID=""
releaseURL=""
layout="default"
snapshotRepo="$snapshotID::$layout::$snapshotURL"
releaseRepo="$releaseID::$layout::$releaseURL"
# SCM Revision number -Fetch automatically
scmpath=`git config --get remote.origin.url`
scmrevision=`git log --pretty=format:'%h' -n 1`
# Set values normally set by Alfresco bamboo build system.
bamboo_planName="mvnLoftuxWrapper"
bamboo_fullBuildKey="$buildnumber $buildAlfresco"
bamboo_buildNumber=1
bamboo_repository_revision_number=$scmrevision
bamboo_custom_svn_lastchange_revision_number=$scmrevision
bamboo_planRepository_repositoryUrl=$scmpath
echo
echo "Loftux Maven Wrapper. Helper script for building Alfresco with maven."
echo
echo "version-edition: $versionedition"
echo "build-number: $buildnumber"
echo "build-Alfresco: $buildAlfresco"
echo "scm-revision: $scmrevision"
echo "scm-path: $scmpath"
echo "maven command: $1"
echo
echo "Java Environment"
echo $JAVA_HOME
echo $JAVA_OPTS
echo
echo "Press control-c to stop this script."
echo "Press any other key to continue."
read KEY
install() {
echo "Starting local install build..."
mvn clean source:jar install -Dversion-edition="$versionedition" -Dbuild-number="$buildnumber" -Dscm-revision="$scmrevision" -Dscm-path="$scmpath" \
-Dbamboo_planName="$bamboo_planName" -Dbamboo_fullBuildKey="$bamboo_fullBuildKey" -Dbamboo_buildNumber="$bamboo_buildNumber" -Dbamboo_repository_revision_number="$bamboo_repository_revision_number" \
-Dbamboo_custom_svn_lastchange_revision_number="$bamboo_custom_svn_lastchange_revision_number" -D=bamboo_planRepository_repositoryUrl="$bamboo_planRepository_repositoryUrl"
}
deploy() {
echo
echo "Starting deploy build..."
echo
if [[ $buildnumber == *"SNAPSHOT"* ]]
then
if [ -n "$snapshotURL" ]; then
echo "Deploy to SNAPSHOT $snapshotRepo"
echo
mvn clean source:jar deploy -Penv=production -DaltSnapshotDeploymentRepository="$snapshotRepo" \
-Dmaven.distributionManagement.snapshot.url="$snapshotURL" -Dmaven.distributionManagement.snapshot.id="$snapshotID" \
-Dversion-edition="$versionedition" -Dbuild-number="$buildnumber" -Dscm-revision="$scmrevision" -Dscm-path="$scmpath" \
-Dbamboo_planName="$bamboo_planName" -Dbamboo_fullBuildKey="$bamboo_fullBuildKey" -Dbamboo_buildNumber="$bamboo_buildNumber" -Dbamboo_repository_revision_number="$bamboo_repository_revision_number" \
-Dbamboo_custom_svn_lastchange_revision_number="$bamboo_custom_svn_lastchange_revision_number" -D=bamboo_planRepository_repositoryUrl="$bamboo_planRepository_repositoryUrl"
else
echo "You must set the snapshotRepo url for a SNAPSHOT deployment"
fi
else
if [ -n "$releaseURL" ]; then
echo "Deploy to RELEASE $releaseRepo"
echo
mvn clean source:jar deploy -Penv=production -DaltReleaseDeploymentRepository="$releaseRepo" \
-Dmaven.distributionManagement.release.url="$releaseURL" -Dmaven.distributionManagement.release.id="$releaseID" \
-Dversion-edition="$versionedition" -Dbuild-number="$buildnumber" -Dscm-revision="$scmrevision" -Dscm-path="$scmpath" \
-Dbamboo_planName="$bamboo_planName" -Dbamboo_fullBuildKey="$bamboo_fullBuildKey" -Dbamboo_buildNumber="$bamboo_buildNumber" -Dbamboo_repository_revision_number="$bamboo_repository_revision_number" \
-Dbamboo_custom_svn_lastchange_revision_number="$bamboo_custom_svn_lastchange_revision_number" -D=bamboo_planRepository_repositoryUrl="$bamboo_planRepository_repositoryUrl"
else
echo "You must set the releaseRepo url for a RELEASE deployment"
fi
fi
}
setup () {
echo
echo "Updating with Loftux build Number in pom.xml"
echo "Replacing $buildAlfresco with $buildnumber"
echo
find . -name "pom.xml" -type f -exec sed -i '' "s/\<version\>$buildAlfresco\<\/version\>/\<version\>$buildnumber\<\/version\>/g" {} \;
find . -name "pom.xml" -type f -exec sed -i '' "s/\<alfresco.platform.version\>$buildAlfresco\<\/alfresco.platform.version\>/\<alfresco.platform.version\>$buildnumber\<\/alfresco.platform.version\>/g" {} \;
}
cleanup() {
echo
echo "Restoring Loftux build Number to Alfresco build in pom.xml"
echo "Replacing $buildnumber with $buildAlfresco "
echo
find . -name "pom.xml" -type f -exec sed -i '' "s/\<version\>$buildnumber\<\/version\>/\<version\>$buildAlfresco\<\/version\>/g" {} \;
find . -name "pom.xml" -type f -exec sed -i '' "s/\<alfresco.platform.version\>$buildnumber\<\/alfresco.platform.version\>/\<alfresco.platform.version\>$buildAlfresco\<\/alfresco.platform.version\>/g" {} \;
echo
echo "Restore orginal Alfresco build number completed"
echo
read -e -p "Do you want to run mvn clean [y/n] (default: y)" runclean
if [ "$runclean" != "n" ]; then
mvn clean
fi
}
case "$1" in
install)
setup
install
cleanup
;;
deploy)
setup
deploy
cleanup
;;
*)
echo "You need to supply an argument: $0 {install|deploy}"
exit 1
esac
exit $RETVAL