build.gradle 3.8 KB
Newer Older
S
Skylot 已提交
1
plugins {
S
Skylot 已提交
2
	id 'org.sonarqube' version '3.0'
S
Skylot 已提交
3
	id 'com.github.ben-manes.versions' version '0.28.0'
S
Skylot 已提交
4
	id "com.diffplug.gradle.spotless" version "4.5.0"
S
Skylot 已提交
5 6
}

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

11
allprojects {
12 13
	apply plugin: 'java'
	apply plugin: 'jacoco'
14
	apply plugin: 'checkstyle'
15 16 17

	version = jadxVersion

18 19 20
	sourceCompatibility = JavaVersion.VERSION_1_8
	targetCompatibility = JavaVersion.VERSION_1_8

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
	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 {
39
		compile 'org.slf4j:slf4j-api:1.7.30'
40
		compileOnly 'org.jetbrains:annotations:19.0.0'
41 42

		testCompile 'ch.qos.logback:logback-classic:1.2.3'
S
Skylot 已提交
43
		testCompile 'org.hamcrest:hamcrest-library:2.2'
S
Skylot 已提交
44
		testCompile 'org.mockito:mockito-core:3.3.3'
S
Skylot 已提交
45
		testCompile 'org.assertj:assertj-core:3.16.1'
46

S
Skylot 已提交
47 48
		testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.2'
		testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.2'
49 50

		testCompile 'org.eclipse.jdt.core.compiler:ecj:4.6.1'
51
		testCompileOnly 'org.jetbrains:annotations:19.0.0'
52 53 54 55 56 57 58 59 60 61 62 63 64 65
	}

	test {
		useJUnitPlatform()
	}

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

	jacoco {
66
		toolVersion = "0.8.5"
67 68 69 70 71 72 73
	}
	jacocoTestReport {
		reports {
			xml.enabled = true
			html.enabled = true
		}
	}
74 75 76 77 78

	checkstyleMain {
		// exclude all sources in samples module
		exclude '**/samples/**'
	}
79 80
}

S
Skylot 已提交
81
sonarqube {
82 83 84 85 86 87
	properties {
		property 'sonar.exclusions', '**/jadx/samples/**/*,**/test-app/**/*'
		property 'sonar.coverage.exclusions', '**/jadx/gui/**/*'
	}
}

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

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

101
		lineEndings(com.diffplug.spotless.LineEnding.UNIX)
102 103 104 105 106 107
		encoding("UTF-8")
		trimTrailingWhitespace()
		endWithNewline()
	}
	format 'misc', {
		target '**/*.gradle', '**/*.md', '**/*.xml', '**/.gitignore', '**/.properties'
108
		targetExclude ".gradle/**", ".idea/**", "*/build/**"
109

110
		lineEndings(com.diffplug.spotless.LineEnding.UNIX)
111 112 113 114
		encoding("UTF-8")
		trimTrailingWhitespace()
		endWithNewline()
	}
S
Skylot 已提交
115 116
}

S
Skylot 已提交
117
dependencyUpdates.resolutionStrategy = {
118 119 120 121 122 123 124 125 126 127
	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 已提交
128 129
}

S
Skylot 已提交
130
task copyArtifacts(type: Sync, dependsOn: ['jadx-cli:installDist', 'jadx-gui:installDist']) {
131 132 133 134
	destinationDir file("$buildDir/jadx")
	['jadx-cli', 'jadx-gui'].each {
		from tasks.getByPath(":${it}:installDist").destinationDir
	}
S
Skylot 已提交
135 136
}

S
Skylot 已提交
137
task pack(type: Zip, dependsOn: copyArtifacts) {
138 139 140
	destinationDir buildDir
	archiveName "jadx-${jadxVersion}.zip"
	from copyArtifacts.destinationDir
S
Skylot 已提交
141 142
}

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

task dist(dependsOn: [pack, copyExe]) {
152 153
	group 'jadx'
	description = 'Build jadx distribution zip'
S
Skylot 已提交
154 155
}

S
Skylot 已提交
156
task samples(dependsOn: 'jadx-samples:samples') {
157
	group 'jadx'
S
Skylot 已提交
158 159
}

S
Skylot 已提交
160
task cleanBuildDir(type: Delete) {
161 162
	group 'jadx'
	delete buildDir
S
Skylot 已提交
163 164
}

165
test.dependsOn(samples)
S
Skylot 已提交
166 167

clean.dependsOn(cleanBuildDir)