-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: scan all subprojects when selecting attributes for conifguration (…
…#81)
- Loading branch information
Konstantin Yegupov
authored
Jun 26, 2019
1 parent
3ac5b5c
commit 1125014
Showing
6 changed files
with
194 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
test/fixtures/multi-config-attributes-subproject/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
apply plugin: 'java' | ||
apply plugin: 'maven' | ||
|
||
group = 'com.github.jitpack' | ||
|
||
sourceCompatibility = 1.8 // java 8 | ||
targetCompatibility = 1.8 | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
// See https://docs.gradle.org/current/userguide/dependency_management_attribute_based_matching.html | ||
|
||
def specificAttr = Attribute.of("specificAttr", String) | ||
def commonAttr = Attribute.of("specificAttr", String) | ||
def usageAttr = null | ||
|
||
if (project.hasProperty('objects')) { | ||
usageAttr = Attribute.of("org.gradle.usage", Usage) | ||
// Gradle 4+ | ||
configurations { | ||
apiConf { | ||
attributes { | ||
attribute(usageAttr, project.objects.named(Usage, "java-api")) | ||
attribute(specificAttr, "rootprojValue") | ||
attribute(commonAttr, "common") | ||
} | ||
} | ||
runtimeConf { | ||
attributes { | ||
attribute(usageAttr, project.objects.named(Usage, "java-runtime")) | ||
attribute(specificAttr, "rootprojValue") | ||
attribute(commonAttr, "common") | ||
} | ||
} | ||
} | ||
} else { | ||
// Gradle 3 | ||
usageAttr = Attribute.of('usage', String) | ||
configurations { | ||
apiConf { | ||
attributes { | ||
attribute(usageAttr, "java-api") | ||
attribute(specificAttr, "rootprojValue") | ||
attribute(commonAttr, "common") | ||
} | ||
} | ||
runtimeConf { | ||
attributes { | ||
attribute(usageAttr, "java-runtime") | ||
attribute(specificAttr, "rootprojValue") | ||
attribute(commonAttr, "common") | ||
} | ||
} | ||
} | ||
} | ||
|
||
dependencies.attributesSchema { | ||
attribute(specificAttr) | ||
attribute(usageAttr) | ||
|
||
println('SNYKECHO compatchain ' + attribute(specificAttr).compatibilityRules) | ||
} | ||
|
||
|
||
dependencies { | ||
compile 'com.google.guava:guava:18.0' | ||
apiConf 'commons-httpclient:commons-httpclient:3.1' | ||
runtimeConf 'org.apache.commons:commons-lang3:3.8.1' | ||
compile project(':subproj') | ||
} | ||
|
||
task sourcesJar(type: Jar, dependsOn: classes) { | ||
classifier = 'sources' | ||
from sourceSets.main.allSource | ||
} | ||
|
||
task javadocJar(type: Jar, dependsOn: javadoc) { | ||
classifier = 'javadoc' | ||
from javadoc.destinationDir | ||
} | ||
|
||
artifacts { | ||
archives sourcesJar | ||
archives javadocJar | ||
} | ||
|
||
// To specify a license in the pom: | ||
install { | ||
repositories.mavenInstaller { | ||
pom.project { | ||
licenses { | ||
license { | ||
name 'The Apache Software License, Version 2.0' | ||
url 'http://www.apache.org/licenses/LICENSE-2.0.txt' | ||
distribution 'repo' | ||
} | ||
} | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
test/fixtures/multi-config-attributes-subproject/settings.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
rootProject.name = 'root-proj' | ||
|
||
include 'subproj' |
60 changes: 60 additions & 0 deletions
60
test/fixtures/multi-config-attributes-subproject/subproj/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
apply plugin: 'java' | ||
apply plugin: 'maven' | ||
|
||
group = 'com.github.jitpack' | ||
|
||
sourceCompatibility = 1.8 // java 8 | ||
targetCompatibility = 1.8 | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
def specificAttr = Attribute.of("specificAttr", String) | ||
def commonAttr = Attribute.of("specificAttr", String) | ||
def usageAttr = null | ||
|
||
if (project.hasProperty('objects')) { | ||
usageAttr = Attribute.of("org.gradle.usage", Usage) | ||
// Gradle 4+ | ||
configurations { | ||
apiConf { | ||
attributes { | ||
attribute(usageAttr, project.objects.named(Usage, "java-api")) | ||
attribute(specificAttr, "subproj1Value") | ||
attribute(commonAttr, "common") | ||
} | ||
} | ||
runtimeConf { | ||
attributes { | ||
attribute(usageAttr, project.objects.named(Usage, "java-runtime")) | ||
attribute(specificAttr, "subproj1Value") | ||
attribute(commonAttr, "common") | ||
} | ||
} | ||
} | ||
} else { | ||
// Gradle 3 | ||
usageAttr = Attribute.of('usage', String) | ||
configurations { | ||
apiConf { | ||
attributes { | ||
attribute(usageAttr, "java-api") | ||
attribute(specificAttr, "subproj1Value") | ||
attribute(commonAttr, "common") | ||
} | ||
} | ||
runtimeConf { | ||
attributes { | ||
attribute(usageAttr, "java-runtime") | ||
attribute(specificAttr, "subproj2Value") | ||
attribute(commonAttr, "common") | ||
} | ||
} | ||
} | ||
} | ||
|
||
dependencies.attributesSchema { | ||
attribute(specificAttr) | ||
attribute(usageAttr) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters