On Fri, Oct 23, 2020 at 2:27 PM Jesse Glick <[email protected]> wrote:

> On Fri, Oct 23, 2020 at 7:30 AM Radek Antoniuk <[email protected]>
> wrote:
> > how can I customise the list of plugins that the test runs with
>
> Normally you do not do anything besides have plugins of interest in
> your Maven test classpath. `@WithPlugin` is tricky and rarely needed.
>
> > to detect a missing dependency in tests?
>
> What specifically are you trying to accomplish? Reproducing
> JENKINS-64002 in a test? Not going to work (see JENKINS-41827). Your
> mistake can be seen from `mvn dependency:tree`:
>
> [INFO] +- org.jenkins-ci.plugins:p4:jar:1.3.8:compile (optional)
> [INFO] |  +- org.jenkins-ci.plugins:credentials:jar:2.3.13:compile
> (optional)
>
>
You explicitly use the `credentials` plugin’s APIs, so you should have
> a direct dependency on it. (check `mvn dependency:analyze`)
>

It took me a while to understand what you wrote and happenned here, but I
think I got it right now.

p4 is optional and it should stay there IMHO. perforce functionality is
absolutely custom and therefore optional for jira plugin for users using
git (majority).
The JENKINS-64002 <https://issues.jenkins-ci.org/browse/JENKINS-64002> bug
is however about basic Credential user/password saving to JIRA instance
itself that bails out at the main manage configuration
screen.

So if I read you correct, you are saying that all the
*org.jenkins-ci.plugin:**:*compile* dependencies that are in the
"Undeclared used dependencies" output from dependency:analyze - should be
added to direct dependencies?

And indeed, that's exactly what I would like to "detect with @JenkinsRule
or during compilation phase" - but the root cause here was that the p4
maven included "credentials api" for compilation through optional p4
dependency but not introduced a direct plugin dependency in Jenkins plugin
system.

So I think that the better solution is to actually exclude
org.jenkins-ci.plugin:* from the optional dependencies instead - see
https://github.com/jenkinsci/jira-plugin/pull/292/files
This way the plugin fails on compilation with no direct dependency declared
and still optional dependency is ok.

Thanks a lot for pointing in the right direction!


> In general, use `optional` dependencies only with extreme care; see
> JENKINS-19508 for discussion.
>
> BTW your plugin does not build in `master`, perhaps because #277
> introduced a mistake that #290 caught, or similar.
>

Not sure what you mean, the plugin pipeline is green on master branch -
https://github.com/jenkinsci/jira-plugin

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/CAPe2pWirbT4eYsMuSv2Bw_AQ-mrkGCBYv%2B%3DJfGN7ubK7UZ6C9w%40mail.gmail.com.

Reply via email to