build.gradle 3.6 KB
Newer Older
S
Skylot 已提交
1
plugins {
S
Skylot 已提交
2 3
	id 'com.github.ben-manes.versions' version '0.38.0'
	id "com.diffplug.spotless" version "5.11.0"
S
Skylot 已提交
4 5
}

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

10
allprojects {
11
	apply plugin: 'java'
12
	apply plugin: 'checkstyle'
13 14 15

	version = jadxVersion

16 17 18
	sourceCompatibility = JavaVersion.VERSION_1_8
	targetCompatibility = JavaVersion.VERSION_1_8

19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
	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 {
36
		implementation 'org.slf4j:slf4j-api:1.7.30'
S
Skylot 已提交
37
		compileOnly 'org.jetbrains:annotations:20.1.0'
38

39 40
		testImplementation 'ch.qos.logback:logback-classic:1.2.3'
		testImplementation 'org.hamcrest:hamcrest-library:2.2'
S
Skylot 已提交
41 42
		testImplementation 'org.mockito:mockito-core:3.8.0'
		testImplementation 'org.assertj:assertj-core:3.19.0'
43

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

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

	test {
		useJUnitPlatform()
	}

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

61 62 63 64
	checkstyleMain {
		// exclude all sources in samples module
		exclude '**/samples/**'
	}
65 66
}

67 68 69 70 71 72
spotless {
	java {
		target fileTree(rootDir).matching {
			include 'jadx-cli/src/**/java/**/*.java'
			include 'jadx-core/src/**/java/**/*.java'
			include 'jadx-gui/src/**/java/**/*.java'
73
			include 'jadx-plugins/**/java/**/*.java'
74 75 76 77 78 79
		}

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

80
		lineEndings(com.diffplug.spotless.LineEnding.UNIX)
81 82 83 84 85 86
		encoding("UTF-8")
		trimTrailingWhitespace()
		endWithNewline()
	}
	format 'misc', {
		target '**/*.gradle', '**/*.md', '**/*.xml', '**/.gitignore', '**/.properties'
87
		targetExclude ".gradle/**", ".idea/**", "*/build/**"
88

89
		lineEndings(com.diffplug.spotless.LineEnding.UNIX)
90 91 92 93
		encoding("UTF-8")
		trimTrailingWhitespace()
		endWithNewline()
	}
S
Skylot 已提交
94 95
}

96 97 98 99 100 101 102 103 104 105
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')
				}
106 107 108
			}
		}
	}
S
Skylot 已提交
109 110
}

S
Skylot 已提交
111
task copyArtifacts(type: Sync, dependsOn: ['jadx-cli:installDist', 'jadx-gui:installDist']) {
112 113 114 115
	destinationDir file("$buildDir/jadx")
	['jadx-cli', 'jadx-gui'].each {
		from tasks.getByPath(":${it}:installDist").destinationDir
	}
116
	duplicatesStrategy = DuplicatesStrategy.EXCLUDE
S
Skylot 已提交
117 118
}

S
Skylot 已提交
119
task pack(type: Zip, dependsOn: copyArtifacts) {
120 121
	destinationDirectory = buildDir
	archiveFileName = "jadx-${jadxVersion}.zip"
122
	from copyArtifacts.destinationDir
S
Skylot 已提交
123 124
}

S
Skylot 已提交
125
task copyExe(type: Copy, dependsOn: 'jadx-gui:createExe') {
126 127 128 129 130
	group 'jadx'
	description = 'Copy exe to build dir'
	destinationDir buildDir
	from tasks.getByPath('jadx-gui:createExe').outputs
	include '*.exe'
131
	duplicatesStrategy = DuplicatesStrategy.EXCLUDE
S
Skylot 已提交
132 133 134
}

task dist(dependsOn: [pack, copyExe]) {
135 136
	group 'jadx'
	description = 'Build jadx distribution zip'
S
Skylot 已提交
137 138
}

S
Skylot 已提交
139
task samples(dependsOn: 'jadx-samples:samples') {
140
	group 'jadx'
S
Skylot 已提交
141 142
}

S
Skylot 已提交
143
task cleanBuildDir(type: Delete) {
144 145
	group 'jadx'
	delete buildDir
S
Skylot 已提交
146 147
}

148
test.dependsOn(samples)
S
Skylot 已提交
149 150

clean.dependsOn(cleanBuildDir)