On Sat, Oct 26, 2019 at 7:03 AM Ullrich Hafner <
ullrich...@gmail.com> wrote:
> I can reference my local plugin web resources with
>
> <link rel="stylesheet" href="${resURL}/plugin/warnings-ng/css/font-awesome/css/fontawesome.min.css"/>
>
> But the same does not work when the fontawesome.min.css is part of the other webjar.
Right, because the Jenkins resource URLs only serve files from the
`*.hpi` outside `WEB-INF/` and `META-INF/`, built by Maven from
`src/main/webapp/`. This is to match the traditional behavior of Java
EE WARs.
WebJars sounds neat, and definitely more friendly than Stapler
adjuncts, but to make them usable from Jenkins you would need to write
the infrastructure to serve their contents. I suppose this could take
the form of a WebJars support plugin which defines a `RootAction &
InvisibleAction` and then defines a page variable `webJarsUrl` so that
you could refer to URLs like
${webJarsUrl}/warnings-ng/bootstrap/js/bootstrap.js
This specifies the hosting plugin for purposes of `ClassLoader`
lookup, the JAR `artifactId`, and the rest of path inside that JAR. (I
am assuming the JAR version should be omitted, since a given plugin
can only host one version of a given dependency without some Shade
contortions, and you do not want to have to change a bunch of sources
every time Dependabot bumps the version.) This would resolve to an
actual path like
/jenkins/webJars/4f86c88e/warnings-ng/bootstrap/js/bootstrap.js
The random string in there would be `Jenkins.SESSION_HASH`, so the
server can set a fairly long cache expiry without improper caching
after restarts with plugin updates. See the code used for `static` and
`adjunct` URLs in Jenkins.