build.gradle 3.9 KB
Newer Older
S
Skylot 已提交
1
plugins {
2 3 4
	id 'org.sonarqube' version '3.1'
	id 'com.github.ben-manes.versions' version '0.36.0'
	id "com.diffplug.spotless" version "5.9.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
	tasks.withType(JavaCompile) {
		if (!"$it".contains(':jadx-samples:')) {
			options.compilerArgs << '-Xlint' << '-Xlint:unchecked' << '-Xlint:deprecation'
		}
	}

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

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

	dependencies {
38
		implementation 'org.slf4j:slf4j-api:1.7.30'
S
Skylot 已提交
39
		compileOnly 'org.jetbrains:annotations:20.1.0'
40

41 42
		testImplementation 'ch.qos.logback:logback-classic:1.2.3'
		testImplementation 'org.hamcrest:hamcrest-library:2.2'
43 44
		testImplementation 'org.mockito:mockito-core:3.7.0'
		testImplementation 'org.assertj:assertj-core:3.18.1'
45

S
Skylot 已提交
46 47
		testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
		testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
48

49
		testImplementation 'org.eclipse.jdt.core.compiler:ecj:4.6.1'
S
Skylot 已提交
50
		testCompileOnly 'org.jetbrains:annotations:20.1.0'
51 52 53 54 55 56 57 58 59 60 61 62 63 64
	}

	test {
		useJUnitPlatform()
	}

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

	jacoco {
S
Skylot 已提交
65
		toolVersion = "0.8.6"
66 67 68 69 70 71 72
	}
	jacocoTestReport {
		reports {
			xml.enabled = true
			html.enabled = true
		}
	}
73 74 75 76 77

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

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

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

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

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

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

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

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

S
Skylot 已提交
139
task pack(type: Zip, dependsOn: copyArtifacts) {
140 141
	destinationDirectory = buildDir
	archiveFileName = "jadx-${jadxVersion}.zip"
142
	from copyArtifacts.destinationDir
S
Skylot 已提交
143 144
}

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

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

S
Skylot 已提交
159
task samples(dependsOn: 'jadx-samples:samples') {
160
	group 'jadx'
S
Skylot 已提交
161 162
}

S
Skylot 已提交
163
task cleanBuildDir(type: Delete) {
164 165
	group 'jadx'
	delete buildDir
S
Skylot 已提交
166 167
}

168
test.dependsOn(samples)
S
Skylot 已提交
169 170

clean.dependsOn(cleanBuildDir)