The transitive jars lost in .war file when it's in 'provideRuntime' configuration!

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
Steps
  1. Download the .zip file to local and unzip file.
  2. Enter unziped folder, execute DOS command
mvn clean package
  1. 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.

The very first line you quoted from the link spends the rest of the paragraph answering your question. In that example, spring-core is commons-httpclient and spring-jcl is commons-codec.

Let’s say you add commons-httpclient:commons-httpclient:3.0 to any of the provided configurations. This dependency has a dependency on commons-codec . Because this is a “provided” configuration, this means that neither of these dependencies will be added to your WAR, even if the commons-codec library is an explicit dependency of your compile configuration. If you don’t want this transitive behavior, simply declare your provided dependencies like commons-httpclient:commons-httpclient:3.0@jar.

In other words, your dependency declaration would look like this:

dependencies { 
    implementation 'org.springframework:spring-jcl:5.1.6.RELEASE'
    providedRuntime 'org.springframework:spring-core:5.1.6.RELEASE@jar'
}

@jjustinic Thanks for your answer. This’s the one of solutions.

But, let’s change the code:

apply plugin: 'java' 
apply plugin: 'war'  
apply plugin: 'eclipse-wtp'  

repositories {   
    mavenCentral()
    jcenter()
} 

dependencies {  
    compile "org.springframework.boot:spring-boot-starter-aop:2.1.4.RELEASE"
    providedRuntime "org.springframework.boot:spring-boot-starter-actuator:2.1.4.RELEASE" 
}

TIPS:

  • Add new ‘eclipse-wtp’ plugin to build a eclipse web project.

  • I just want to export ‘spring-boot-starter-aop’ and its transitive dependencies in .war file, excluding spring-boot-starter-actuator and its transitive dependencies.

We can get the dependency tree, by command gradle :dependencies --configuration runtime

+--- org.springframework.boot:spring-boot-starter-aop:2.1.4.RELEASE
|    +--- org.springframework.boot:spring-boot-starter:2.1.4.RELEASE
|    |    +--- org.springframework.boot:spring-boot:2.1.4.RELEASE
|    |    |    +--- org.springframework:spring-core:5.1.6.RELEASE
|    |    |    |    \--- org.springframework:spring-jcl:5.1.6.RELEASE
...
|    \--- org.aspectj:aspectjweaver:1.9.2
\--- org.springframework.boot:spring-boot-starter-actuator:2.1.4.RELEASE
     +--- org.springframework.boot:spring-boot-starter:2.1.4.RELEASE (*)
     +--- org.springframework.boot:spring-boot-actuator-autoconfigure:2.1.4.RELEASE
     |    +--- org.springframework.boot:spring-boot-actuator:2.1.4.RELEASE
     |    |    \--- org.springframework.boot:spring-boot:2.1.4.RELEASE (*)
     |    +--- org.springframework.boot:spring-boot-autoconfigure:2.1.4.RELEASE (*)
     |    +--- com.fasterxml.jackson.core:jackson-databind:2.9.8
     |    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.9.0
     |    |    \--- com.fasterxml.jackson.core:jackson-core:2.9.8
     |    +--- org.springframework:spring-core:5.1.6.RELEASE (*)
     |    +--- org.springframework:spring-context:5.1.6.RELEASE (*)
     |    \--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.8
     |         +--- com.fasterxml.jackson.core:jackson-annotations:2.9.0
     |         +--- com.fasterxml.jackson.core:jackson-core:2.9.8
     |         \--- com.fasterxml.jackson.core:jackson-databind:2.9.8 (*)
     \--- io.micrometer:micrometer-core:1.1.4
          +--- org.hdrhistogram:HdrHistogram:2.1.9
          \--- org.latencyutils:LatencyUtils:2.0.3

But when I execute “gradle build” and get a .war file. The spring-boot-starter and its transitive dependencies are lost.

So, I apply the tailer ‘@jar’ solution.

providedRuntime "org.springframework.boot:spring-boot-starter-actuator:2.1.4.RELEASE@jar" 

the dependencies tree:

