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

External JSON configuration does not work #183

Closed
m7stock opened this issue May 19, 2020 · 2 comments
Closed

External JSON configuration does not work #183

m7stock opened this issue May 19, 2020 · 2 comments

Comments

@m7stock
Copy link
Contributor

m7stock commented May 19, 2020

Description

I am not able to externalize the configuration to a JSON file that ignores reported problems. Although I'm afraid of a user error, it could be a bug or is at least be suitable for the FAQ.

Minimal example

I have set up a simple example at https://github.com/matthiasstock/revapi-issue. This example contains:

Manual tests

./mvnw clean revapi:check for various plugin configurations that should ignore the following problem:

[ERROR] java.class.nonPublicPartOfAPI: class org.springframework.boot.loader.jar.JarEntry: Class 'org.springframework.boot.loader.jar.JarEntry' is indirectly included in the API (by the means of method return type for example) but the class is not accessible (neither public nor protected).

Expected Behavior

The configuration under analysisConfiguration and within revapi-docs-new.json works.

Actual Behavior

Only the configuration under analysisConfiguration works.

Remarks

The other two JSON files merely document other approaches and are not essential to this issue.

@metlos
Copy link
Member

metlos commented May 27, 2020

The reproducer repo is super useful, thank you. I have not had a chance to take a look at it yet, though.

@metlos
Copy link
Member

metlos commented May 28, 2020

First of all, please upgrade to revapi-java:0.21.0 that I released yesterday, if at all possible. 0.20.2 had an ugly error in the textual representation of the java elements (the part in the parentheses mentioning the archive etc).

Now to your issue - you have a simple error in your configuration.

Try to run ./mvnw revapi:validate-configuration and you will see that revapi has this to say:

[ERROR] Failed to execute goal org.revapi:revapi-maven-plugin:0.11.4:validate-configuration (default-cli) on project demo: Failed to validate configuration. Errors: invalid type: object (expected array) @ /[0]/configuration  -> [Help 1]

Which is not that super helpful, but given the fact you have a single file in the configuration active, you can see that the configuration of the revapi.ignore should be an array, while you have an object.

So rewriting revapi-docs-new.json to read:

[
  {
    "extension": "revapi.ignore",
    "configuration": [
      { 
        "code": "java.class.nonPublicPartOfAPI",
        "new": "class org.springframework.boot.loader.jar.JarEntry",
        "justification": "as in documentation: JSON Configuration Format"
      }
    ]
  }
]

fixes your problem. revapi:validate-configuration goal succeeds with this change and revapi:check succeeds as well, because it is able to use the configuration.

You can read the documentation for the ignore settings here: https://revapi.org/modules/revapi-basic-features/extensions/ignore.html.

Note that Revapi silently ignores configuration formatting errors mainly due to technical reasons - I implemented this in ancient times when there was no good json schema validator for java and so I am using a javascript based one that I invoke using java's script engine. You can imagine that this is not performing too well and substantially increases the runtime of the API check. I therefore opted to not run it on every analysis.

See #142 which I wrote down to track this problem.

I'm closing this issue but if you have any more questions or comments feel free to either submit a new issue or ask on the mailing list https://groups.google.com/forum/#!forum/revapi.

@metlos metlos closed this as completed May 28, 2020
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

2 participants