You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Steinar Bang <sb...@dod.no> on 2025/05/07 21:22:59 UTC
How do exec:java on a mainclass that calls System.exit() without terminating the maven build?
I am trying to make exec:java from exec-maven-plugin convert a Relax-NG
schema in XML notation (RNG) to a Relax-NG schema in compact notation:
https://gist.github.com/steinarb/9f5105c68bf0c5978272e5af99b2ab5f#file-pom-xml-L197
The config successfully does the file conversion, but then the maven
build abrubtly terminates, and the reason is here in the mainClass:
https://github.com/relaxng/jing-trang/blob/master/mod/rng-validate/src/main/com/thaiopensource/relaxng/util/Driver.java#L35
I.e. the maven build termination is caused by the call to System.exit()
from the Driver.main() method.
As you can see in the gist I have tried to use the blockSystemExit
config, but the maven build still terminates:
https://gist.github.com/steinarb/9f5105c68bf0c5978272e5af99b2ab5f#file-pom-xml-L205
Is there a way around this that do not involve creating my own Java code
to run the desired stuff from trang? (calling the Driver.doMain() method
would be sufficient, I think...?)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How do exec:java on a mainclass that calls System.exit() without terminating the maven build?
Posted by Alexander Kriegisch <Al...@Kriegisch.name>.
> Currently the Security Manager is not used. Classes are transformed by
> ASM
Oh, that is interesting. I had no idea that this was changed internally
already. Nifty trick to use an ASM transformer. After your hint, I just
found
-- BlockExitTransformer,
-- BlockExitTransformer.SystemExitOverrideVisitor
in the source code. I see that my old class SystemExitManager is now
just an empty shell with a new static method 'exit' to which
SystemExitOverrideVisitor delegates the 'System.exit' call. Cute!
When first reopening the project locally and updating the main branch, I
still found this TODO [1] ExecJavaMojo#execute and thought, the issue
had not been addressed yet. Maybe, you want to remove the TODO.
[1]
https://github.com/mojohaus/exec-maven-plugin/blob/47eac15af14e836d54aeb8fae4c047182f224a1f/src/main/java/org/codehaus/mojo/exec/ExecJavaMojo.java#L267-L270
--
Alexander Kriegisch
https://scrum-master.de
Slawomir Jaranowski schrieb am 08.05.2025 um 12:47:
> On Thu, 8 May 2025 at 05:19, Alexander Kriegisch
> <Al...@kriegisch.name> wrote:
>>
>> Hello Steinar.
>>
>> I am usually not involved in Maven Exec development or even use it a
>> lot, but I happen to be the person who implemented the 'blockSystemExit'
>> feature as a PR about 1.5 years ago. So, you may call me an interested
>> party.
>>
>> A quick test shows that the feature still seems to work as expected up
>> to JDK 24 [1]. What do you mean by "Maven build abrubtly terminates"?
>
> Currently the Security Manager is not used. Classes are transformed by ASM,
> so the next release with updated ASM will help with newer JDK.
>
>> The build should terminate with an error, if System.exit was called with
>> a non-zero return code [2] and reported as follows:
>>
>> System::exit was called with return code 123
>>
>> But that is just Maven Exec failing the build. The JVM should not
>> terminate without notice in the middle of the Mojo execution like
>> without using 'blockSystemExit'.
>>
>> As your gist does not qualify as a reproducer, because I cannot just
>> download and execute it without errors out of context, would you please
>> create a stand-alone reproducer on GitHub and link to it from this
>> thread? The maintainers and maybe I can then take a closer look.
>>
>> [1] https://openjdk.org/jeps/486
>> [2]
>> https://www.mojohaus.org/exec-maven-plugin/java-mojo.html#blockSystemExit
>>
>> Best regards
>> --
>> Alexander Kriegisch
>> https://scrum-master.de
>>
>>
>> Steinar Bang schrieb am 08.05.2025 um 04:22:
>>
>>> I am trying to make exec:java from exec-maven-plugin convert a Relax-NG
>>> schema in XML notation (RNG) to a Relax-NG schema in compact notation:
>>> https://gist.github.com/steinarb/9f5105c68bf0c5978272e5af99b2ab5f#file-pom-xml-L197
>>>
>>> The config successfully does the file conversion, but then the maven
>>> build abrubtly terminates, and the reason is here in the mainClass:
>>> https://github.com/relaxng/jing-trang/blob/master/mod/rng-validate/src/main/com/thaiopensource/relaxng/util/Driver.java#L35
>>>
>>> I.e. the maven build termination is caused by the call to System.exit()
>>> from the Driver.main() method.
>>>
>>> As you can see in the gist I have tried to use the blockSystemExit
>>> config, but the maven build still terminates:
>>> https://gist.github.com/steinarb/9f5105c68bf0c5978272e5af99b2ab5f#file-pom-xml-L205
>>>
>>> Is there a way around this that do not involve creating my own Java code
>>> to run the desired stuff from trang? (calling the Driver.doMain() method
>>> would be sufficient, I think...?)
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How do exec:java on a mainclass that calls System.exit() without terminating the maven build?
Posted by Slawomir Jaranowski <s....@gmail.com>.
On Thu, 8 May 2025 at 05:19, Alexander Kriegisch
<Al...@kriegisch.name> wrote:
>
> Hello Steinar.
>
> I am usually not involved in Maven Exec development or even use it a
> lot, but I happen to be the person who implemented the 'blockSystemExit'
> feature as a PR about 1.5 years ago. So, you may call me an interested
> party.
>
> A quick test shows that the feature still seems to work as expected up
> to JDK 24 [1]. What do you mean by "Maven build abrubtly terminates"?
Currently the Security Manager is not used. Classes are transformed by ASM,
so the next release with updated ASM will help with newer JDK.
> The build should terminate with an error, if System.exit was called with
> a non-zero return code [2] and reported as follows:
>
> System::exit was called with return code 123
>
> But that is just Maven Exec failing the build. The JVM should not
> terminate without notice in the middle of the Mojo execution like
> without using 'blockSystemExit'.
>
> As your gist does not qualify as a reproducer, because I cannot just
> download and execute it without errors out of context, would you please
> create a stand-alone reproducer on GitHub and link to it from this
> thread? The maintainers and maybe I can then take a closer look.
>
> [1] https://openjdk.org/jeps/486
> [2]
> https://www.mojohaus.org/exec-maven-plugin/java-mojo.html#blockSystemExit
>
> Best regards
> --
> Alexander Kriegisch
> https://scrum-master.de
>
>
> Steinar Bang schrieb am 08.05.2025 um 04:22:
>
> > I am trying to make exec:java from exec-maven-plugin convert a Relax-NG
> > schema in XML notation (RNG) to a Relax-NG schema in compact notation:
> > https://gist.github.com/steinarb/9f5105c68bf0c5978272e5af99b2ab5f#file-pom-xml-L197
> >
> > The config successfully does the file conversion, but then the maven
> > build abrubtly terminates, and the reason is here in the mainClass:
> > https://github.com/relaxng/jing-trang/blob/master/mod/rng-validate/src/main/com/thaiopensource/relaxng/util/Driver.java#L35
> >
> > I.e. the maven build termination is caused by the call to System.exit()
> > from the Driver.main() method.
> >
> > As you can see in the gist I have tried to use the blockSystemExit
> > config, but the maven build still terminates:
> > https://gist.github.com/steinarb/9f5105c68bf0c5978272e5af99b2ab5f#file-pom-xml-L205
> >
> > Is there a way around this that do not involve creating my own Java code
> > to run the desired stuff from trang? (calling the Driver.doMain() method
> > would be sufficient, I think...?)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
--
Sławomir Jaranowski
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How do exec:java on a mainclass that calls System.exit() without terminating the maven build?
Posted by Slawomir Jaranowski <s....@gmail.com>.
On Fri, 9 May 2025 at 10:20, Alexander Kriegisch
<Al...@kriegisch.name> wrote:
>
> Seems like it was not such a good idea to silently swallow exceptions,
> always assuming a single root cause. Even that should have been
> reported, at least on debug. In this case, it seems like dependency
> classes cannot be found by ASM. Is that the bug you mean?
Exactly ... ClassWriter needs to find some classes used during transformation.
For simple classes with not many references is not used.
I will have a fix for it.
> --
> Alexander Kriegisch
> https://scrum-master.de
>
>
> Slawomir Jaranowski schrieb am 09.05.2025 um 03:31:
> > Thanks for a reproduction project ...
> > I see a bug in exec-maven-plugin.
> >
> > I will try to fix it in a few days.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
--
Sławomir Jaranowski
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How do exec:java on a mainclass that calls System.exit() without terminating the maven build?
Posted by Alexander Kriegisch <Al...@Kriegisch.name>.
Seems like it was not such a good idea to silently swallow exceptions,
always assuming a single root cause. Even that should have been
reported, at least on debug. In this case, it seems like dependency
classes cannot be found by ASM. Is that the bug you mean?
--
Alexander Kriegisch
https://scrum-master.de
Slawomir Jaranowski schrieb am 09.05.2025 um 03:31:
> Thanks for a reproduction project ...
> I see a bug in exec-maven-plugin.
>
> I will try to fix it in a few days.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How do exec:java on a mainclass that calls System.exit() without terminating the maven build?
Posted by Slawomir Jaranowski <s....@gmail.com>.
Thanks for a reproduction project ...
I see a bug in exec-maven-plugin.
I will try to fix it in a few days.
On Thu, 8 May 2025 at 21:07, Steinar Bang <sb...@dod.no> wrote:
>
> >>>>> Thorsten Heit <th...@gmx.de.INVALID>:
>
> > Out of curiosity I cloned your project, executed "mvn clean install",
> > but couldn't reproduce the error you've seen...
>
> Actually, you did.
>
> > convert-xsd-to-rnc % mvn clean install
> > [INFO] Scanning for projects...
> > [INFO]
> > [INFO] -------------< no.priv.bang.xml.schema:convert-xsd-to-rnc -------------
> > (...)
> > [INFO] --- install:3.1.2:install (default-install) @ convert-xsd-to-rnc ---
> > [INFO] Installing /Users/thorsten/git/convert-xsd-to-rnc/pom.xml to
> > /Users/thorsten/.m2/repository/no/priv/bang/xml/schema/convert-xsd-to-rnc/0.0.1-SNAPSHOT/convert-xsd-to-rnc-0.0.1-SNAPSHOT.pom
> > [INFO] Installing
> > /Users/thorsten/git/convert-xsd-to-rnc/target/convert-xsd-to-rnc-0.0.1-SNAPSHOT.jar
> > to
> > /Users/thorsten/.m2/repository/no/priv/bang/xml/schema/convert-xsd-to-rnc/0.0.1-SNAPSHOT/convert-xsd-to-rnc-0.0.1-SNAPSHOT.jar
> > [INFO]
> > [INFO] --- exec:3.5.0:java (convert-xsd-to-rng) @ convert-xsd-to-rnc ---
> > "anyType" is implicitly used as the content model of this element. Is
> > this your intention? If so, please consider to write it explicitly as
> > type="anyType".
> > 1088:72@file:///Users/thorsten/git/convert-xsd-to-rnc/dbchangelog-4.31.xsd
> > [INFO]
> > [INFO] --- exec:3.5.0:java (convert-liquibase-rng-to-rnc) @
> > convert-xsd-to-rnc ---
>
> It stops here. This is the abrupt stop I was talking about.
>
> Here is how "mvn install" ends if I remove the second <excution> (the
> one calling System.exit() in the main):
>
> ...
> [INFO] --- maven-install-plugin:2.4:install (default-install) @ convert-xsd-to-rnc ---
> [INFO] Installing /home/sb/git/convert-xsd-to-rnc/target/convert-xsd-to-rnc-0.0.1-SNAPSHOT.jar to /home/sb/.m2/repository/no/priv/bang/xml/schema/convert-xsd-to-rnc/0.0.1-SNAPSHOT/convert-xsd-to-rnc-0.0.1-SNAPSHOT.jar
> [INFO] Installing /home/sb/git/convert-xsd-to-rnc/pom.xml to /home/sb/.m2/repository/no/priv/bang/xml/schema/convert-xsd-to-rnc/0.0.1-SNAPSHOT/convert-xsd-to-rnc-0.0.1-SNAPSHOT.pom
> [INFO]
> [INFO] --- exec-maven-plugin:3.5.0:java (convert-xsd-to-rng) @ convert-xsd-to-rnc ---
> "anyType" is implicitly used as the content model of this element. Is this your intention? If so, please consider to write it explicitly as type="anyType".
> 1088:72@file:///home/sb/git/convert-xsd-to-rnc/dbchangelog-4.31.xsd
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 1.260 s
> [INFO] Finished at: 2025-05-08T21:03:43+02:00
> [INFO] ------------------------------------------------------------------------
> sb@marquez:~/git/convert-xsd-to-rnc$
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
--
Sławomir Jaranowski
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How do exec:java on a mainclass that calls System.exit() without terminating the maven build?
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Thorsten Heit <th...@gmx.de.INVALID>:
> Out of curiosity I cloned your project, executed "mvn clean install",
> but couldn't reproduce the error you've seen...
Actually, you did.
> convert-xsd-to-rnc % mvn clean install
> [INFO] Scanning for projects...
> [INFO]
> [INFO] -------------< no.priv.bang.xml.schema:convert-xsd-to-rnc -------------
> (...)
> [INFO] --- install:3.1.2:install (default-install) @ convert-xsd-to-rnc ---
> [INFO] Installing /Users/thorsten/git/convert-xsd-to-rnc/pom.xml to
> /Users/thorsten/.m2/repository/no/priv/bang/xml/schema/convert-xsd-to-rnc/0.0.1-SNAPSHOT/convert-xsd-to-rnc-0.0.1-SNAPSHOT.pom
> [INFO] Installing
> /Users/thorsten/git/convert-xsd-to-rnc/target/convert-xsd-to-rnc-0.0.1-SNAPSHOT.jar
> to
> /Users/thorsten/.m2/repository/no/priv/bang/xml/schema/convert-xsd-to-rnc/0.0.1-SNAPSHOT/convert-xsd-to-rnc-0.0.1-SNAPSHOT.jar
> [INFO]
> [INFO] --- exec:3.5.0:java (convert-xsd-to-rng) @ convert-xsd-to-rnc ---
> "anyType" is implicitly used as the content model of this element. Is
> this your intention? If so, please consider to write it explicitly as
> type="anyType".
> 1088:72@file:///Users/thorsten/git/convert-xsd-to-rnc/dbchangelog-4.31.xsd
> [INFO]
> [INFO] --- exec:3.5.0:java (convert-liquibase-rng-to-rnc) @
> convert-xsd-to-rnc ---
It stops here. This is the abrupt stop I was talking about.
Here is how "mvn install" ends if I remove the second <excution> (the
one calling System.exit() in the main):
...
[INFO] --- maven-install-plugin:2.4:install (default-install) @ convert-xsd-to-rnc ---
[INFO] Installing /home/sb/git/convert-xsd-to-rnc/target/convert-xsd-to-rnc-0.0.1-SNAPSHOT.jar to /home/sb/.m2/repository/no/priv/bang/xml/schema/convert-xsd-to-rnc/0.0.1-SNAPSHOT/convert-xsd-to-rnc-0.0.1-SNAPSHOT.jar
[INFO] Installing /home/sb/git/convert-xsd-to-rnc/pom.xml to /home/sb/.m2/repository/no/priv/bang/xml/schema/convert-xsd-to-rnc/0.0.1-SNAPSHOT/convert-xsd-to-rnc-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] --- exec-maven-plugin:3.5.0:java (convert-xsd-to-rng) @ convert-xsd-to-rnc ---
"anyType" is implicitly used as the content model of this element. Is this your intention? If so, please consider to write it explicitly as type="anyType".
1088:72@file:///home/sb/git/convert-xsd-to-rnc/dbchangelog-4.31.xsd
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.260 s
[INFO] Finished at: 2025-05-08T21:03:43+02:00
[INFO] ------------------------------------------------------------------------
sb@marquez:~/git/convert-xsd-to-rnc$
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How do exec:java on a mainclass that calls System.exit() without terminating the maven build?
Posted by Thorsten Heit <th...@gmx.de.INVALID>.
Hi Steinar,
> Here is a repro case as simple as I could make it:
> https://github.com/steinarb/convert-xsd-to-rnc
>
> Clone and run with "mvn install"
>
> The maven build ends (for me) as abruptly as the above gist after the
> second <execution> in the exec-maven-plugin config.
>
> The <execution> of trang is run to completion (which I can see since
> target/dbchangelog-4.31.rnc have been created), but maven stops and
> there is no error message as would have been expected for a non 0 return
> value of Driver.doMain().
>
> My platform:
> debian 12.10 "bookworm", amd64
> openjdk java 20.0.4
> maven 3.8.7
Out of curiosity I cloned your project, executed "mvn clean install",
but couldn't reproduce the error you've seen...
convert-xsd-to-rnc % mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] -------------< no.priv.bang.xml.schema:convert-xsd-to-rnc
>-------------
(...)
[INFO] --- install:3.1.2:install (default-install) @ convert-xsd-to-rnc ---
[INFO] Installing /Users/thorsten/git/convert-xsd-to-rnc/pom.xml to
/Users/thorsten/.m2/repository/no/priv/bang/xml/schema/convert-xsd-to-rnc/0.0.1-SNAPSHOT/convert-xsd-to-rnc-0.0.1-SNAPSHOT.pom
[INFO] Installing
/Users/thorsten/git/convert-xsd-to-rnc/target/convert-xsd-to-rnc-0.0.1-SNAPSHOT.jar
to
/Users/thorsten/.m2/repository/no/priv/bang/xml/schema/convert-xsd-to-rnc/0.0.1-SNAPSHOT/convert-xsd-to-rnc-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- exec:3.5.0:java (convert-xsd-to-rng) @ convert-xsd-to-rnc ---
"anyType" is implicitly used as the content model of this element. Is
this your intention? If so, please consider to write it explicitly as
type="anyType".
1088:72@file:///Users/thorsten/git/convert-xsd-to-rnc/dbchangelog-4.31.xsd
[INFO]
[INFO] --- exec:3.5.0:java (convert-liquibase-rng-to-rnc) @
convert-xsd-to-rnc ---
convert-xsd-to-rnc % mvn --version
Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: /opt/homebrew/Cellar/maven/3.9.9/libexec
Java version: 23.0.2, vendor: Homebrew, runtime:
/opt/homebrew/Cellar/openjdk/23.0.2/libexec/openjdk.jdk/Contents/Home
Default locale: de_DE, platform encoding: UTF-8
OS name: "mac os x", version: "15.4.1", arch: "aarch64", family: "mac"
Best regards
Thorsten
Re: How do exec:java on a mainclass that calls System.exit() without terminating the maven build?
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:
>> What do you mean by "Maven build abrubtly terminates"?
> Here's the output of "mvn clean install" on the project. Maven build
> ends on line 26 with no error message:
> https://gist.github.com/steinarb/12596b7771bc2d0e2a3835292b07329e
[snip!]
>> As your gist does not qualify as a reproducer, because I cannot just
>> download and execute it without errors out of context, would you
>> please create a stand-alone reproducer on GitHub and link to it from
>> this thread? The maintainers and maybe I can then take a closer look.
> Ok, I will try to create a simple repro case.
Here is a repro case as simple as I could make it:
https://github.com/steinarb/convert-xsd-to-rnc
Clone and run with "mvn install"
The maven build ends (for me) as abruptly as the above gist after the
second <execution> in the exec-maven-plugin config.
The <execution> of trang is run to completion (which I can see since
target/dbchangelog-4.31.rnc have been created), but maven stops and
there is no error message as would have been expected for a non 0 return
value of Driver.doMain().
My platform:
debian 12.10 "bookworm", amd64
openjdk java 20.0.4
maven 3.8.7
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How do exec:java on a mainclass that calls System.exit() without terminating the maven build?
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Alexander Kriegisch <Al...@Kriegisch.name>:
> A quick test shows that the feature still seems to work as expected up
> to JDK 24 [1].
I forgot to say what I was using, but I'm currently using Java 21.0.4
from openjdk on debian 12.10 "bookwork" on amd64.
> What do you mean by "Maven build abrubtly terminates"?
Here's the output of "mvn clean install" on the project. Maven build
ends on line 26 with no error message:
https://gist.github.com/steinarb/12596b7771bc2d0e2a3835292b07329e
> The build should terminate with an error, if System.exit was called
> with a non-zero return code [2] and reported as follows:
> System::exit was called with return code 123
Yes, I would have expected something like that from a non-null value
returned by Driver.doMain().
> But that is just Maven Exec failing the build. The JVM should not
> terminate without notice in the middle of the Mojo execution like
> without using 'blockSystemExit'.
Indeed.
> As your gist does not qualify as a reproducer, because I cannot just
> download and execute it without errors out of context, would you please
> create a stand-alone reproducer on GitHub and link to it from this
> thread? The maintainers and maybe I can then take a closer look.
Ok, I will try to create a simple repro case.
But until then:
This is the project the gist belongs in:
https://github.com/steinarb/liquibase-karaf-feature
The gist is a drop-in replacement for this pom:
https://github.com/steinarb/liquibase-karaf-feature/blob/master/liquibase-integration-test/karaf.liquibase.sample/pom.xml
(i.e. the ./liquibase-integration-test/karaf.liquibase.sample/pom.xml
file of a "git clone"
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How do exec:java on a mainclass that calls System.exit() without terminating the maven build?
Posted by Alexander Kriegisch <Al...@Kriegisch.name>.
Hello Steinar.
I am usually not involved in Maven Exec development or even use it a
lot, but I happen to be the person who implemented the 'blockSystemExit'
feature as a PR about 1.5 years ago. So, you may call me an interested
party.
A quick test shows that the feature still seems to work as expected up
to JDK 24 [1]. What do you mean by "Maven build abrubtly terminates"?
The build should terminate with an error, if System.exit was called with
a non-zero return code [2] and reported as follows:
System::exit was called with return code 123
But that is just Maven Exec failing the build. The JVM should not
terminate without notice in the middle of the Mojo execution like
without using 'blockSystemExit'.
As your gist does not qualify as a reproducer, because I cannot just
download and execute it without errors out of context, would you please
create a stand-alone reproducer on GitHub and link to it from this
thread? The maintainers and maybe I can then take a closer look.
[1] https://openjdk.org/jeps/486
[2]
https://www.mojohaus.org/exec-maven-plugin/java-mojo.html#blockSystemExit
Best regards
--
Alexander Kriegisch
https://scrum-master.de
Steinar Bang schrieb am 08.05.2025 um 04:22:
> I am trying to make exec:java from exec-maven-plugin convert a Relax-NG
> schema in XML notation (RNG) to a Relax-NG schema in compact notation:
> https://gist.github.com/steinarb/9f5105c68bf0c5978272e5af99b2ab5f#file-pom-xml-L197
>
> The config successfully does the file conversion, but then the maven
> build abrubtly terminates, and the reason is here in the mainClass:
> https://github.com/relaxng/jing-trang/blob/master/mod/rng-validate/src/main/com/thaiopensource/relaxng/util/Driver.java#L35
>
> I.e. the maven build termination is caused by the call to System.exit()
> from the Driver.main() method.
>
> As you can see in the gist I have tried to use the blockSystemExit
> config, but the maven build still terminates:
> https://gist.github.com/steinarb/9f5105c68bf0c5978272e5af99b2ab5f#file-pom-xml-L205
>
> Is there a way around this that do not involve creating my own Java code
> to run the desired stuff from trang? (calling the Driver.doMain() method
> would be sufficient, I think...?)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How do exec:java on a mainclass that calls System.exit() without terminating the maven build?
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:
> Side note: Heh, I just discovered an unexpected side effect of my schema
> conversion with System.exit(): it can bring down eclipse that has a
> maven project where the schema conversion is done.
exec-maven-plugin has been released and this now works:
https://github.com/steinarb/convert-xsd-to-rnc/blob/master/pom.xml#L46
> I wonder if the exec-maven-plugin fix mentioned in this thread also will
> fix eclipse or if I need a different fix there...?
[snip!]
> (I'll update this thread with what I discover wrt. to eclipse behaviour
> once the exec-maven-plugin fix is released)
This is a regular java project that crashed eclipse when blockSystemExit
didn't block exit from com.thaiopensource.relaxng.translate.Driver
https://github.com/steinarb/sampleapp/blob/master/sampleapp.db.liquibase/pom.xml#L157
But with exec-maven-plugin 3.5.1, eclipse now survives a maven update of
the project.
Thanks!
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How do exec:java on a mainclass that calls System.exit() without terminating the maven build?
Posted by Steinar Bang <sb...@dod.no>.
Side note: Heh, I just discovered an unexpected side effect of my schema
conversion with System.exit(): it can bring down eclipse that has a
maven project where the schema conversion is done.
I wonder if the exec-maven-plugin fix mentioned in this thread also will
fix eclipse or if I need a different fix there...?
(not the maven team's responsibility I know... just putting the
information out there... :-) )
(I'll update this thread with what I discover wrt. to eclipse behaviour
once the exec-maven-plugin fix is released)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How do exec:java on a mainclass that calls System.exit() without terminating the maven build?
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Slawomir Jaranowski <s....@gmail.com>:
> Hi Steinar
> Can you test my patch: https://github.com/mojohaus/exec-maven-plugin/pull/472
Looks successful to me: https://gist.github.com/steinarb/922753fd7bcb7189c1716e7761d237df
Thanks!
Here is what I did to test:
git clone https://github.com/mojohaus/exec-maven-plugin.git
cd exec-maven-plugin/
git checkout class-writer-classloader
mvn install
Then I bumped <version> of exec-maven-plugin to 3.5.1-SNAPSHOT and built
my test project, with the result shown in the above gist.
> I added an example provided by you as an IT.
Cool!
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How do exec:java on a mainclass that calls System.exit() without terminating the maven build?
Posted by Slawomir Jaranowski <s....@gmail.com>.
Hi Steinar
Can you test my patch: https://github.com/mojohaus/exec-maven-plugin/pull/472
I added an example provided by you as an IT.
On Fri, 9 May 2025 at 16:11, Steinar Bang <sb...@dod.no> wrote:
>
> >>>>> Thomas Broyer <t....@gmail.com>:
>
> > Use exec:exec instead:
> > https://www.mojohaus.org/exec-maven-plugin/examples/example-exec-for-java-programs.html
>
> I don't wish to start a separate process for to convert schemas, so this
> isn't an option for me.
>
> But thanks for responding.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
--
Sławomir Jaranowski
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How do exec:java on a mainclass that calls System.exit() without terminating the maven build?
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Thomas Broyer <t....@gmail.com>:
> Use exec:exec instead:
> https://www.mojohaus.org/exec-maven-plugin/examples/example-exec-for-java-programs.html
I don't wish to start a separate process for to convert schemas, so this
isn't an option for me.
But thanks for responding.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How do exec:java on a mainclass that calls System.exit() without terminating the maven build?
Posted by Thomas Broyer <t....@gmail.com>.
Use exec:exec instead:
https://www.mojohaus.org/exec-maven-plugin/examples/example-exec-for-java-programs.html
Le mer. 7 mai 2025, 23:24, Steinar Bang <sb...@dod.no> a écrit :
> I am trying to make exec:java from exec-maven-plugin convert a Relax-NG
> schema in XML notation (RNG) to a Relax-NG schema in compact notation:
>
> https://gist.github.com/steinarb/9f5105c68bf0c5978272e5af99b2ab5f#file-pom-xml-L197
>
> The config successfully does the file conversion, but then the maven
> build abrubtly terminates, and the reason is here in the mainClass:
>
> https://github.com/relaxng/jing-trang/blob/master/mod/rng-validate/src/main/com/thaiopensource/relaxng/util/Driver.java#L35
>
> I.e. the maven build termination is caused by the call to System.exit()
> from the Driver.main() method.
>
> As you can see in the gist I have tried to use the blockSystemExit
> config, but the maven build still terminates:
>
> https://gist.github.com/steinarb/9f5105c68bf0c5978272e5af99b2ab5f#file-pom-xml-L205
>
> Is there a way around this that do not involve creating my own Java code
> to run the desired stuff from trang? (calling the Driver.doMain() method
> would be sufficient, I think...?)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
Re: How do exec:java on a mainclass that calls System.exit() without terminating the maven build?
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Slawomir Jaranowski <s....@gmail.com>:
> You can try with - blockSystemExit
I am trying with blockSystemExit:
https://gist.github.com/steinarb/9f5105c68bf0c5978272e5af99b2ab5f#file-pom-xml-L205
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How do exec:java on a mainclass that calls System.exit() without terminating the maven build?
Posted by Slawomir Jaranowski <s....@gmail.com>.
Hi,
You can try with - blockSystemExit
https://www.mojohaus.org/exec-maven-plugin/java-mojo.html#blockSystemExit
On Wed, 7 May 2025 at 23:24, Steinar Bang <sb...@dod.no> wrote:
>
> I am trying to make exec:java from exec-maven-plugin convert a Relax-NG
> schema in XML notation (RNG) to a Relax-NG schema in compact notation:
> https://gist.github.com/steinarb/9f5105c68bf0c5978272e5af99b2ab5f#file-pom-xml-L197
>
> The config successfully does the file conversion, but then the maven
> build abrubtly terminates, and the reason is here in the mainClass:
> https://github.com/relaxng/jing-trang/blob/master/mod/rng-validate/src/main/com/thaiopensource/relaxng/util/Driver.java#L35
>
> I.e. the maven build termination is caused by the call to System.exit()
> from the Driver.main() method.
>
> As you can see in the gist I have tried to use the blockSystemExit
> config, but the maven build still terminates:
> https://gist.github.com/steinarb/9f5105c68bf0c5978272e5af99b2ab5f#file-pom-xml-L205
>
> Is there a way around this that do not involve creating my own Java code
> to run the desired stuff from trang? (calling the Driver.doMain() method
> would be sufficient, I think...?)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
--
Sławomir Jaranowski
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org