forked from pniederw/elastic-deps
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
62 lines (52 loc) · 2.04 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import org.gradle.api.internal.artifacts.dependencies.*
import org.gradle.logging.StyledTextOutput
import org.gradle.logging.StyledTextOutput.Style
import org.gradle.logging.StyledTextOutputFactory
version=System.nanoTime()
subprojects {
apply plugin: "java"
apply plugin: "maven"
group = "mycompany"
repositories {
mavenLocal()
}
configurations.all { configuration ->
resolutionStrategy {
eachDependency { details ->
def p1 = rootProject.subprojects.find { it.group == details.requested.group && it.name == details.requested.name }
if( p1 != null && p1.version != details.requested.version){
def staticRef = false;
configuration.hierarchy.each { hconf ->
def z=hconf.dependencies.find { it instanceof ProjectDependency && it.group == details.requested.group && it.name == details.requested.name }
staticRef = staticRef || z
}
if( staticRef != false ){
logger.lifecycle "hiding binary of '${details.requested}' in [${project}] "
useTarget 'junit:junit:4.10' // this should be some empty project which can be referenced in cases like this
}else{
StyledTextOutput o = services.get(StyledTextOutputFactory).create(this.class)
o.style(Style.Failure).text('============================================= ').println()
o.style(Style.Info).text("${project}: ")
o.style(Style.Failure).text('binary/source clash detected')
o.println()
o.style(Style.Header).text('please use:')
o.println()
o.style(Style.UserInput).text(" dependencies.${configuration.name} elastic(??? '${details.requested.name}','${details.requested.name}')")
o.println()
o.style(Style.Failure).text('=============================================').println()
useVersion 'nonexistent'
}
}
}
}
}
}
def elastic(notation, projectName) {
if (allprojects.find { it.name == projectName }) {
println "adding project dependency on project $projectName"
project(projectName)
} else {
println "adding binary dependency on project $projectName"
dependencies.create(notation)
}
}