Skip to content

Commit

Permalink
1. move TinkerApplication get* method to ApplicationLIke
Browse files Browse the repository at this point in the history
2. add pmd and findbug check
3. wait  dexOpt file generate when patching
4. add TInkerLoadLibrary file to load patch library easier
5. reformat code
  • Loading branch information
shwenzhang committed Jan 5, 2017
1 parent c741ff5 commit 3fdaead
Show file tree
Hide file tree
Showing 28 changed files with 536 additions and 268 deletions.
15 changes: 0 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,6 @@ allprojects {
enabled = false
options.setEncoding('UTF-8')
}

apply plugin: 'checkstyle'

checkstyle {
configFile rootProject.file('checkstyle.xml')
toolVersion '6.19'
ignoreFailures false
showViolations true
}

task('checkstyle', type: Checkstyle) {
source 'src/main/java'
include '**/*.java'
classpath = files()
}
}

ext {
Expand Down
9 changes: 9 additions & 0 deletions findbugs-exclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<FindBugsFilter>

<Match>
<Class name="~.*R\$.*" />
</Match>
<Match>
<Class name="~.*Manifest\$.*" />
</Match>
</FindBugsFilter>
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
VERSION_NAME_PREFIX=1.7.6
VERSION_NAME_PREFIX=1.7.7
VERSION_NAME_SUFFIX=
4 changes: 2 additions & 2 deletions gradle/android-artifacts.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,5 @@ publishing {
task buildAndPublishTinkerToLocalMaven(dependsOn: ['build', 'publishTinkerPatchPublicationToMavenLocal']) {
group = 'tinker'
}
//depend checkstyle
project.tasks.getByName("check").dependsOn tasks.getByName("checkstyle")

apply from: rootProject.file('gradle/check.gradle')
72 changes: 72 additions & 0 deletions gradle/check.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
apply plugin: 'checkstyle'


checkstyle {
configFile rootProject.file('checkstyle.xml')
toolVersion '6.19'
ignoreFailures false
showViolations true
}

task('checkstyle', type: Checkstyle) {
source 'src/main/java'
include '**/*.java'
classpath = files()
}

check.dependsOn('checkstyle')


apply plugin: 'pmd'
apply plugin: 'findbugs'

pmd {
toolVersion '5.4.0'
}

task pmd(type: Pmd) {
targetJdk = TargetJdk.VERSION_1_7

description 'Run pmd'
group 'verification'

// If ruleSets is not empty, it seems to contain some
// defaults which override rules in the ruleset file...
ruleSets = []
ruleSetFiles = rootProject.files('pmd-ruleset.xml')
source = fileTree('src/main/java')
ignoreFailures = false

reports {
xml.enabled = false
html.enabled = true
}
}
def classTree = 'build/intermediates/classes/debug'

if (project.plugins.hasPlugin('java')) {
classTree = 'build/classes'
}
task findbugs(type: FindBugs) {

description 'Run findbugs'
group 'verification'

classes = fileTree(classTree)
source = fileTree('src/main/java/')
classpath = files()

effort = 'max'

excludeFilter = rootProject.file("findbugs-exclude.xml")

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

//depend check
check.dependsOn('pmd')
check.dependsOn('findbugs')
6 changes: 1 addition & 5 deletions gradle/gradle-mvn-push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,10 @@ task buildAndPublishRepo(dependsOn: ['build', 'uploadArchives']) {
}
}

//depend checkstyle
tasks.getByName("uploadArchives").dependsOn tasks.getByName("checkstyle")
tasks.getByName("bintrayUpload").dependsOn tasks.getByName("checkstyle")

tasks.getByName("bintrayUpload") {
it.doFirst {
if (!isReleaseBuild()) {
throw new GradleException("bintrayUpload only support release version")
}
}
}
}
3 changes: 1 addition & 2 deletions gradle/java-artifacts.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,4 @@ task buildAndPublishTinkerToLocalMaven(dependsOn: ['build', 'publishTinkerPatchP
group = 'tinker'
}

//depend checkstyle
project.tasks.getByName("check").dependsOn tasks.getByName("checkstyle")
apply from: rootProject.file('gradle/check.gradle')
44 changes: 44 additions & 0 deletions pmd-ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ruleset name="PMD.rul" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">

<description>This ruleset was created from PMD.rul</description>

<rule ref="rulesets/java/basic.xml">
<exclude name="AvoidBranchingStatementAsLastInLoop"/>
</rule>
<rule ref="rulesets/java/braces.xml"/>
<rule ref="rulesets/java/strings.xml">
<!-- TODO: This warns about annotations, apparently fixed in a later version. -->
<exclude name="AvoidDuplicateLiterals"/>
</rule>
<rule ref="rulesets/java/unusedcode.xml"/>

<rule ref="rulesets/java/design.xml">
<exclude name="ConfusingTernary"/>
<exclude name="EmptyMethodInAbstractClassShouldBeAbstract"/>
<exclude name="AvoidSynchronizedAtMethodLevel"/>

<!-- This check breaks on double checked locking which is safe in Java 6/7 -->
<exclude name="NonThreadSafeSingleton"/>
<!-- This check breaks the builder pattern, I didn't find the solution-->
<exclude name="AccessorClassGeneration"/>
<!-- TODO: Fix these -->
<exclude name="AvoidReassigningParameters"/>
<exclude name="GodClass"/>

</rule>

<rule ref="rulesets/java/design.xml/AvoidDeeplyNestedIfStmts">
<properties>
<property name="problemDepth" value="5"/>
</properties>
</rule>

<rule message="Commented blocks are ok" ref="rulesets/java/empty.xml/EmptyCatchBlock">
<properties>
<property name="allowCommentedBlocks" value="true"/>
</properties>
</rule>
</ruleset>
Loading

0 comments on commit 3fdaead

Please sign in to comment.