+--- org.springframework.boot:spring-boot-starter-aop:2.1.4.RELEASE
|    +--- org.springframework.boot:spring-boot-starter:2.1.4.RELEASE
|    |    +--- org.springframework.boot:spring-boot:2.1.4.RELEASE
.....
|    |    +--- org.springframework.boot:spring-boot-autoconfigure:2.1.4.RELEASE
|    |    |    \--- org.springframework.boot:spring-boot:2.1.4.RELEASE (*)
|    |    +--- org.springframework.boot:spring-boot-starter-logging:2.1.4.RELEASE
|    |    |    +--- ch.qos.logback:logback-classic:1.2.3
|    |    |    |    +--- ch.qos.logback:logback-core:1.2.3
|    |    |    |    \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.26
|    |    |    +--- org.apache.logging.log4j:log4j-to-slf4j:2.11.2
|    |    |    |    +--- org.slf4j:slf4j-api:1.7.25 -> 1.7.26
|    |    |    |    \--- org.apache.logging.log4j:log4j-api:2.11.2
|    |    |    \--- org.slf4j:jul-to-slf4j:1.7.26
|    |    |         \--- org.slf4j:slf4j-api:1.7.26
|    |    +--- javax.annotation:javax.annotation-api:1.3.2
|    |    +--- org.springframework:spring-core:5.1.6.RELEASE (*)
|    |    \--- org.yaml:snakeyaml:1.23
|    +--- org.springframework:spring-aop:5.1.6.RELEASE (*)
|    \--- org.aspectj:aspectjweaver:1.9.2
\--- org.springframework.boot:spring-boot-starter-actuator:2.1.4.RELEASE

We can see the transitive dependencies of spring-boot-starter-actuator are truncated.

It’s work to export war.

However, execute "gradle eclipse " to build a eclipse IDE development environment. The transitive dependencies of spring-boot-starter-actuator are lost.

Actually, I want to keep the transitive dependencies.

Do you have any better solution?

It’s unclear what you want here. When I run eclipse, my .classpath file contains all dependencies that were declared, including those that were excluded from the WAR.

Two goals:

  • The transitive dependencies(e.g. spring-boot-actuator-autoconfigure) must be excluded in WAR file

  • The transitive dependencies(e.g. spring-boot-actuator-autoconfigure)must be including in .classpath file of a eclipse project.

Is there a solution make a trade-off of them?

[Attachment-1] Snapshot of .classpath in eclipse [add ‘@jar’]

[Attachment-2] .classpath file [add ‘@jar’]
.classpath-eclipse.zip (2.0 KB)

You’re back to the original scenario then. Given this build.gradle:

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'eclipse-wtp'

repositories {
    jcenter()
}

dependencies {
    compile "org.springframework.boot:spring-boot-starter-aop:2.1.4.RELEASE"
    providedRuntime "org.springframework.boot:spring-boot-starter-actuator:2.1.4.RELEASE"
}

There are only 2 JARs that will end up in the WAR file, spring-boot-starter-aop-2.1.4.RELEASE.jar and aspectjweaver-1.9.2.jar. Everything else shown is a transitive dependency of spring-boot-starter-actuator and is excluded from the WAR file:

+--- org.springframework.boot:spring-boot-starter-aop:2.1.4.RELEASE
|    +--- org.springframework.boot:spring-boot-starter:2.1.4.RELEASE
|    |    +--- org.springframework.boot:spring-boot:2.1.4.RELEASE
|    |    |    +--- org.springframework:spring-core:5.1.6.RELEASE
|    |    |    |    \--- org.springframework:spring-jcl:5.1.6.RELEASE
|    |    |    \--- org.springframework:spring-context:5.1.6.RELEASE
|    |    |         +--- org.springframework:spring-aop:5.1.6.RELEASE
|    |    |         |    +--- org.springframework:spring-beans:5.1.6.RELEASE
|    |    |         |    |    \--- org.springframework:spring-core:5.1.6.RELEASE (*)
|    |    |         |    \--- org.springframework:spring-core:5.1.6.RELEASE (*)
|    |    |         +--- org.springframework:spring-beans:5.1.6.RELEASE (*)
|    |    |         +--- org.springframework:spring-core:5.1.6.RELEASE (*)
|    |    |         \--- org.springframework:spring-expression:5.1.6.RELEASE
|    |    |              \--- org.springframework:spring-core:5.1.6.RELEASE (*)
|    |    +--- org.springframework.boot:spring-boot-autoconfigure:2.1.4.RELEASE
|    |    |    \--- org.springframework.boot:spring-boot:2.1.4.RELEASE (*)
|    |    +--- org.springframework.boot:spring-boot-starter-logging:2.1.4.RELEASE
|    |    |    +--- ch.qos.logback:logback-classic:1.2.3
|    |    |    |    +--- ch.qos.logback:logback-core:1.2.3
|    |    |    |    \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.26
|    |    |    +--- org.apache.logging.log4j:log4j-to-slf4j:2.11.2
|    |    |    |    +--- org.slf4j:slf4j-api:1.7.25 -> 1.7.26
|    |    |    |    \--- org.apache.logging.log4j:log4j-api:2.11.2
|    |    |    \--- org.slf4j:jul-to-slf4j:1.7.26
|    |    |         \--- org.slf4j:slf4j-api:1.7.26
|    |    +--- javax.annotation:javax.annotation-api:1.3.2
|    |    +--- org.springframework:spring-core:5.1.6.RELEASE (*)
|    |    \--- org.yaml:snakeyaml:1.23
|    +--- org.springframework:spring-aop:5.1.6.RELEASE (*)
|    \--- org.aspectj:aspectjweaver:1.9.2
\--- org.springframework.boot:spring-boot-starter-actuator:2.1.4.RELEASE
     +--- org.springframework.boot:spring-boot-starter:2.1.4.RELEASE (*)
     +--- org.springframework.boot:spring-boot-actuator-autoconfigure:2.1.4.RELEASE
     |    +--- org.springframework.boot:spring-boot-actuator:2.1.4.RELEASE
     |    |    \--- org.springframework.boot:spring-boot:2.1.4.RELEASE (*)
     |    +--- org.springframework.boot:spring-boot-autoconfigure:2.1.4.RELEASE (*)
     |    +--- com.fasterxml.jackson.core:jackson-databind:2.9.8
     |    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.9.0
     |    |    \--- com.fasterxml.jackson.core:jackson-core:2.9.8
     |    +--- org.springframework:spring-core:5.1.6.RELEASE (*)
     |    +--- org.springframework:spring-context:5.1.6.RELEASE (*)
     |    \--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.8
     |         +--- com.fasterxml.jackson.core:jackson-annotations:2.9.0
     |         +--- com.fasterxml.jackson.core:jackson-core:2.9.8
     |         \--- com.fasterxml.jackson.core:jackson-databind:2.9.8 (*)
     \--- io.micrometer:micrometer-core:1.1.4
          +--- org.hdrhistogram:HdrHistogram:2.1.9
          \--- org.latencyutils:LatencyUtils:2.0.3

However, the generated .classpath contains all of the dependencies listed above as entries for classpath:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
	<classpathentry kind="output" path="bin/default"/>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-9/"/>
	<classpathentry kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-aop/2.1.4.RELEASE/39fffcbea8207ca708b7891f3b70c37a33c2dca4/spring-boot-starter-aop-2.1.4.RELEASE.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter/2.1.4.RELEASE/8fa436ef4e273cb476d5dc3aa73701a8837460af/spring-boot-starter-2.1.4.RELEASE.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-autoconfigure/2.1.4.RELEASE/2edd9ce8f7fe3dafb83eef9248b882abc6fe6192/spring-boot-autoconfigure-2.1.4.RELEASE-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-autoconfigure/2.1.4.RELEASE/d5f8b3f7835a23b4dfd8d1489d265c1e426e317b/spring-boot-autoconfigure-2.1.4.RELEASE.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot/2.1.4.RELEASE/fc28861fbd06b8aa6d151f8810a7748a86f1f155/spring-boot-2.1.4.RELEASE-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot/2.1.4.RELEASE/5ad0355a8c810b32b9221b9b92746b51c983337f/spring-boot-2.1.4.RELEASE.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework/spring-context/5.1.6.RELEASE/647293fbac4e4a0805d5440151ebb79cd0bf426b/spring-context-5.1.6.RELEASE-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework/spring-context/5.1.6.RELEASE/7b9e80ab68ee91ca0462a0eb2c58a9d957788b/spring-context-5.1.6.RELEASE.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework/spring-aop/5.1.6.RELEASE/fe960ed9c1ce1dc18613578eda8eefda4df88077/spring-aop-5.1.6.RELEASE-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework/spring-aop/5.1.6.RELEASE/a473d4bca7295f2b90522594e413f9e19107c1d2/spring-aop-5.1.6.RELEASE.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.aspectj/aspectjweaver/1.9.2/7aa564f5753105f884c50bc84ffa49a282c10a00/aspectjweaver-1.9.2-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.aspectj/aspectjweaver/1.9.2/d2502817521477faf0712c49a6ee2a5388787fc7/aspectjweaver-1.9.2.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-logging/2.1.4.RELEASE/2fb669a89cd65b275be20ab755c3742399395dff/spring-boot-starter-logging-2.1.4.RELEASE.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/javax.annotation/javax.annotation-api/1.3.2/65dfd2c47380bf72ec62a5b8c4ceb78a4eda1a53/javax.annotation-api-1.3.2-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/javax.annotation/javax.annotation-api/1.3.2/934c04d3cfef185a8008e7bf34331b79730a9d43/javax.annotation-api-1.3.2.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework/spring-beans/5.1.6.RELEASE/edd8534e9e343663a18560cc465c49f9d93ca097/spring-beans-5.1.6.RELEASE-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework/spring-beans/5.1.6.RELEASE/90d2f4bf7eced108de0b5bf617abb2b13a6206a3/spring-beans-5.1.6.RELEASE.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework/spring-expression/5.1.6.RELEASE/6e026ead3c18350b7ff47ec6f69326964d30abd3/spring-expression-5.1.6.RELEASE-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework/spring-expression/5.1.6.RELEASE/50fe4080029e43e7612e50fb4d7c7c43e95bf03c/spring-expression-5.1.6.RELEASE.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.1.6.RELEASE/aa74700198d24e1ed8b3c8ad663ad50733658ac6/spring-core-5.1.6.RELEASE-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.1.6.RELEASE/9329591e728ef9844911e082e399f4fc3e3ecb37/spring-core-5.1.6.RELEASE.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.3/cfd5385e0c5ed1c8a5dce57d86e79cf357153a64/logback-classic-1.2.3-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.3/7c4f3c474fb2c041d8028740440937705ebb473a/logback-classic-1.2.3.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-to-slf4j/2.11.2/5b26345d96fce28b017316c5840484e0e929fa33/log4j-to-slf4j-2.11.2-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-to-slf4j/2.11.2/6d37bf7b046c0ce2669f26b99365a2cfa45c4c18/log4j-to-slf4j-2.11.2.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.slf4j/jul-to-slf4j/1.7.26/74d35fd39913770cb0213e0ca418f485ed69ce4c/jul-to-slf4j-1.7.26-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.slf4j/jul-to-slf4j/1.7.26/8031352b2bb0a49e67818bf04c027aa92e645d5c/jul-to-slf4j-1.7.26.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework/spring-jcl/5.1.6.RELEASE/e5cf3ba1dc3bb1127ea8a591f4afd88fc706a27a/spring-jcl-5.1.6.RELEASE-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework/spring-jcl/5.1.6.RELEASE/a4ad3c98c7cc31357e94e12772c8e6449522bc5/spring-jcl-5.1.6.RELEASE.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-core/1.2.3/3ebabe69eba0196af9ad3a814f723fb720b9101e/logback-core-1.2.3-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-core/1.2.3/864344400c3d4d92dfeb0a305dc87d953677c03c/logback-core-1.2.3.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.26/21c84cdf9da108216b5e402611d4af479b60cb8/slf4j-api-1.7.26-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.26/77100a62c2e6f04b53977b9f541044d7d722693d/slf4j-api-1.7.26.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-api/2.11.2/a11bdc0e8f95da31527b4f34f1a35c23e197498d/log4j-api-2.11.2-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-api/2.11.2/f5e9a2ffca496057d6891a3de65128efc636e26e/log4j-api-2.11.2.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-actuator/2.1.4.RELEASE/3f3897febeecb4c3243e5a31bee769e4d9fd9445/spring-boot-starter-actuator-2.1.4.RELEASE.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-actuator-autoconfigure/2.1.4.RELEASE/c027f7a73ccb2b25552d8175b673f86f397e8e7e/spring-boot-actuator-autoconfigure-2.1.4.RELEASE-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-actuator-autoconfigure/2.1.4.RELEASE/c17cc820eb7c4b1a95d05aaac806c3acc784c01/spring-boot-actuator-autoconfigure-2.1.4.RELEASE.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-actuator/2.1.4.RELEASE/5c9359b8e12143fb4bb664a67be95120625dfe32/spring-boot-actuator-2.1.4.RELEASE-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-actuator/2.1.4.RELEASE/fdafe5167dc886e116cf07ef552a4229e93883af/spring-boot-actuator-2.1.4.RELEASE.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/io.micrometer/micrometer-core/1.1.4/4eccaad660022eb7154fc3f4db3dd0bcd6cbc9e7/micrometer-core-1.1.4-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/io.micrometer/micrometer-core/1.1.4/96eabfe2343a4a4676d215b2122cbbc4d4b6af9b/micrometer-core-1.1.4.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.yaml/snakeyaml/1.23/1186bcf89d33080275bab74a0b0f495af5c812ef/snakeyaml-1.23-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.yaml/snakeyaml/1.23/ec62d74fe50689c28c0ff5b35d3aebcaa8b5be68/snakeyaml-1.23.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.9.8/b452bf6ebfe953921def884eb2e746218d6e2489/jackson-datatype-jsr310-2.9.8-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.9.8/28ad1bced632ba338e51c825a652f6e11a8e6eac/jackson-datatype-jsr310-2.9.8.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.9.8/f66792d499a6fea6c7a743558f940e0ebf775ce3/jackson-databind-2.9.8-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.9.8/11283f21cc480aa86c4df7a0a3243ec508372ed2/jackson-databind-2.9.8.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.hdrhistogram/HdrHistogram/2.1.9/966a6429061192e62cc346462587253a726db6b7/HdrHistogram-2.1.9-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.hdrhistogram/HdrHistogram/2.1.9/e4631ce165eb400edecfa32e03d3f1be53dee754/HdrHistogram-2.1.9.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.latencyutils/LatencyUtils/2.0.3/fbc38259e2077a428984637d811dac542a6a913e/LatencyUtils-2.0.3-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/org.latencyutils/LatencyUtils/2.0.3/769c0b82cb2421c8256300e907298a9410a2a3d3/LatencyUtils-2.0.3.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.9.0/a0ad4e203304ccab7e01266fa814115850edb8a9/jackson-annotations-2.9.0-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.9.0/7c10d545325e3a6e72e06381afe469fd40eb701/jackson-annotations-2.9.0.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.9.8/ecaea301e166a0b48f11615864246de739b6619b/jackson-core-2.9.8-sources.jar" kind="lib" path="/Users/jjustinic/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.9.8/f5a654e4675769c716e5b387830d19b501ca191/jackson-core-2.9.8.jar">
		<attributes>
			<attribute name="gradle_used_by_scope" value="main,test"/>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
