java为什么将具有运行时作用域的库添加到debugCompileClasspath?
如果我将我的库添加到项目中,并运行命令:
> gradlew -q app:dependencies --configuration debugCompileClasspath > app_dependencies_compile.txt
为什么com.github.kolyall:utils:1.0.4
lib在CompileClasspath
中获得了com.安卓.support:appcompat-v7
lib(和其他)和runtime
作用域?如果它们的作用域应该是runtime
,为什么要将它们添加到CompileClasspath
输出为:
\--- com.github.kolyall:utils:1.0.4
+--- net.danlew:安卓.joda:2.8.2
| \--- joda-time:joda-time:2.8.2
+--- com.安卓.support:appcompat-v7:28.0.0-alpha3 -> 28.0.0 (*)
+--- com.安卓.support:design:28.0.0-alpha3
| +--- com.安卓.support:support-annotations:28.0.0-alpha3 -> 28.0.0
| +--- com.安卓.support:support-compat:28.0.0-alpha3 -> 28.0.0 (*)
| +--- com.安卓.support:support-core-ui:28.0.0-alpha3 -> 28.0.0 (*)
| +--- com.安卓.support:support-core-utils:28.0.0-alpha3 -> 28.0.0 (*)
| +--- com.安卓.support:support-fragment:28.0.0-alpha3 -> 28.0.0 (*)
| +--- com.安卓.support:transition:28.0.0-alpha3
| | +--- com.安卓.support:support-annotations:28.0.0-alpha3 -> 28.0.0
| | \--- com.安卓.support:support-compat:28.0.0-alpha3 -> 28.0.0 (*)
| +--- com.安卓.support:appcompat-v7:28.0.0-alpha3 -> 28.0.0 (*)
| +--- com.安卓.support:cardview-v7:28.0.0-alpha3
| | \--- com.安卓.support:support-annotations:28.0.0-alpha3 -> 28.0.0
| \--- com.安卓.support:recyclerview-v7:28.0.0-alpha3
| +--- com.安卓.support:support-annotations:28.0.0-alpha3 -> 28.0.0
| +--- com.安卓.support:support-compat:28.0.0-alpha3 -> 28.0.0 (*)
| \--- com.安卓.support:support-core-ui:28.0.0-alpha3 -> 28.0.0 (*)
+--- io.reactivex:rxjava:1.3.0
+--- io.reactivex:rx安卓:1.2.1
\--- javax.annotation:jsr250-api:1.0
完整输出为:
Executing tasks: [dependencies, --configuration, debugCompileClasspath]
:app:dependencies
------------------------------------------------------------
Project :app
------------------------------------------------------------
debugCompileClasspath - Resolved configuration for compilation for variant: debug
+--- com.安卓.support:appcompat-v7:28.0.0
| +--- com.安卓.support:support-annotations:28.0.0
| +--- com.安卓.support:support-compat:28.0.0
| | +--- com.安卓.support:support-annotations:28.0.0
| | +--- com.安卓.support:collections:28.0.0
| | | \--- com.安卓.support:support-annotations:28.0.0
| | +--- 安卓.arch.lifecycle:runtime:1.1.1
| | | +--- 安卓.arch.lifecycle:common:1.1.1
| | | | \--- com.安卓.support:support-annotations:26.1.0 -> 28.0.0
| | | +--- 安卓.arch.core:common:1.1.1
| | | | \--- com.安卓.support:support-annotations:26.1.0 -> 28.0.0
| | | \--- com.安卓.support:support-annotations:26.1.0 -> 28.0.0
| | \--- com.安卓.support:versionedparcelable:28.0.0
| | +--- com.安卓.support:support-annotations:28.0.0
| | \--- com.安卓.support:collections:28.0.0 (*)
| +--- com.安卓.support:collections:28.0.0 (*)
| +--- com.安卓.support:cursoradapter:28.0.0
| | \--- com.安卓.support:support-annotations:28.0.0
| +--- com.安卓.support:support-core-utils:28.0.0
| | +--- com.安卓.support:support-annotations:28.0.0
| | +--- com.安卓.support:support-compat:28.0.0 (*)
| | +--- com.安卓.support:documentfile:28.0.0
| | | \--- com.安卓.support:support-annotations:28.0.0
| | +--- com.安卓.support:loader:28.0.0
| | | +--- com.安卓.support:support-annotations:28.0.0
| | | +--- com.安卓.support:support-compat:28.0.0 (*)
| | | +--- 安卓.arch.lifecycle:livedata:1.1.1
| | | | +--- 安卓.arch.core:runtime:1.1.1
| | | | | +--- com.安卓.support:support-annotations:26.1.0 -> 28.0.0
| | | | | \--- 安卓.arch.core:common:1.1.1 (*)
| | | | +--- 安卓.arch.lifecycle:livedata-core:1.1.1
| | | | | +--- 安卓.arch.lifecycle:common:1.1.1 (*)
| | | | | +--- 安卓.arch.core:common:1.1.1 (*)
| | | | | \--- 安卓.arch.core:runtime:1.1.1 (*)
| | | | \--- 安卓.arch.core:common:1.1.1 (*)
| | | \--- 安卓.arch.lifecycle:viewmodel:1.1.1
| | | \--- com.安卓.support:support-annotations:26.1.0 -> 28.0.0
| | +--- com.安卓.support:localbroadcastmanager:28.0.0
| | | \--- com.安卓.support:support-annotations:28.0.0
| | \--- com.安卓.support:print:28.0.0
| | \--- com.安卓.support:support-annotations:28.0.0
| +--- com.安卓.support:support-fragment:28.0.0
| | +--- com.安卓.support:support-compat:28.0.0 (*)
| | +--- com.安卓.support:support-core-ui:28.0.0
| | | +--- com.安卓.support:support-annotations:28.0.0
| | | +--- com.安卓.support:support-compat:28.0.0 (*)
| | | +--- com.安卓.support:support-core-utils:28.0.0 (*)
| | | +--- com.安卓.support:customview:28.0.0
| | | | +--- com.安卓.support:support-annotations:28.0.0
| | | | \--- com.安卓.support:support-compat:28.0.0 (*)
| | | +--- com.安卓.support:viewpager:28.0.0
| | | | +--- com.安卓.support:support-annotations:28.0.0
| | | | +--- com.安卓.support:support-compat:28.0.0 (*)
| | | | \--- com.安卓.support:customview:28.0.0 (*)
| | | +--- com.安卓.support:coordinatorlayout:28.0.0
| | | | +--- com.安卓.support:support-annotations:28.0.0
| | | | +--- com.安卓.support:support-compat:28.0.0 (*)
| | | | \--- com.安卓.support:customview:28.0.0 (*)
| | | +--- com.安卓.support:drawerlayout:28.0.0
| | | | +--- com.安卓.support:support-annotations:28.0.0
| | | | +--- com.安卓.support:support-compat:28.0.0 (*)
| | | | \--- com.安卓.support:customview:28.0.0 (*)
| | | +--- com.安卓.support:slidingpanelayout:28.0.0
| | | | +--- com.安卓.support:support-annotations:28.0.0
| | | | +--- com.安卓.support:support-compat:28.0.0 (*)
| | | | \--- com.安卓.support:customview:28.0.0 (*)
| | | +--- com.安卓.support:interpolator:28.0.0
| | | | \--- com.安卓.support:support-annotations:28.0.0
| | | +--- com.安卓.support:swiperefreshlayout:28.0.0
| | | | +--- com.安卓.support:support-annotations:28.0.0
| | | | +--- com.安卓.support:support-compat:28.0.0 (*)
| | | | \--- com.安卓.support:interpolator:28.0.0 (*)
| | | +--- com.安卓.support:asynclayoutinflater:28.0.0
| | | | +--- com.安卓.support:support-annotations:28.0.0
| | | | \--- com.安卓.support:support-compat:28.0.0 (*)
| | | \--- com.安卓.support:cursoradapter:28.0.0 (*)
| | +--- com.安卓.support:support-core-utils:28.0.0 (*)
| | +--- com.安卓.support:support-annotations:28.0.0
| | +--- com.安卓.support:loader:28.0.0 (*)
| | \--- 安卓.arch.lifecycle:viewmodel:1.1.1 (*)
| +--- com.安卓.support:support-vector-drawable:28.0.0
| | +--- com.安卓.support:support-annotations:28.0.0
| | \--- com.安卓.support:support-compat:28.0.0 (*)
| \--- com.安卓.support:animated-vector-drawable:28.0.0
| +--- com.安卓.support:support-vector-drawable:28.0.0 (*)
| \--- com.安卓.support:support-core-ui:28.0.0 (*)
+--- com.安卓.support.constraint:constraint-layout:1.1.3
| \--- com.安卓.support.constraint:constraint-layout-solver:1.1.3
\--- com.github.kolyall:utils:1.0.4
+--- net.danlew:安卓.joda:2.8.2
| \--- joda-time:joda-time:2.8.2
+--- com.安卓.support:appcompat-v7:28.0.0-alpha3 -> 28.0.0 (*)
+--- com.安卓.support:design:28.0.0-alpha3
| +--- com.安卓.support:support-annotations:28.0.0-alpha3 -> 28.0.0
| +--- com.安卓.support:support-compat:28.0.0-alpha3 -> 28.0.0 (*)
| +--- com.安卓.support:support-core-ui:28.0.0-alpha3 -> 28.0.0 (*)
| +--- com.安卓.support:support-core-utils:28.0.0-alpha3 -> 28.0.0 (*)
| +--- com.安卓.support:support-fragment:28.0.0-alpha3 -> 28.0.0 (*)
| +--- com.安卓.support:transition:28.0.0-alpha3
| | +--- com.安卓.support:support-annotations:28.0.0-alpha3 -> 28.0.0
| | \--- com.安卓.support:support-compat:28.0.0-alpha3 -> 28.0.0 (*)
| +--- com.安卓.support:appcompat-v7:28.0.0-alpha3 -> 28.0.0 (*)
| +--- com.安卓.support:cardview-v7:28.0.0-alpha3
| | \--- com.安卓.support:support-annotations:28.0.0-alpha3 -> 28.0.0
| \--- com.安卓.support:recyclerview-v7:28.0.0-alpha3
| +--- com.安卓.support:support-annotations:28.0.0-alpha3 -> 28.0.0
| +--- com.安卓.support:support-compat:28.0.0-alpha3 -> 28.0.0 (*)
| \--- com.安卓.support:support-core-ui:28.0.0-alpha3 -> 28.0.0 (*)
+--- io.reactivex:rxjava:1.3.0
+--- io.reactivex:rx安卓:1.2.1
\--- javax.annotation:jsr250-api:1.0
(*) - dependencies omitted (listed previously)
BUILD SUCCESSFUL in 0s
1 actionable task: 1 executed
应用程序。格拉德尔
apply plugin: 'com.安卓.application'
安卓 {
compileSdkVersion 28
defaultConfig {
applicationId "com.example"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "安卓.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-安卓.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.安卓.support:appcompat-v7:28.0.0-rc01'
implementation 'com.github.kolyall:utils:1.0.4'
}
这是*。pom文件from my lib:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.kolyall</groupId>
<artifactId>utils</artifactId>
<version>1.0.4</version>
<packaging>aar</packaging>
<name>utils</name>
<description>A wrapper for utils on Android</description>
<url>https://github.com/Kolyall/BaseUtils</url>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<developers>
<developer>
<id>nickunuchek</id>
<name>Nick Unuchek</name>
<email>kolyall@tut.by</email>
</developer>
</developers>
<scm>
<connection>https://github.com/Kolyall/BaseUtils.git</connection>
<developerConnection>https://github.com/Kolyall/BaseUtils.git</developerConnection>
<url>https://github.com/Kolyall/BaseUtils</url>
</scm>
<dependencies>
<dependency>
<groupId>net.danlew</groupId>
<artifactId>安卓.joda</artifactId>
<version>2.8.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.安卓.support</groupId>
<artifactId>appcompat-v7</artifactId>
<version>28.0.0-alpha3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.安卓.support</groupId>
<artifactId>design</artifactId>
<version>28.0.0-alpha3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.reactivex</groupId>
<artifactId>rxjava</artifactId>
<version>1.3.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.reactivex</groupId>
<artifactId>rx安卓</artifactId>
<version>1.2.1</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<artifactId>rxjava</artifactId>
<groupId>io.reactivex</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
<version>1.0</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
# 1 楼答案
在
Gradle 5.0
之前,gradle不支持IMPROVED_POM_SUPPORT
,因此默认情况下,它将所有可传递依赖项都视为compile
。(不支持非罐子包装。)这在
Gradle 5.0
中得到了修复,其中IMPROVED_POM_SUPPORT
被设置为默认行为虽然这不是强制性的,但告诉gradle提供的依赖关系是android存档使用的一个好做法
在gradle中声明依赖关系时。注意@aar在library的版本之后
现在将gradle升级到5.0或更高版本后
compileClasspath输出为