support de la création d'un template wosrc pour un projet maven

This commit is contained in:
Jephté Clain 2016-06-04 18:53:27 +04:00
parent 34dbba9991
commit 7091ecff64
1 changed files with 25 additions and 4 deletions

View File

@ -87,6 +87,10 @@ function guess_package() {
} }
# stop quand on arrive à import ou class # stop quand on arrive à import ou class
/^(import|class)/ { exit 0 }' /^(import|class)/ { exit 0 }'
elif [[ "$dir" == */src/main/java/* ]]; then
local package="${dir##*/src/main/java/}"
package="${package//\//.}"
echo "$package"
elif [[ "$dir" == */Sources/* ]]; then elif [[ "$dir" == */Sources/* ]]; then
local package="${dir##*/Sources/}" local package="${dir##*/Sources/}"
package="${package//\//.}" package="${package//\//.}"
@ -188,7 +192,7 @@ EOF
} }
function generate_wosrccomp() { function generate_wosrccomp() {
local file="$1" local file="$(abspath "$1")"
local dir="$(dirname "$file")" local dir="$(dirname "$file")"
local name="$(basename "$file")" local name="$(basename "$file")"
local basename="${name%.*}" local basename="${name%.*}"
@ -198,9 +202,25 @@ function generate_wosrccomp() {
*) die "Destination name should not have an extension" *) die "Destination name should not have an extension"
esac esac
case "$file" in
*/src/main/java/*)
javafile="$file"
wosrcfile="${file/src\/main\/java/src/main/wosrc}"
;;
*/src/main/wosrc/*)
wosrcfile="$file"
javafile="${file/src\/main\/wosrc/src/main/java}"
;;
*)
wosrcfile="$file"
javafile="$file"
;;
esac
etitle "$(ppath "$file")" etitle "$(ppath "$file")"
generate_wosrc "$file.wosrc"; [ -n "$2" ] && array_add "$2" "$file.wosrc" mkdirof "$wosrcfile"
generate_woapi "$file.api"; [ -n "$2" ] && array_add "$2" "$file.api" generate_wosrc "$wosrcfile.wosrc"; [ -n "$2" ] && array_add "$2" "$wosrcfile.wosrc"
generate_woapi "$wosrcfile.api"; [ -n "$2" ] && array_add "$2" "$wosrcfile.api"
local -a imports implements local -a imports implements
local extends body local extends body
imports=(com.webobjects.appserver.WOComponent com.webobjects.appserver.WOContext) imports=(com.webobjects.appserver.WOComponent com.webobjects.appserver.WOContext)
@ -212,7 +232,8 @@ function generate_wosrccomp() {
public ${basename}(WOContext context) { public ${basename}(WOContext context) {
super(context); super(context);
}" }"
generate_java "$file.java"; [ -n "$2" ] && array_add "$2" "$file.java" mkdirof "$javafile"
generate_java "$javafile.java"; [ -n "$2" ] && array_add "$2" "$javafile.java"
eend eend
return 0 return 0
} }