</classpath>

There isn’t any trade-off here. This does what you’re saying you want it to do, so there must be some detail you’re expecting that isn’t being captured.

Yes, I am thinking about why maven can work .

<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.boot</groupId>
      <artifactId>spring-boot-starter-aop</artifactId>
      <version>2.1.4.RELEASE</version> 
    </dependency> 
	    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
      <version>2.1.4.RELEASE</version> 
	  <scope>provided</scope>
    </dependency>  
  </dependencies>
  <build>
    <finalName>Blank-deps</finalName>
  </build>
</project>
Overview of WAR file after 'mvn package' command

This artifact is my want.

Maven can resolve both (eclipse and WAR).

How can I archive that? :disappointed_relieved:
@jjustinic

I don’t have an example to test this on, but have you experimented with transitive:false on your providedRuntime dependency?

Unfortunately, it’s hard to answer your question because there’s contradictions in what you’re requesting.

For example,

If you want the transitive dependencies of spring-boot-starter-actuator excluded from the WAR, the WAR should only include two JAR files, aspectjweaver-1.9.2.jar and spring-boot-starter-aop-2.1.4.RELEASE.jar. The other 18 JARs listed in WEB-INF/lib of your Blank-deps.war file are transitive dependencies of spring-boot-starter-actuator, so excluding these transitive dependencies is clearly not what you want.

