Skip to content

Commit

Permalink
Merge pull request #183 from aalmiray/master
Browse files Browse the repository at this point in the history
Initial gradle build setup
  • Loading branch information
chriswhocodes committed Aug 10, 2015
2 parents a1c9c00 + c2ec783 commit 93acbe0
Show file tree
Hide file tree
Showing 9 changed files with 529 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -14,4 +14,5 @@ JVMS.html
jitwatch.out
jitwatch.properties
.idea
jitwatch.iml
jitwatch.i*
build/
161 changes: 161 additions & 0 deletions build.gradle
@@ -0,0 +1,161 @@
buildscript {
repositories {
jcenter()
}

dependencies {
classpath 'commons-io:commons-io:2.4'
}
}
import static org.apache.commons.io.output.NullOutputStream.NULL_OUTPUT_STREAM

plugins {
id 'java' // self explanatory
id 'idea' // idem
id 'application' // similar to mvn exec:java
id 'com.github.johnrengelman.shadow' version '1.2.2' // fat jar
id 'com.github.hierynomus.license' version '0.11.0' // license checks
id 'com.github.ben-manes.versions' version '0.11.3' // version checks
}


// maven coordinates
group = 'org.adoptopenjdk.jitwatch'
version = '1.0.0-SNAPSHOT'

repositories {
jcenter() // faster than mavenCentral()
}

// we expect jdk to be any of ['jdk7', 'jdk8', 'jdk9']
// this property can specified at the command line as follows
//
// gradle -Pjdk=jdk8 <command>
//
if (!hasProperty('jdk')) {
ext.jdk = 'jdk7' // lowest
}

// detect jfxrt.jar & tools.jar
ext {
jfxrtLocation = new File("${System.properties['java.home']}/jre/lib/jfxrt.jar").absolutePath
toolsLocation = new File("${System.properties['java.home']}/lib/tools.jar").absolutePath
}

for (location in ['lib/jfxrt.jar', 'jre/lib/jfxrt.jar', 'jre/lib/ext/jfxrt.jar']) {
File javaHome = new File(System.properties['java.home'])
javaHome = javaHome.name == 'jre' ? javaHome.parentFile : javaHome
File file = new File(javaHome, location)
if (file.exists()) {
jfxrtLocation = file.absolutePath
break
}
}

File javaHome = new File(System.properties['java.home'])
javaHome = javaHome.name == 'jre' ? javaHome.parentFile : javaHome
File file = new File(javaHome, 'lib/tools.jar')
if (file.exists()) {
toolsLocation = file.absolutePath
}

configurations {
// gradle does not have a 'system' nor 'provided' scope
system
}

dependencies {
compile 'org.slf4j:slf4j-api:1.7.12'
compile 'ch.qos.logback:logback-classic:1.1.3'
compile 'ch.qos.logback:logback-core:1.1.3'
testCompile 'junit:junit:4.12'
system project.files(jfxrtLocation)
if (jdk != 'jdk9') system project.files(toolsLocation)
}

mainClassName = 'org.adoptopenjdk.jitwatch.launch.LaunchUI'

license {
header = rootProject.file('config/HEADER')
strictCheck = true
ignoreFailures = true
mapping {
java = 'SLASHSTAR_STYLE'
groovy = 'SLASHSTAR_STYLE'
scala = 'SLASHSTAR_STYLE'
}
ext.year = '2013, 2014'
exclude '**/*.png'
exclude '**/*.kt'
}

// do not format test resources
licenseTest {
source -= sourceSets.test.resources
}

// fix classpaths due to missing 'system' scope
sourceSets {
main {
compileClasspath += [configurations.system]
}
}

javadoc {
classpath += [configurations.system]
}

idea {
module {
scopes.PROVIDED.plus += [configurations.system]
}
}

run {
// include tools.jar in the runtime classpath
classpath += [configurations.system]
}

