As we know gradle has provided a configuration ‘provideRuntime’ in ‘WAR’ plugin.
It is important to note that these
provided
configurations work transitively
.
My scene
The tree of dependency jar ‘org.springframework:spring-core:5.1.6.RELEASE
’:
\--- org.springframework:spring-core:5.1.6.RELEASE
\--- org.springframework:spring-jcl:5.1.6.RELEASE
Our build.gradle
( Gradle version: 3.5)
apply plugin: 'java'
apply plugin: 'war'
repositories {
jcenter()
}
dependencies {
implementation 'org.springframework:spring-jcl:5.1.6.RELEASE'
providedRuntime 'org.springframework:spring-core:5.1.6.RELEASE'
}
then I run command
gradle build
to build a deployment file with suffix .war
,
finally, I find that there’s no ‘.jar’ library files exist in this .war
file.
My Expect
There must be a file named ‘spring-jcl-5.1.6.RELEASE.jar
’ in built .war
.
Just like following maven script:
Maven
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.web</groupId>
<artifactId>Blank-deps</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>Blank-deps Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jcl</artifactId>
<version>5.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.1.6.RELEASE</version>
<scope>provided</scope>
</dependency>
/dependencies>
<build>
<finalName>Blank-deps</finalName>
</build>
</project>
Download
- URL: https://pan.baidu.com/s/18h7hSA5PY-L-U_afBLDaKA
- Extract code: jhcf
Steps
- Download the
.zip
file to local and unzip file. - Enter unziped folder, execute DOS command
mvn clean package
- You will get a ‘.war’ file in
target
folder when it run successfully. There’s a ‘spring-jcl-5.1.6.RELEASE.jar’ file under ‘WEB-INF/lib’ subdirectory in ‘.war’ file.
Question:
Is my approach wrong or are there other solutions to implement like Maven?
Thanks for your help.