Sure, but what it resolves is technically incorrect. Maven’s provided scope is not transitive, and therefore spring-boot-starter-actuator and its transitive dependencies do not impact your WAR file. You have exactly the WAR that would be created if org.springframework.boot:spring-boot-starter-aop:2.1.4.RELEASE was listed as your only dependency.

However, eclipse is including org.springframework.boot:spring-boot-starter-aop:2.1.4.RELEASE and all of its transitive dependencies on the compile and runtime classpaths in the IDE. This is not ideal because it means that you now have classes available in the IDE that might not be available when the WAR runs in the application container.

Gradle strives to more accurately model the domain of build automation. When what you have is correctly modeled, you’re going to get the correct results for the WAR and eclipse. The most important item for this is what JARs are actually being provided externally from the WAR file through the container? If it’s only the spring-boot-starter-actuator-2.1.4.RELEASE.jar, you’re technically missing JARs that would be needed in the WAR. If it’s spring-boot-starter-actuator-2.1.4.RELEASE.jar AND its transitive dependencies, you need less in the WAR. If it’s something in between, then that exact list is important. If there’s exclusions you want to make for other reasons, those are important too. The Gradle dependencies need to be configured with those details.

Is there a workround solution that fits for both ‘eclipse’ and ‘build’ task?

Eclipse task

gradle eclipse 

My build.gradle file:

providedRuntime "org.springframework.boot:spring-boot-starter-actuator:2.1.4.RELEASE"

Reason:

  • The tailer ‘@jar’ will cause missing the transitive dependencies of spring-boot-starter-actuator in .classpath file(Eclipse IDE configuration file).

  • It also hard to fit the scence of the jar -jar <.war> running mode.

Build Task

gradle build

My build.gradle file change to :

providedRuntime "org.springframework.boot:spring-boot-starter-actuator:2.1.4.RELEASE@jar"