shadowJar {
if (jdk != 'jdk9') {
from project.files(toolsLocation)
}
}

task makeDemoLogFile(type: JavaExec) {
dependsOn classes
main = 'org.adoptopenjdk.jitwatch.demo.MakeHotSpotLog'
jvmArgs = [
// --== required switches ==--
// Unlock the HotSpot logging options
"-XX:+UnlockDiagnosticVMOptions",

// Log each time a class is loaded (how JITWatch builds the class model)
"-XX:+TraceClassLoading",

// Enable XML format HotSpot log output
"-XX:+LogCompilation",

// --== optional switches ==--
// Enable disassembly of native code into assembly language (AT&T / GNU format)
// Requires the hsdis (HotSpot disassembler) binary to be added to your JRE
// For hsdis build instructions see http://www.chrisnewland.com/building-hsdis-on-linux-amd64-on-debian-369
"-XX:+PrintAssembly",

// Change disassembly format from AT&T to Intel assembly
"-XX:PrintAssemblyOptions=intel",

// Disable tiered compilation (enabled by default on Java 8, optional on Java 7)
"-XX:-TieredCompilation",

// Enable tiered compilation
"-XX:+TieredCompilation",

// Disable compressed oops (makes assembly easier to read)
"-XX:-UseCompressedOops"
]
classpath = project.configurations.runtime
ignoreExitValue = true
standardOutput = NULL_OUTPUT_STREAM
errorOutput = NULL_OUTPUT_STREAM
}
35 changes: 35 additions & 0 deletions config/HEADER
@@ -0,0 +1,35 @@
Copyright (c) ${year} Chris Newland.
Website: www.chrisnewland.com
Twitter: @chriswhocodes
Email : chris@chrisnewland.com

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.

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.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.

This software contains an assembly language reference from ref.x86asm.net used with kind permission of Karel Lejska
and in compliance with the licence at http://ref.x86asm.net/#License

Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki
70 changes: 70 additions & 0 deletions gradle/code-quality.gradle
@@ -0,0 +1,70 @@
apply plugin: 'jdepend'
apply plugin: 'checkstyle'
apply plugin: 'com.github.hierynomus.license'

def configDir = new File(buildscript.sourceFile.parentFile.parentFile, 'config')
ext.checkstyleConfigDir = "$configDir/checkstyle"

checkstyle {
toolVersion = '6.0'
configFile = new File(checkstyleConfigDir, 'checkstyle.xml')
configProperties.checkstyleConfigDir = checkstyleConfigDir
}

if (project.hasProperty('findBugsEnabled') && project.findBugsEnabled.toBoolean()) {
apply plugin: 'findbugs'
findbugs {
toolVersion = '3.0.0'
sourceSets = [sourceSets.main]
ignoreFailures = true
reportsDir = file("$project.buildDir/reports/findbugs")
effort = 'max'
reportLevel = 'high'
}

findbugsMain {
reports {
xml.enabled = false
html.enabled = true
}
}

findbugsTest {
reports {
xml.enabled = false
html.enabled = true
}
}
}

jdepend {
toolVersion = '2.9.1'
sourceSets = [sourceSets.main]
ignoreFailures = true
reportsDir = file("$project.buildDir/reports/jdepend")
}

license {
header = rootProject.file('config/HEADER')
strictCheck = true
ignoreFailures = true
mapping {
java = 'SLASHSTAR_STYLE'
groovy = 'SLASHSTAR_STYLE'
}
ext.year = '2014'
exclude '**/*.png'
}

licenseTest {
source -= sourceSets.test.resources
}

if (project.plugins.hasPlugin('groovy')) {
apply plugin: 'codenarc'

codenarc {
ignoreFailures = true
configFile = file("$configDir/codenarc/codenarc.groovy")
}
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
#Fri Aug 07 10:48:38 CEST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-bin.zip

0 comments on commit 93acbe0

Please sign in to comment.