Created
September 4, 2014 04:17
-
-
Save qianjigui/0b10862d0fb8b30fe74f to your computer and use it in GitHub Desktop.
Java SDK Build gradle template: proguard, static-test
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
apply plugin: 'java' | |
//repositories { | |
// mavenCentral() | |
// maven { | |
// url 'https://repo.eclipse.org/content/groups/releases/' | |
// } | |
//} | |
dependencies { | |
compile fileTree(dir: 'libs', include: ['*.jar']) | |
testCompile fileTree(dir: 'libstest', include: ['*.jar']) | |
//compile group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '3.4.1.201406201815-r' | |
} | |
version = 'v1.0.0' | |
jar { | |
manifest { | |
attributes 'Application': 'Application Name', | |
'Version': version, | |
'Main-Class': 'xxx.Main' | |
} | |
from(configurations.compile.collect {it.directory ? it : zipTree(it)}){ | |
exclude 'META-INF/**' | |
exclude 'META-INF/maven/*' | |
exclude 'plugin.properties' | |
exclude 'about.html' | |
} | |
} | |
// Define a ProGuard task. | |
task proguard(type: proguard.gradle.ProGuardTask, dependsOn: jar) { | |
// You should probably import a more compact ProGuard-style configuration | |
// file for all static settings, but we're specifying them all here, for | |
// the sake of the example. | |
//configuration 'configuration.pro' | |
// Specify the input jars, output jars, and library jars. | |
// In this case, the input jar is the program library that we want to process. | |
//injars "build/libs/PMChecker-${version}.jar" | |
for(File jarFile:jar.getOutputs().getFiles()){ | |
ext.tmppath=jarFile.getCanonicalPath() | |
injars ext.tmppath | |
outjars "${ext.tmppath}.proguard.jar" | |
printmapping "${ext.tmppath}.proguard-out.map" | |
} | |
for(String jar:['rt','jsse','jce']){ | |
libraryjars "${System.getProperty('java.home')}/lib/${jar}.jar" | |
} | |
// Save the obfuscation mapping to a file, so we can de-obfuscate any stack | |
// traces later on. Keep a fixed source file attribute and all line number | |
// tables to get line numbers in the stack traces. | |
// You can comment this out if you're not interested in stack traces. | |
configuration file('proguard-rules.pro') | |
} | |
assemble { | |
it.dependsOn proguard | |
} | |
test { | |
include '**/*Suite.class' | |
} | |
apply plugin: 'findbugs' | |
findbugs{ | |
sourceSets = [sourceSets.main] | |
ignoreFailures = true | |
effort = "max" | |
reportLevel = "low" | |
} | |
tasks.withType(FindBugs) { | |
reports { | |
xml.enabled = false | |
html.enabled = true | |
} | |
exclude '**/org/json/**' | |
classes = classes.filter { | |
!it.path.contains(new File("org/json/").path) | |
} | |
} | |
apply plugin: 'checkstyle' | |
checkstyle{ | |
ignoreFailures = true | |
configFile = file('./config/checkstyle/style.xml') | |
} | |
checkstyleMain.exclude '**/org/json/**' | |
checkstyleMain << { | |
ant.xslt(in: reports.xml.destination, | |
style: new File('./config/checkstyle/checkstyle-noframes-sorted.xsl'), | |
out: new File(reports.xml.destination.parent, 'main.html')) | |
} | |
checkstyleTest << { | |
ant.xslt(in: reports.xml.destination, | |
style: new File('./config/checkstyle/checkstyle-noframes-sorted.xsl'), | |
out: new File(reports.xml.destination.parent, 'test.html')) | |
} | |
apply plugin: 'pmd' | |
pmd { | |
ignoreFailures = true | |
ruleSets = [ | |
"basic", | |
"braces", | |
"naming", | |
"android", | |
"clone", | |
"codesize", | |
"controversial", | |
"design", | |
"finalizers", | |
"imports", | |
"j2ee", | |
"javabeans", | |
"junit", | |
"logging-jakarta-commons", | |
"logging-java", | |
"migrating", | |
"optimizations", | |
"strictexception", | |
"strings", | |
"sunsecure", | |
"typeresolution", | |
"unusedcode" | |
] | |
} | |
tasks.withType(Pmd) { | |
reports { | |
xml.enabled = false | |
html.enabled = true | |
} | |
exclude '**/org/json/**' | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment