How to access boot CSS that was loaded as a gradle dependency?

My question is that I'm not sure how to access the boot library, which is located in the "External Libraries" in my project.

In the build.gradle file, I added:
compile group: 'org.webjars', name: 'bootstrap', version: '3.3.7'

to download the boot library. But when I want to access it in an html file and try to use the copy path function, I get the following:

 C:\Users\Michael\.gradle\caches\modules-2\files-2.1\org.webjars\bootstrap\3.3.7\d6aeba80236573ed585baa657dac2b951caa8e7e\bootstrap-3.3.7.jar!\META-INF\resources\webjars\bootstrap\3.3.7\css\bootstrap.css 

Also tried this "standard" path (wasnt working):

 <link rel="stylesheet" href="../css/bootstrap.min.css"> 

I am using Intellij (gradle project)

Bootstrap downloaded folder can be found in external libraries

0
source share
1 answer

Gradle boot and cahces dependecies locally. It refers to artifacts from the cache, when necessary, IDE, all compilers get the path to the artifact from the cache. The link that you are in includes a file from the archive in the cache. This is not what the browser understands.

You need to use the Copy task to place it somewhere in your project, where you can access it, or pack it along with the rest of your site. Copying a specific dependency has already been considered . You will need to additionally extract the artifact. The documentation has examples of how to read the contents of the archive .

Here's what a complete solution might look like:

 apply plugin: "java" repositories { mavenCentral() } dependencies { compile group: 'org.webjars', name: 'bootstrap', version: '3.3.7' } task copyBootstrap(type: Copy) { configurations.compile .files({ it.group.equals("org.webjars")}) .each { from zipTree(it) } into "$buildDir/static_resources" } 

This puts the file you are looking for in the following location on my system (Gradle 2.14.1):

 build/static_resources/META-INF/resources/webjars/bootstrap/3.3.7/css/bootstrap.min.css 

If you want to extract a specific file or get rid of the version number, to simplify access to what is also possible .

Please note that in $buildDir it is recommended to extract it, because with most plugins, including java, it is automatically cleared using the "Clear" task, and it is more difficult to do this by accident.

0
source

Source: https://habr.com/ru/post/1260025/


All Articles