diff --git a/lib/templates/java b/lib/templates/java index 8b9d684..aafe3ba 100755 --- a/lib/templates/java +++ b/lib/templates/java @@ -87,6 +87,10 @@ function guess_package() { } # stop quand on arrive à import ou class /^(import|class)/ { exit 0 }' + elif [[ "$dir" == */src/main/java/* ]]; then + local package="${dir##*/src/main/java/}" + package="${package//\//.}" + echo "$package" elif [[ "$dir" == */Sources/* ]]; then local package="${dir##*/Sources/}" package="${package//\//.}" @@ -188,7 +192,7 @@ EOF } function generate_wosrccomp() { - local file="$1" + local file="$(abspath "$1")" local dir="$(dirname "$file")" local name="$(basename "$file")" local basename="${name%.*}" @@ -198,9 +202,25 @@ function generate_wosrccomp() { *) die "Destination name should not have an extension" 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")" - generate_wosrc "$file.wosrc"; [ -n "$2" ] && array_add "$2" "$file.wosrc" - generate_woapi "$file.api"; [ -n "$2" ] && array_add "$2" "$file.api" + mkdirof "$wosrcfile" + 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 extends body imports=(com.webobjects.appserver.WOComponent com.webobjects.appserver.WOContext) @@ -212,7 +232,8 @@ function generate_wosrccomp() { public ${basename}(WOContext 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 return 0 }