Skip to content

fix: use separator properties when running JMH #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,8 @@
<goal>exec</goal>
</goals>
<configuration>
<executable>${java.home}/bin/java</executable>
<commandlineArgs>-cp target/classes:target/test-classes:${test.classpath} org.openjdk.jmh.Main ${jmh.args}</commandlineArgs>
<executable>${java.home}${file.separator}bin${file.separator}java</executable>
<commandlineArgs>-cp "target${file.separator}classes${path.separator}target${file.separator}test-classes${path.separator}${test.classpath}" org.openjdk.jmh.Main ${jmh.args}</commandlineArgs>
Copy link
Contributor

@ppkarwasz ppkarwasz Apr 4, 2025

Choose a reason for hiding this comment

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

This command line does not look very elegant, due to the fact that:

  • we want ${jmh.args} to be split into words.
  • we do not want the classpath to be split into words.

What would you say about passing the classpath in the CLASSPATH environment variable instead:

<environmentVariables>
  <CLASSPATH>target${file.separator}classes${path.separator}target${file.separator}test-classes${path.separator}${test.classpath}</CLASSPATH>
</environmentVariables>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, this seems to work as well. I changed it.

But, I thought that the quotes were already preventing the splitting of the classpath. The JMH args were left unquoted, same as before.

Copy link
Contributor

Choose a reason for hiding this comment

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

But, I thought that the quotes were already preventing the splitting of the classpath. The JMH args were left unquoted, same as before.

The quotes should work in most normal cases, although I suspect that using " in the path of the Maven local repository on UNIX might break the configuration (the plugin uses plexus-utils to split the command line).
Using the environment variable is probably just safer.

</configuration>
</execution>
</executions>
Expand Down