build.gradle 3.5 KB
Newer Older
1 2
import com.diffplug.spotless.LineEnding

S
Skylot 已提交
3
plugins {
S
Skylot 已提交
4
	id 'org.sonarqube' version '2.7.1'
S
Skylot 已提交
5 6
	id 'com.github.ben-manes.versions' version '0.22.0'
	id "com.diffplug.gradle.spotless" version "3.24.0"
S
Skylot 已提交
7 8
}

9
ext.jadxVersion = System.getenv('JADX_VERSION') ?: "dev"
S
Skylot 已提交
10
version = jadxVersion
11
println("jadx version: ${jadxVersion}")
S
Skylot 已提交
12

13
allprojects {
14 15
	apply plugin: 'java'
	apply plugin: 'jacoco'
16
	apply plugin: 'checkstyle'
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

	version = jadxVersion

	tasks.withType(JavaCompile) {
		if (!"$it".contains(':jadx-samples:')) {
			options.compilerArgs << '-Xlint' << '-Xlint:unchecked' << '-Xlint:deprecation'
		}
	}

	compileJava {
		options.encoding = "UTF-8"
	}

	jar {
		version = jadxVersion
		manifest {
			mainAttributes('jadx-version': jadxVersion)
		}
	}

	dependencies {
S
Skylot 已提交
38
		compile 'org.slf4j:slf4j-api:1.7.28'
39 40 41

		testCompile 'ch.qos.logback:logback-classic:1.2.3'
		testCompile 'org.hamcrest:hamcrest-library:2.1'
S
Skylot 已提交
42
		testCompile 'org.mockito:mockito-core:3.0.0'
43

S
Skylot 已提交
44 45
		testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.1'
		testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.1'
46 47

		testCompile 'org.eclipse.jdt.core.compiler:ecj:4.6.1'
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
	}

	test {
		useJUnitPlatform()
	}

	repositories {
		mavenLocal()
		mavenCentral()
		jcenter()
		google()
	}

	jacoco {
		toolVersion = "0.8.2"
	}
	jacocoTestReport {
		reports {
			xml.enabled = true
			html.enabled = true
		}
	}
70 71 72 73 74

	checkstyleMain {
		// exclude all sources in samples module
		exclude '**/samples/**'
	}
75 76
}

S
Skylot 已提交
77
sonarqube {
78 79 80 81 82 83
	properties {
		property 'sonar.exclusions', '**/jadx/samples/**/*,**/test-app/**/*'
		property 'sonar.coverage.exclusions', '**/jadx/gui/**/*'
	}
}

84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
spotless {
	java {
		target fileTree(rootDir).matching {
			include 'jadx-cli/src/**/java/**/*.java'
			include 'jadx-core/src/**/java/**/*.java'
			include 'jadx-gui/src/**/java/**/*.java'
		}

		importOrderFile 'config/code-formatter/eclipse.importorder'
		eclipse().configFile 'config/code-formatter/eclipse.xml'
		removeUnusedImports()

		lineEndings(LineEnding.UNIX)
		encoding("UTF-8")
		trimTrailingWhitespace()
		endWithNewline()
	}
	format 'misc', {
		target '**/*.gradle', '**/*.md', '**/*.xml', '**/.gitignore', '**/.properties'
S
Skylot 已提交
103
		targetExclude ".gradle/**", ".idea/**"
104 105 106 107 108 109

		lineEndings(LineEnding.UNIX)
		encoding("UTF-8")
		trimTrailingWhitespace()
		endWithNewline()
	}
S
Skylot 已提交
110 111
}

S
Skylot 已提交
112
dependencyUpdates.resolutionStrategy = {
113 114 115 116 117 118 119 120 121 122
	componentSelection { rules ->
		rules.all { ComponentSelection selection ->
			boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm', 'atlassian'].any { qualifier ->
				selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
			}
			if (rejected) {
				selection.reject('Release candidate')
			}
		}
	}
S
Skylot 已提交
123 124
}

S
Skylot 已提交
125
task copyArtifacts(type: Sync, dependsOn: ['jadx-cli:installDist', 'jadx-gui:installDist']) {
126 127 128 129
	destinationDir file("$buildDir/jadx")
	['jadx-cli', 'jadx-gui'].each {
		from tasks.getByPath(":${it}:installDist").destinationDir
	}
S
Skylot 已提交
130 131
}

S
Skylot 已提交
132
task pack(type: Zip, dependsOn: copyArtifacts) {
133 134 135
	destinationDir buildDir
	archiveName "jadx-${jadxVersion}.zip"
	from copyArtifacts.destinationDir
S
Skylot 已提交
136 137
}

S
Skylot 已提交
138
task copyExe(type: Copy, dependsOn: 'jadx-gui:createExe') {
139 140 141 142 143
	group 'jadx'
	description = 'Copy exe to build dir'
	destinationDir buildDir
	from tasks.getByPath('jadx-gui:createExe').outputs
	include '*.exe'
S
Skylot 已提交
144 145 146
}

task dist(dependsOn: [pack, copyExe]) {
147 148
	group 'jadx'
	description = 'Build jadx distribution zip'
S
Skylot 已提交
149 150
}

S
Skylot 已提交
151
task samples(dependsOn: 'jadx-samples:samples') {
152
	group 'jadx'
S
Skylot 已提交
153 154
}

S
Skylot 已提交
155
task cleanBuildDir(type: Delete) {
156 157
	group 'jadx'
	delete buildDir
S
Skylot 已提交
158 159
}

160
test.dependsOn(samples)
S
Skylot 已提交
161 162

clean.dependsOn(cleanBuildDir)