Skip to content
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

Add support for absolute paths for jacoco exec and report #34544

Merged
merged 1 commit into from
Jul 5, 2023

Conversation

vsevel
Copy link
Contributor

@vsevel vsevel commented Jul 5, 2023

This changes the data-file and report-location config parameters to allow paths that are not relative to the build directory.
we need this to be able to point to a common location for all modules in a multi module project.
today, if we specify a data-file=jacoco/jacoco-quarkus.exec in module foo, the data-file passed to jacoco will be <project root>/foo/target/jacoco/jacoco-quarkus.exec
in a multi-module project, we need the path to be something like /target/jacoco/jacoco-quarkus.exec
the only option we have right now is to use an expression such as data-file=../target/jacoco/jacoco-quarkus.exec.
but that works only for modules that are at the first level. if we have deeper sub-modules (which is the case in extensions), then we have to customize the number of ../../.. for each module.
This PR allows to configure data-file=${maven.multiModuleProjectDirectory}/target/jacoco/jacoco-quarkus.exec

this is a breaking change on the configuration, since existing configuration data-file=foo would end up with ./foo instead of ./target/foo. if accepted this will need to be properly documented in the migration guide.
another option would be to add an additional config parameter relative-to-multi-module-project-directory=true|false(false by default).

see zulip Multi Module Code Coverage With Jacoco and #32254

@quarkus-bot
Copy link

quarkus-bot bot commented Jul 5, 2023

✔️ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

Copy link
Contributor

@geoand geoand left a comment

Choose a reason for hiding this comment

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

Thanks for this!

I think it makes sense, I just have a comment about the config object change

Comment on lines +17 to +18
@ConfigItem
public Optional<String> dataFile;
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the rationale of this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the default to be the equivalent of target/jacoco-quarkus.exec, but since I wanted to reuse outputTargetBuildItem.getOutputDirectory() and module.getWorkspaceModule().getBuildDir() in the processor, I could not use a WithDefault anymore.
so now it is optional, but a default is calculated in the processor directly.
there are no changes for people who did not set data-file.
for people that did set data-file=foo, they need to change it to target/foo.
your advice more than welcome.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense, thanks.

What I would like however is some Javadoc explaining this process so users who might want to configure it can find this information on our config page (or their IDE if it supports it)

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 thing, which I did I believe:

    /**
     * The jacoco data file. By default this will be target/jacoco-quarkus.exec.
     * The path can be relative (to the module) or absolute.
     */
    @ConfigItem
    public Optional<String> dataFile;

do you think this should be more detailed?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it's fine.

Comment on lines +89 to +90
@ConfigItem
public Optional<String> reportLocation;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same reason as for data file

@geoand geoand merged commit 39c30a6 into quarkusio:main Jul 5, 2023
@quarkus-bot quarkus-bot bot added this to the 3.3 - main milestone Jul 5, 2023
@@ -11,10 +11,11 @@
public class JacocoConfig {

/**
* The jacoco data file
* The jacoco data file. By default this will be target/jacoco-quarkus.exec.
Copy link
Member

Choose a reason for hiding this comment

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

Could we use defaultValueForDocumentation instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't remember that at all. @vsevel fancy doing a new PR with this improvement?

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. I will add some info on the guide as well

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

Successfully merging this pull request may close these issues.

3 participants