blob: 50b83ace727aa48d622dc6aaee2e12c57e36b825 [file] [log] [blame]
// ASM: a very small and fast Java bytecode manipulation framework
// Copyright (c) 2000-2011 INRIA, France Telecom
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the copyright holders nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
// THE POSSIBILITY OF SUCH DAMAGE.
buildscript {
repositories { mavenCentral() }
}
plugins { id 'biz.aQute.bnd.builder' version '3.3.0' apply false }
plugins { id 'com.github.sherter.google-java-format' version '0.6' apply false }
plugins { id 'me.champeau.gradle.jmh' version '0.4.4' apply false }
plugins { id 'org.sonarqube' version '2.6' apply false }
description = 'ASM, a very small and fast Java bytecode manipulation framework'
subprojects {
repositories { mavenCentral() }
apply plugin: 'java'
def snapshotSuffix = rootProject.hasProperty('release') ? '' : '-SNAPSHOT'
group = 'org.ow2.asm'
version = '6.1.2' + snapshotSuffix
sourceCompatibility = '1.6'
targetCompatibility = '1.6'
test { useJUnitPlatform() }
ext.provides = [] // The provided java packages, e.g. ['org.objectweb.asm']
ext.requires = [] // The required Gradle projects, e.g. [':asm-test']
ext.depends = [] // The external dependencies, e.g. ['junit:junit:4.12']
ext.minCodeCoverage = 0.95 // The minimum code coverage fraction.
}
// -----------------------------------------------------------------------------
// Project descriptions
// -----------------------------------------------------------------------------
project(':asm') {
description = parent.description
provides = ['org.objectweb.asm', 'org.objectweb.asm.signature']
}
project(':asm-analysis') {
description = "Static code analysis API of ${parent.description}"
provides = ['org.objectweb.asm.tree.analysis']
requires = [':asm-tree']
}
project(':asm-commons') {
description = "Usefull class adapters based on ${parent.description}"
provides = ['org.objectweb.asm.commons']
requires = [':asm', ':asm-tree', ':asm-analysis']
dependencies { testCompile project(':asm-util') }
}
project(':asm-test') {
description = "Utilities for testing ${parent.description}"
provides = ['org.objectweb.asm.test']
depends = ['org.junit.jupiter:junit-jupiter-api:5.1.0',
'org.junit.jupiter:junit-jupiter-params:5.1.0']
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
project(':asm-tree') {
description = "Tree API of ${parent.description}"
provides = ['org.objectweb.asm.tree']
requires = [':asm']
}
project(':asm-util') {
description = "Utilities for ${parent.description}"
provides = ['org.objectweb.asm.util']
requires = [':asm', ':asm-tree', ':asm-analysis']
dependencies { testCompile 'org.codehaus.janino:janino:3.0.7' }
}
project(':asm-xml') {
description = "XML API of ${parent.description}"
provides = ['org.objectweb.asm.xml']
requires = [':asm', ':asm-util']
minCodeCoverage = 0.8
}
project(':benchmarks') {
description = "Benchmarks for ${rootProject.description}"
apply plugin: 'me.champeau.gradle.jmh'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
dependencies {
compile files('libs/csg-bytecode-1.0.0.jar', 'libs/jclasslib.jar')
jmh project(':asm'), project(':asm-tree')
}
depends = [
'kawa:kawa:1.7',
'net.sf.jiapi:jiapi-reflect:0.5.2',
'net.sourceforge.serp:serp:1.15.1',
'org.apache.bcel:bcel:6.0',
'org.aspectj:aspectjweaver:1.8.10',
'org.cojen:cojen:2.2.5',
'org.javassist:javassist:3.21.0-GA',
'org.mozilla:rhino:1.7.7.1'
]
['4.0', '5.0.1', '6.0'].each { version ->
configurations.create("asm${version}")
dependencies.add("asm${version}", "org.ow2.asm:asm:${version}@jar")
dependencies.add("asm${version}", "org.ow2.asm:asm-tree:${version}@jar")
task "asm${version}"(type: Copy) {
from configurations."asm${version}".collect { zipTree(it) }
into "${buildDir}/asm${version}"
}
classes.dependsOn "asm${version}"
}
jmh {
jmhVersion = '1.19'
profilers = ['org.objectweb.asm.benchmarks.MemoryProfiler']
}
}
project(':tools') {
description = "Tools used to build ${parent.description}"
}
project(':tools:bnd-module-plugin') {
description = "bnd plugin to build moduleinfo with ${rootProject.description}"
// TODO: this compiles asm twice (here and in :asm), find a way to avoid this.
sourceSets.main.java.srcDirs += project(':asm').sourceSets.main.java.srcDirs
depends = ['biz.aQute.bnd:biz.aQute.bnd:3.4.0']
}
project(':tools:retrofitter') {
description = "JDK 1.5 class retrofitter based on ${rootProject.description}"
// TODO: this compiles asm thrice (here, above and in :asm).
sourceSets.main.java.srcDirs += project(':asm').sourceSets.main.java.srcDirs
}
// -----------------------------------------------------------------------------
// Project tasks creation and configuration
// -----------------------------------------------------------------------------
// All projects use Java 1.6 and are tested with :asm-test and JUnit.
subprojects {
apply plugin: 'com.github.sherter.google-java-format'
googleJavaFormat.toolVersion = '1.4'
compileTestJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
dependencies {
requires.each { projectName -> compile project(projectName) }
depends.each { artifactName -> compile artifactName }
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.0',
'org.junit.jupiter:junit-jupiter-params:5.1.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.0'
testCompile project(':asm-test')
}
}
// Exclude anything deprecated or outside asm packages from code coverage.
def jacocoClasses(project) {
return files(project.sourceSets.main.output.collect { fileTree(
dir: it, include: 'org/objectweb/asm/**', exclude: '**/Remapping*'
)})
}
// Configures the projects with a non-empty 'provides' property. These are the
// ones which are published in Maven. They must be checked for code coverage and
// backward compatibility, retrofited to Java 1.5, packaged with biz.aQute.bnd
// and uploaded to Maven with a POM, sources and Javadoc.
configure(subprojects.findAll { it.provides }) {
// Code coverage configuration.
apply plugin: 'jacoco'
jacocoTestReport {
afterEvaluate { classDirectories = jacocoClasses(project) }
}
jacocoTestCoverageVerification {
violationRules.rule {
limit { counter = 'INSTRUCTION'; minimum = minCodeCoverage }
}
afterEvaluate { classDirectories = jacocoClasses(project) }
}
check.dependsOn jacocoTestCoverageVerification
// Retrofit the code to Java 1.5, in-place, in compileJava.doLast.
if (name != 'asm-test') {
task retrofit(type: JavaExec) {
classpath project(':tools:retrofitter').sourceSets.main.runtimeClasspath
main 'org.objectweb.asm.tools.Retrofitter'
args sourceSets.main.output.classesDirs
}
compileJava.dependsOn ':tools:retrofitter:classes'
compileJava.doLast { tasks.retrofit.execute() }
}
// Create one backward compatibility checking task for each 'sigtest-*' file
// in test/resources, and make the 'check' task depend on all these tasks.
if (file('src/test/resources/').exists()) {
configurations { sigtest }
dependencies { sigtest 'org.netbeans.tools:sigtest-maven-plugin:1.0' }
file('src/test/resources/').eachFileMatch(~/sigtest-.*/) { f ->
task "${f.name}" (type: JavaExec, dependsOn: 'classes') {
inputs.files(f, sourceSets.main.java)
outputs.file("${buildDir}/${f.name}")
classpath configurations.sigtest
main 'com.sun.tdk.signaturetest.Main'
args 'Test', '-ApiVersion', version, '-Backward', '-Static', '-Mode',
'bin', '-Classpath', "${System.env.JAVA_HOME}/jre/lib/rt.jar:" +
sourceSets.main.output.classesDirs.asPath, '-FileName', f,
'-Out', outputs.getFiles()[0], '-Package'
args provides
// The exit value is not 0 in case of success, but 95...
ignoreExitValue true
doLast {
if (!outputs.getFiles()[0].readLines().find {it =~ /STATUS:Passed/}) {
throw new GradleException('Sigtest FAILED')
}
}
}
check.dependsOn f.name
}
}
// Apply the biz.aQute.bnd plugin to package the project as an OSGi bundle,
// with a custom plugin to generate and include a module-info class. Exclude
// the asm-test project (the DefaultPackage class prevents it from being a
// proper bundle).
if (name != 'asm-test') {
apply plugin: 'biz.aQute.bnd.builder'
jar.dependsOn ':tools:bnd-module-plugin:jar'
jar.manifest.attributes(
'-classpath': sourceSets.main.output.classesDirs.asPath,
'-plugin': 'org.objectweb.asm.tools.ModuleInfoBndPlugin;',
'-pluginpath':
project(':tools:bnd-module-plugin').jar.outputs.files.singleFile,
'-removeheaders': 'Bnd-LastModified,Build-By,Created-By,Include-Resource,\
Require-Capability,Tool',
'Bundle-DocURL': 'http://asm.ow2.org',
'Bundle-RequiredExecutionEnvironment': 'J2SE-1.5',
'Bundle-SymbolicName': provides[0],
'Export-Package': provides.collect{"${it};version=${version}"}.join(','),
'Implementation-Title': project.description,
'Module-Requires':
requires
.collect{"${project(it).provides[0]};transitive=true"}
.join(',')
)
}
// Apply the SonarQube plugin to monitor the code quality of the project.
// Use with 'gradlew sonarqube -Dsonar.host.url=https://sonarqube.ow2.org'.
apply plugin: 'org.sonarqube'
// Add a task to generate a private javadoc and add it as a dependency of the
// 'check' task.
task privateJavadoc(type: Javadoc) {
source = sourceSets.main.allJava
classpath = configurations.compile
destinationDir = file("${javadoc.destinationDir}-private")
options.memberLevel = JavadocMemberLevel.PRIVATE
}
check.dependsOn privateJavadoc
// Add tasks to generate the Javadoc and a source jar, to be uploaded to Maven
// together with the main jar (containing the compiled code).
task javadocJar(type: Jar, dependsOn: 'javadoc') {
from javadoc.destinationDir
classifier 'javadoc'
}
task sourcesJar(type: Jar, dependsOn: 'classes') {
from sourceSets.main.allSource
classifier 'sources'
}
artifacts {
archives javadocJar
archives sourcesJar
}
// Add an uploadArchives task, provided by the maven plugin, to generate the
// project POM and to upload it, with the classes, sources and Javadoc jars.
apply plugin: 'maven'
uploadArchives.repositories.mavenDeployer {
def nexusUserName = System.env.NEXUS_USER_NAME
def nexusPassword = System.env.NEXUS_PASSWORD
if (nexusUserName != null) {
def baseUrl = 'http://repository.ow2.org/nexus/'
repository(url: baseUrl + 'service/local/staging/deploy/maven2') {
authentication(userName: nexusUserName, password: nexusPassword)
}
snapshotRepository(url: baseUrl + 'content/repositories/snapshots') {
authentication(userName: nexusUserName, password: nexusPassword)
}
} else {
repository url: 'file://localhost/tmp/myRepo/'
}
pom.project {
parent {
artifactId 'ow2'
groupId 'org.ow2'
version '1.5'
}
name jar.baseName
description project.description
packaging 'jar'
inceptionYear '2000'
licenses {
license {
name 'BSD'
url 'http://asm.ow2.org/license.html'
}
}
url 'http://asm.ow2.org/'
mailingLists {
mailingList {
name 'ASM Users List'
subscribe 'https://mail.ow2.org/wws/subscribe/asm'
post 'asm@objectweb.org'
archive 'https://mail.ow2.org/wws/arc/asm/'
}
mailingList {
name 'ASM Team List'
subscribe 'https://mail.ow2.org/wws/subscribe/asm-team'
post 'asm-team@objectweb.org'
archive 'https://mail.ow2.org/wws/arc/asm-team/'
}
}
issueManagement {
url 'https://gitlab.ow2.org/asm/asm/issues'
}
scm {
connection 'scm:git:https://gitlab.ow2.org/asm/asm/'
developerConnection 'scm:git:https://gitlab.ow2.org/asm/asm/'
url 'https://gitlab.ow2.org/asm/asm/'
}
developers {
developer {
name 'Eric Bruneton'
id 'ebruneton'
email 'ebruneton@free.fr'
roles {
role 'Creator'
role 'Java Developer'
}
}
developer {
name 'Eugene Kuleshov'
id 'eu'
email 'eu@javatx.org'
roles {
role 'Java Developer'
}
}
developer {
name 'Remi Forax'
id 'forax'
email 'forax@univ-mlv.fr'
roles {
role 'Java Developer'
}
}
}
organization {
name 'OW2'
url 'http://www.ow2.org/'
}
}
}
}