blob: ce82730d6999d530c137724034348d5a0455c7c5 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import me.champeau.gradle.japicmp.JapicmpTask
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'me.champeau.gradle:japicmp-gradle-plugin:0.2.6'
}
}
task checkBinaryCompatibility {
description = 'Generates binary compatibility reports'
}
check.dependsOn(checkBinaryCompatibility)
// for comparing between versions with different modules, set excludeModules to differing modules, e.g.
def excludeModules = [
'groovy-cli-picocli', 'groovy-cli-commons', 'groovy-dateutil', 'groovy-datetime', 'groovy-jaxb',
'groovy-macro', 'groovy-json-direct', 'groovy-test-junit5', 'performance', 'tests-vm8'
]
//def excludeModules = []
Set projectsToCheck = allprojects.findAll{ !(it.name in excludeModules) }
def compatibilityBaselineVersion = '2.4.16'
allprojects {
if (project in projectsToCheck) {
// Use a detached configuration, otherwise the current version's jar will take precedence over the baseline jar.
// A necessary hack, the intuitive thing does NOT work:
// https://discuss.gradle.org/t/is-the-default-configuration-leaking-into-independent-configurations/2088/6
def saveGroup = project.group
def detachedConf
try {
project.group = 'virtual_group_for_japicmp'
String depModule = "org.codehaus.groovy:${project.name}:${compatibilityBaselineVersion}@jar"
String depJar = "${project.name}-${compatibilityBaselineVersion}.jar"
detachedConf = configurations.detachedConfiguration(
dependencies.create(depModule)
)
} finally {
project.group = saveGroup
}
task japicmp(type: JapicmpTask, dependsOn: jarjar) {
oldClasspath = files({
files(detachedConf.files).filter {
it.name.equals(depJar)
}.singleFile})
newArchives = files(jarjar.outputFile)
newClasspath = configurations.runtimeClasspath
accessModifier = 'protected'
onlyModified = true
failOnModification = false
ignoreMissingClasses = true
classExcludes = ['**_closure**','org.codehaus.groovy.runtime.dgm$**']
packageExcludes = ['**internal**','groovyjarjar**']
htmlOutputFile = file("$buildDir/reports/japi.html")
}
}
}
allprojects {
tasks.withType(JapicmpTask) { task ->
checkBinaryCompatibility.dependsOn(task)
}
}