This repository was archived by the owner on May 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.project.sh
More file actions
85 lines (73 loc) · 1.98 KB
/
plugin.project.sh
File metadata and controls
85 lines (73 loc) · 1.98 KB
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
#!/bin/sh
# VARIABLES
PROJECTS_DIR=projects
project_configure(){
mvn -f $1/${PROJECTS_DIR}/pom.xml clean install
}
project_run(){
expected_params 1 $@
project_$@ || halt
}
project_create(){
template_name=$1
name=${name:-$1}
group_id=${group_id:-$name}
version=${version:-1.0.0-SNAPSHOT}
artifact_id=${artifact_id:-$name}
if [ -d "$artifact_id" ]; then
warn "A module/project named `yellow $artifact_id` already exists. Override it?"
warn "Press ENTER to Continue, Ctrl+C to abort."
read null
rm -rf $artifact_id
fi
mvn archetype:generate -B \
-DarchetypeGroupId=io.skullabs.kikaha.archetypes \
-DarchetypeArtifactId=${template_name}-archetype \
-DarchetypeVersion=1.0.0 \
-DgroupId=$group_id \
-DartifactId=$artifact_id \
-Dversion=$version
}
project_use_last(){
latest_version=`curl -s http://download.kikaha.io/stable-version`
project_use $latest_version
}
project_use(){
expected_params 1 $@
if [ ! -f "pom.xml" ]; then
warn "Invalid project. No maven project found."
info "Ensure that you choose a project folder that have a $(yellow pom.xml) file."
debug "Current work directory: `pwd`"
halt
fi
info "Setting up project to use Kikaha version $1"
var_set pom.xml version $1
}
project_add_dep(){
SED_RE='\(\([^:]*\):\([^:]*\)\(:\(.*\)\)*\)'
artifact_id=`echo $1 | sed "s/${SED_RE}/\3/"`
group_id=`echo $1 | sed "s/${SED_RE}/\2/"`
version=`echo $1 | sed "s/${SED_RE}/\5/"`
if [ "$version" = "$1" ]; then
dep=`cat <<EOF
<dependency>
<groupId>$group_id</groupId>
<artifactId>$artifact_id</artifactId>
</dependency>
EOF
`
else
dep=`cat <<EOF
<dependency>
<groupId>$group_id</groupId>
<artifactId>$artifact_id</artifactId>
<version>$version</version>
</dependency>
EOF
`
fi
dep=$(echo $dep | sed 's/\//\\\//g')
info "Adding $artifact_id ($group_id) at version $version as dependency"
debug "Maven dependency :\n $dep"
var_add pom.xml dependencies "$dep\n"
}