GithubHelp home page GithubHelp logo

Comments (19)

slawekjaranowski avatar slawekjaranowski commented on August 25, 2024 1

In StyleBook there is code:

    public static void main(String[] var0) throws IOException {
      .....
      exit((String)"All done successfully", 0);
    }

    private static void exit(String var0, int var1) {
        log(var0);
        System.exit(var1);
    }

as exec-maven-plugin simply execute code in the same JVM .... in this case build are finished by System.exit ....

I have:

[INFO] --- exec:3.1.0:java (Stylebook XSLTC documentation) @ xalan-project ---
[StyleBook] Overriding loaderConfig="sbk:/style/loaderdesign.xml" (Old="sbk:/style/loader.xml")
[StyleBook] Overriding targetDirectory="./target/tmp/site/xsltc/" (Old=".")

....

[StyleBook] All done successfully
$

from exec-maven-plugin.

jkesselm avatar jkesselm commented on August 25, 2024 1

Ah. So System.exit() is blowing up the entire Maven session before it can get to the second execution?

If so, the quick fix would be as discussed in https://www.mojohaus.org/exec-maven-plugin/examples/example-exec-for-java-programs.html to launch each StyleBook in a separate JVM. I'll try that.

(The better fix would be to have a version of StyleBook that doesn't gratuitously call System.exit(), of course.)

Thanks. I generally start by assuming I did something stupid... and arguably I did, just not what I thought I had.

from exec-maven-plugin.

slawekjaranowski avatar slawekjaranowski commented on August 25, 2024 1

Ah. So System.exit() is blowing up the entire Maven session before it can get to the second execution?

exactly

from exec-maven-plugin.

jkesselm avatar jkesselm commented on August 25, 2024 1

Seems to have done it. Thanks!

from exec-maven-plugin.

slawekjaranowski avatar slawekjaranowski commented on August 25, 2024 1

@kriegaex , @jkesselm - I will release next version in a few days ... maybe in this weekend.

I always like to check topic like site generation, broken links and other simple issue before release

from exec-maven-plugin.

jkesselm avatar jkesselm commented on August 25, 2024

.... Oh. Default configuration outside the executions, then a configuration inside each execution to set local parameters? With explicit IDs so they don't collide on the default for that?

Maven accepts that without complaining... but I'm still getting output only from the first <execution>.

Copying or moving <additionalClasspathElements> and <mainClass> into the per-execution configurations doesn't seem to change this.

What's my obvious beginner error?

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>3.1.0</version>
        <executions>
          <execution>
	    <id>Stylebook XSLTC documentation</id>
            <phase>package</phase>
            <goals>
              <goal>java</goal>
            </goals>
	    <configuration>
              <arguments>
		<argument>loaderConfig=sbk:/style/loaderdesign.xml</argument>
		<argument>targetDirectory=./target/tmp/site/xsltc/</argument>
		<argument>./stylebook/sources/xsltc.xml</argument>
		<argument>./stylebook/style</argument>
              </arguments>
	    </configuration>
          </execution>
          <execution>
	    <id>Stylebook Xalan interpretive documentation</id>
            <phase>package</phase>
            <goals>
              <goal>java</goal>
            </goals>
	    <configuration>
              <arguments>
		<argument>loaderConfig=sbk:/style/loaderdesign.xml</argument>
		<argument>targetDirectory=./target/tmp/site/xalan/</argument>
		<argument>./stylebook/sources/xalan-jsite.xml</argument>
		<argument>./stylebook/style</argument>
              </arguments>
	    </configuration>
          </execution>
          <execution>
	    <id>Stylebook design documentation</id>
            <phase>package</phase>
            <goals>
              <goal>java</goal>
            </goals>
	    <configuration>
              <arguments>
		<argument>loaderConfig=sbk:/style/loaderdesign.xml</argument>
		<argument>targetDirectory=./target/tmp/site/design/</argument>
		<argument>./stylebook/sources/xalandesign.xml</argument>
		<argument>./stylebook/style</argument>
              </arguments>
	    </configuration>
          </execution>
        </executions>
        <configuration>
	  <additionalClasspathElements>./stylebook/stylebook-1.0-b3_xalan-2.jar</additionalClasspathElements>
          <mainClass>org.apache.stylebook.StyleBook</mainClass>
        </configuration>
      </plugin>

from exec-maven-plugin.

kriegaex avatar kriegaex commented on August 25, 2024

@jkesselm: For me, this works locally. Can you please share a link to a full reproducer, so other people or I can take a closer look?

from exec-maven-plugin.

jkesselm avatar jkesselm commented on August 25, 2024

You'll see that the xsltc subdirectory has been created, but not target/tmp/site/xalan or target/tmp/site/design. Apparently only the first is running.

Platform is Fedora running under WSL. mvn -version reports

Maven home: /mnt/c/users/keshlam/apache-maven-3.6.3
Java version: 1.8.0_382, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.fc37.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.15.90.1-microsoft-standard-wsl2", arch: "amd64", family: "unix"

(Yes, I'm deliberately using a downlevel JDK, to ensure backward compatibility. That shouldn't affect this, right?)

Let me know if you need other details or experiments performed.


Context: What I'm trying to do is move the logic now in stylebook_docgen.sh into the Maven build, so it doesn't have to be done as postprocessing. As written there it does what's expected (though that's outputting directly to target/site rather than to target/site/tmp). But maven is currently giving me only that one execution of stylebook. I must be missing something obvious.

