@@ -9,19 +9,25 @@ import org.gradle.api.attributes.Usage
9
9
import org.gradle.api.internal.DefaultDomainObjectSet
10
10
import org.gradle.api.internal.component.SoftwareComponentInternal
11
11
import org.gradle.api.internal.component.UsageContext
12
+ import org.gradle.api.model.ObjectFactory
12
13
13
14
class AndroidLibrary implements SoftwareComponentInternal {
14
15
15
16
private final UsageContext runtimeUsage
16
17
17
18
public static AndroidLibrary newInstance (Project project ) {
19
+
20
+ ObjectFactory objectFactory = project. getObjects();
21
+ Usage usage = objectFactory. named(Usage . class, Usage . JAVA_RUNTIME );
22
+
23
+
18
24
def configuration = project. configurations. getByName(" compile" )
19
- return configuration ? from(configuration) : empty()
25
+ return configuration ? from(configuration, usage ) : empty()
20
26
}
21
27
22
- static AndroidLibrary from (def configuration ) {
23
- def usage = new RuntimeUsage (configuration. dependencies)
24
- new AndroidLibrary (usage )
28
+ static AndroidLibrary from (def configuration , Usage usage ) {
29
+ def runtimeUsage = new RuntimeUsage (configuration. dependencies, usage )
30
+ new AndroidLibrary (runtimeUsage )
25
31
}
26
32
27
33
static AndroidLibrary empty () {
@@ -44,13 +50,15 @@ class AndroidLibrary implements SoftwareComponentInternal {
44
50
private static class RuntimeUsage implements UsageContext {
45
51
46
52
private final DomainObjectSet<Dependency > runtimeDependencies
53
+ private final Usage usage;
47
54
48
- RuntimeUsage (DomainObjectSet<Dependency > runtimeDependencies ) {
55
+ RuntimeUsage (DomainObjectSet<Dependency > runtimeDependencies , Usage usage ) {
56
+ this . usage = usage;
49
57
this . runtimeDependencies = runtimeDependencies
50
58
}
51
59
52
60
Usage getUsage () {
53
- return Usage . FOR_RUNTIME
61
+ return usage;
54
62
}
55
63
56
64
public Set<PublishArtifact > getArtifacts () {
0 commit comments