Gradle equivalent maven-dependency-plugin

My root problem is that when running spring -test based tests for my controllers and Freemarker views, I need to have all the taglibs inside the WEB-INF / lib folder, otherwise freemarker will not find them during the tests. I solved this problem with the following maven configuration. It actually copies the taglibs flags to the src / main / webapp / WEB-INF / lib folder before running the tests. I do not want to clear this folder, because when running this test for the IDE, the problem is the same.

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.3</version> <executions> <!-- Freemaarker requires that all taglibs should reside in WEB-INF/lib folder --> <execution> <id>tests</id> <phase>test-compile</phase> <goals> <goal>copy</goal> </goals> <configuration> <outputDirectory>${basedir}/src/main/webapp/WEB-INF/lib/</outputDirectory> <artifactItems> <artifactItem> <groupId>org.springframework.security</groupId> <artifactId>spring-security-taglibs</artifactId> <version>${spring.security.version}</version> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin> 

Now I am transferring my project to gradle. How can I achieve this with gradle?

+8
maven maven-dependency-plugin gradle
source share
1 answer

This is how I solved this problem (same as in maven):

Add another configuration for dependencies:

 configurations{ taglibs { transitive = false } } 

Add the required dependency to this configuration:

 dependencies { ... taglibs "org.springframework.security:spring-security-taglibs:$springSecurityVersion" ... } 

Add gradle code to copy these dependencies to the desired folder:

 task copytaglibs << { copy { from configurations.taglibs into 'src/main/webapp/WEB-INF/lib' } } compileTestJava{ dependsOn copytaglibs } 

It is he.

+10
source share

All Articles