aemc icon indicating copy to clipboard operation
aemc copied to clipboard

Maven Not Bundled with Setup

Open mitchross opened this issue 1 year ago • 4 comments

Why is Maven and Node not bundled? Since the JDK is already downloaded, it seems natural to have at least a maven binary downloaded as well? Node for front end? ( although I could argue this is not needed )

image

mitchross avatar Apr 15 '24 15:04 mitchross

Yep, in some setups I have already used Maven Wrapper. It is not as straightforward as it looks at a glance. Mostly due to https://github.com/go-task/task/issues/1038#issuecomment-1892097343 . Without having this resolved, having Java/Maven bundled when initializing AEMC in the project may not look as simple as it should be. That's why till now it's not bundled. The solution I know and is working properly looks a little bit hackish for me and that's why I am avoiding sharing it broader.

krystian-panek-vmltech avatar Apr 15 '24 19:04 krystian-panek-vmltech

for now to satisfy your potential curiosity ;) due to mentioned Taskfile limitation I have it organized in the following way:

Taskfile.yml has a new task that need to be run once right after cloning the AEM project:

  aem:init:
    desc: initialize AEM prerequisites
    cmds:
      - sh aemw instance init
      - mkdir -p var
      - sh aemw instance init --output-value javaHome > var/java_home.txt

mvnw script (from official Maven Wrapper distro) has following addition in the beginning:

script_dir=$(dirname "$0")
if [ -f "${script_dir}/var/java_home.txt" ]; then
    export JAVA_HOME=$(cat "${script_dir}/var/java_home.txt")
fi

plus few if statements are "improved" because they are not working properly on Windows+Git Bash:

  if $cygwin; then

are changed to

if [ "$cygwin" = true ] || [ "$mingw" = true ]; then

finally, in the Taskfile instead of calling mvn I am calling script mvnw which uses Java managed by AEMC

krystian-panek-vmltech avatar Apr 15 '24 19:04 krystian-panek-vmltech

Interesting. Thanks for the acknowledgement.

mitchross avatar Apr 15 '24 19:04 mitchross

considering https://taskfile.dev/experiments/env-precedence/ now mvnw could be integrated in simpler way

krystian-panek-vmltech avatar Sep 17 '24 13:09 krystian-panek-vmltech

hey @mitchross ;

now Maven Wrapper is in use. the new AEM projects after AEMC project scaffold command run will use mvnw (instead of mvn) which eliminated a need to install Maven on your own.

see: https://github.com/wttech/aemc/releases/tag/v2.0.0

enjoy ;)

krystian-panek-vmltech avatar Nov 21 '24 10:11 krystian-panek-vmltech