Maven reminds me of an analog synth. Lots of patch points and knobs; takes quite a while to learn how the designer intended them to be used, how they can actually be (ab)used, and how they all interact. And sometimes the results are not what I expected.


And something else weird is going on. Since adding this, my main compilation has stopped working; I'm no longer getting anything but the target/tmp/site/xsltc output.

Lemme try reverting (to the xalan-java-mvn-refactored branch) and adding this again from scratch...

from exec-maven-plugin.

jkesselm avatar jkesselm commented on August 25, 2024

Checked out the xalan-java-mvn-refactored branch.

Added the multi-execution I originally quoted to the POM, directly above </plugins>.

Ran the maven build, both just as package and as clean package site source:jar source:test-jar.
Either way, ./target/tmp/site/ contains only xsltc/.
Problem confirmed as still present.

Output of mvn -X package attached. You'll see that there's only one [DEBUG] Invoking. So, yes, I'm only getting one of the three executions.

jkesselm-issue-388.log

from exec-maven-plugin.

jkesselm avatar jkesselm commented on August 25, 2024

I've updated the exec-maven-plugin-problem branch if you want to run it locally.

from exec-maven-plugin.

slawekjaranowski avatar slawekjaranowski commented on August 25, 2024

I tried ... with xalan on branch exec-maven-plugin-problem

commit 9c47e6f74de2ee834c09fbc860653bf36f38c2da (HEAD -> exec-maven-plugin-problem, origin/exec-maven-plugin-problem)

and I have

$ mvn package

INFO] --- exec:3.1.0:java (Stylebook XSLTC documentation) @ xalan-project ---
[StyleBook] Overriding loaderConfig="sbk:/style/loaderdesign.xml" (Old="sbk:/style/loader.xml")
[StyleBook] Overriding targetDirectory="./target/tmp/site/xsltc/" (Old=".")
[StyleBook] Caught java.io.IOException
java.io.IOException: Style File/Directory not found
	at org.apache.stylebook.URLHandler.<init>(Unknown Source)
	at org.apache.stylebook.StyleBook.<init>(Unknown Source)
	at org.apache.stylebook.StyleBook.main(Unknown Source)
	at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:279)
	at java.lang.Thread.run(Thread.java:750)

from exec-maven-plugin.

jkesselm avatar jkesselm commented on August 25, 2024

Sorry, forgot to check that in. (Ant build expanded it from a jarfile at build time; simpler, I think, to just check it in flat.)
Should be there now.

from exec-maven-plugin.

jkesselm avatar jkesselm commented on August 25, 2024

(FWIW, I decompiled stylebook to take a quick look at it. About 2500 lines of code, mostly straightforward. Almost tempted to comment it and re-contribute it to Apache, if real source can't be found. "In my copious spare time.")

from exec-maven-plugin.

kriegaex avatar kriegaex commented on August 25, 2024

@slawekjaranowski, would you be interested in a PR to address this? I thought about an option for the exec:java goal to block System.exit by means of a security manager (SM). That is deprecated for removal since JDK 17, but still possible, if the Maven JVM is called with -Djava.security.manager=allow. The SM would intercept calls to System.exit and throw a SecurityException, as required by the SM API. The caller (Maven Exec) would handle the exception gracefully and in case of exit code 0 just print an info or debug message to the console or fail the build. That way, users would not be forced to use exec:exec in order to fork and could stay within the comfortable bounds of exec:java even for tools behaving badly, trying to exit the VM instead of just throwing uncaught exceptions.

Right after finishing exec:java execution, the original SM would be reactivated, i.e. all other plugins and subsequent executions of the same goal without the option to block System.exit would be unaffected. In multi-threaded Maven, maybe we would have to limit the SM's interference to certain threads or classloaders, I have not thought that through yet. I am open for suggestions there.

Before you refuse, because I suggest a deprecated API, please consider that JEP 411 links to JDK-8199704, which is blocking removal of the SM API until a suitable replacement has been introduced to the JVM, i.e. even in the future there will be a means to block System.exit, and Maven Exec can be updated to use that new API, when available and running on a JDK containing such API.

WDYT? Feel free to also mention other MojoHaus developers to discuss this.

from exec-maven-plugin.

slawekjaranowski avatar slawekjaranowski commented on August 25, 2024

@kriegaex sounds reasonable - we can try with such feature, I have no objections for such PR.

from exec-maven-plugin.

kriegaex avatar kriegaex commented on August 25, 2024

@jkesselm, feel free to test your project against my PR. That would spare you the effort to use exec:exec in the future, i.e. as soon as a plugin release containing this change would be available.

from exec-maven-plugin.

jkesselm avatar jkesselm commented on August 25, 2024

from exec-maven-plugin.

kriegaex avatar kriegaex commented on August 25, 2024

@slawekjaranowski, do you have any indicator for @jkesselm when a plugin release containing the now merged feature might become available? I actually do not need it myself, but Joseph's use case was so interesting that I decided to implement it for his future use in Xalan-Java, which currently he is so heroically porting from Ant to Maven.

from exec-maven-plugin.

jkesselm avatar jkesselm commented on August 25, 2024

from exec-maven-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.