build.gradle 3.7 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 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

	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 {
36
		compile 'org.slf4j:slf4j-api:1.7.30'
37
		compileOnly 'org.jetbrains:annotations:19.0.0'
38 39

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

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

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

	test {
		useJUnitPlatform()
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

162
test.dependsOn(samples)
S
Skylot 已提交
163 164

clean.dependsOn(cleanBuildDir)