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

Problem with Gradle 7.5 #55

Open
leonard84 opened this issue Jul 15, 2022 · 3 comments
Open

Problem with Gradle 7.5 #55

leonard84 opened this issue Jul 15, 2022 · 3 comments

Comments

@leonard84
Copy link

The plugin seems to have a problem with Gradle 7.5 the :checkstyleNohttp task fails, while it worked fine with Gradle 7.4.2

A failure occurred while executing org.gradle.api.plugins.quality.internal.CheckstyleAction
> java.lang.IllegalStateException: Could not load file 'config/nohttp/allowlist.lines'
  > Could not load file 'config/nohttp/allowlist.lines'
    > config/nohttp/allowlist.lines (No such file or directory)

Full Stacktrace: https://ge.spockframework.org/s/v657tmnb3ld2u/failure?anchor=e30&expanded-stacktrace=WyIwLTEtMi0zLTQiXQ&focused-exception-line=0-1-2-3-4-0

@asodja
Copy link

asodja commented Jul 21, 2022

To any future reader:
a workaround is to overwrite default checkstyle.xml with checkstyle.xml that uses config_loc.

E.g. if you have allowlist.lines in config/nohttp/allowlist.lines you put checkstyle.xml like the one below to config/nohttp/checkstyle.xml:

<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
  "https://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
  <property name="charset" value="UTF-8"/>
  <property name="fileExtensions" value=""/>
  <module name="io.spring.nohttp.checkstyle.check.NoHttpCheck">
    <property name="allowlistFileName" value="${config_loc}/allowlist.lines" default=""/>
  </module>
  <module name="SuppressionFilter">
    <property name="file" value="${config_loc}/suppressions.xml" default=""/>
    <property name="optional" value="true"/>
  </module>
  <module name="SuppressWithPlainTextCommentFilter"/>
</module>

The important line here is <property name="allowlistFileName" value="${config_loc}/allowlist.lines" default=""/> since config_loc will be resolved to a folder where allowlist.lines is in.

@simonbasle
Copy link

came across this issue as well. probably related to the fact that Gradle 7.5 now runs Checkstyle tasks within a Worker and using the Toolchain support.

thanks for the workaround @asodja, it works for me.

I suspect that the path in which the checkstyle analysis is actually executed has changed with the move to workers, and that this line of code results in a wrong relative path:

String allowlistPath = project.relativePath(allowlistFile);

@big-guy
Copy link

big-guy commented Jul 26, 2022

The problem is in the check itself, sort of:

File allowlistFile = new File(this.allowlistFileName);

This assumes the path will be relative to the current working directory. For Gradle 7.4 and below, the current working directory seen by Checkstyle is the current working directory of the shell. In Gradle 7.5, the current working directory is always the worker directory.

There's another subtle problem that allowlistFile may not be considered an input to the Checkstyle task if it's outside of the configDirectory (config_loc).

It's probably safest if...

  1. Check assumes/requires an absolute path
  2. The example config recommends building an absolute path relative to config_loc
  3. The Gradle plugin sets the allowlistFileName path relative to configDir instead of the project directory

leonard84 added a commit to leonard84/spock that referenced this issue Jan 26, 2023
Apply local fix for spring-io/nohttp#55
Update io.spring.nohttp to version 0.0.11
Update com.gradle.enterprise to version 3.12.2
Update com.github.ben-manes.to versions to version 0.44.0
Update biz.aQute.bnd.builder to version 6.4.0
Remove org.gradle.test-retry as it is integrated into gradle-enterprise
leonard84 added a commit to leonard84/spock that referenced this issue Jan 26, 2023
Apply local fix for spring-io/nohttp#55
Update io.spring.nohttp to version 0.0.11
Update com.gradle.enterprise to version 3.12.2
Update com.github.ben-manes.to versions to version 0.44.0
Update biz.aQute.bnd.builder to version 6.4.0
Remove org.gradle.test-retry as it is integrated into gradle-enterprise
leonard84 added a commit to leonard84/spock that referenced this issue Feb 16, 2023
Apply local fix for spring-io/nohttp#55
Update io.spring.nohttp to version 0.0.11
Update com.gradle.enterprise to version 3.12.2
Update com.github.ben-manes.to versions to version 0.44.0
Update biz.aQute.bnd.builder to version 6.4.0
Remove org.gradle.test-retry as it is integrated into gradle-enterprise
leonard84 added a commit to leonard84/spock that referenced this issue Feb 16, 2023
Apply local fix for spring-io/nohttp#55
Update io.spring.nohttp to version 0.0.11
Update com.gradle.enterprise to version 3.12.3
Update com.github.ben-manes.to versions to version 0.45.0
Update biz.aQute.bnd.builder to version 6.4.0
Remove org.gradle.test-retry as it is integrated into gradle-enterprise
leonard84 added a commit to spockframework/spock that referenced this issue Feb 16, 2023
Apply local fix for spring-io/nohttp#55
Update io.spring.nohttp to version 0.0.11
Update com.gradle.enterprise to version 3.12.3
Update com.github.ben-manes.to versions to version 0.45.0
Update biz.aQute.bnd.builder to version 6.4.0
Remove org.gradle.test-retry as it is integrated into gradle-enterprise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants