Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

[MWRAPPER-16] PoC call mvn(.cmd) script from mvnw(.cmd) #5

Open
wants to merge 1 commit into
base: MWRAPPER-14
Choose a base branch
from

Conversation

hboutemy
Copy link
Member

@hboutemy hboutemy commented Nov 20, 2021

tested on Linux: it works
not tested on Mac, I'm not sure of portability
not tested on Windows: implementation is purely theoretical

@jvanzyl
Copy link

jvanzyl commented Nov 21, 2021

@hboutemy I tried to build it locally and have the following:

INFO] Reading assembly descriptor: src/assembly/script.xml
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Apache Maven Wrapper Parent 3.0.3-SNAPSHOT:
[INFO] 
[INFO] Apache Maven Wrapper Parent ........................ SUCCESS [  2.231 s]
[INFO] Maven Wrapper ...................................... SUCCESS [  3.331 s]
[INFO] Maven Wrapper Distribution ......................... FAILURE [  0.239 s]
[INFO] Apache Maven Wrapper Plugin ........................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.913 s
[INFO] Finished at: 2021-11-21T12:16:35-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:3.2.0:single (default) on project maven-wrapper-distribution: Error reading assemblies: Error reading descriptor: src/assembly/script.xml: Unrecognised tag: 'sources' (position: START_TAG seen ...<file>\n      <sources>... @43:16)  -> [Help 1]

Happy to try it on a Mac with some projects when it builds.

@hboutemy
Copy link
Member Author

uh, strange, I don't have any issue here on my Linux box when launching mvn clean install && mvn org.apache.maven.plugins:maven-wrapper-plugin:3.0.3-SNAPSHOT:wrapper -Dtype=bin -DmavenVersion=3.6.3 && ./mvnw -v
I get the expected result:

Now, mvnw script should call /home/herve/.m2/wrapper/dists/apache-maven-3.6.3-bin/apache-maven-3.6.3/bin/mvn
mvnw will call /home/herve/.m2/wrapper/dists/apache-maven-3.6.3-bin/*/bin/mvn
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /home/herve/.m2/wrapper/dists/apache-maven-3.6.3-bin/apache-maven-3.6.3

first message comes from wrapper.jar, that does not launch Maven but display where Maven is available
second message comes from mvnw script, before launching mvn script
and of course, next ones are from Maven

@cstamas
Copy link
Member

cstamas commented Nov 21, 2021

Same here, same error (Linux) as for @jvanzyl

@cstamas
Copy link
Member

cstamas commented Nov 21, 2021

@hboutemy you somehow locally use 3.3.0 of m-assembly-p, but sources does NOT make that be used. Are you sure you have correct parent or committed all?

@cstamas
Copy link
Member

cstamas commented Nov 21, 2021

Just checked out and build:

[INFO] --- maven-assembly-plugin:3.2.0:single (default) @ maven-wrapper-distribution ---
[INFO] Reading assembly descriptor: src/assembly/script.xml
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Apache Maven Wrapper Parent 3.0.3-SNAPSHOT:
[INFO] 
[INFO] Apache Maven Wrapper Parent ........................ SUCCESS [  2.409 s]
[INFO] Maven Wrapper ...................................... SUCCESS [  3.160 s]
[INFO] Maven Wrapper Distribution ......................... FAILURE [  0.229 s]
[INFO] Apache Maven Wrapper Plugin ........................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.921 s
[INFO] Finished at: 2021-11-21T20:54:23+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:3.2.0:single (default) on project maven-wrapper-distribution: Error reading assemblies: Error reading descriptor: src/assembly/script.xml: Unrecognised tag: 'sources' (position: START_TAG seen ...<file>\n      <sources>... @43:16)  -> [Help 1]
[ERROR] 

If I edit maven-wrapper-distribution/pom.xml to use m-assembly-p 3.3.0,all is ok.

@cstamas
Copy link
Member

cstamas commented Nov 21, 2021

Sources tag (that we fail on) was added in this issue https://issues.apache.org/jira/browse/MASSEMBLY-934 present in 3.3.0 but not 3.2.0. Something is off re @hboutemy env and PR as PR is clearly broken. Unsure what is really happening, but PR uses m-assembly-p 3.2.0 that FAILS, while upping m-assembly-p to 3.3.0 it works.

@slawekjaranowski
Copy link
Member

Confirm on mac with m-assembly-p 3.3.0 it is ok ... maybe #4 can help to detect early such problems

@hboutemy
Copy link
Member Author

ok, I deleted my local parent POMs and now I see the issue: just need to define newer plugin version than inherited
issue fixed in MWRAPPER-14, MWRAPPER-16 rebased
#4 won't really help: everything was visible in ASF Jenkins, given it is in a branch before going into GH PR

# local distribution dir is distributionUrl basename without extension
distribution=`basename $distributionUrl .zip`

mvn=~/.m2/wrapper/dists/$distribution/*/bin/mvn
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here the glob wildcard * will expand to multiple files or select a wrong version or not expand at all in some posix shell. To invoke the main entrance script, u has to print the full path of the distribution or at least the hash of url.

The cons of this method is that java would be run twice. While the original way is the java way of exec invoking.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to remove *, in Unix shell, I suppose we can derive directory name from with basename $distribution -bin
I'm not too much worried in POSIX shell: equivalent implementation in Windows cmd is harder to me

on running java twice, I suppose the script can check if the distribution is already installed to not run the installation java -jar maven-wrapper.jar if not really necessary

@michael-o
Copy link
Member

@hboutemy Please note that your shell (/bin/sh) may trick you. Dependening on your OS your default shell might be bash where you will not notice that your script is not POSIX compliant. In such a case force POSIX mode.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants