@@ -18,20 +18,18 @@ import '../logging/logging.dart';
1818import '../util/find_package.dart' ;
1919import 'gradle_tools.dart' ;
2020
21- final toolPath = join ('.' , '.dart_tool' , 'jnigen' );
22- final mvnTargetDir = join (toolPath, 'target' );
23- final gradleBuildDir = join ('.' , 'java' , 'build' );
24- final gradleTargetDir = join (gradleBuildDir, 'libs' );
25- final jarFile = join (gradleTargetDir, 'ApiSummarizer.jar' );
26- final targetJarFile = join (toolPath, 'ApiSummarizer.jar' );
21+ final _toolPath = join ('.' , '.dart_tool' , 'jnigen' );
22+ final _jarFile = join ('.' , 'java' , 'build' , 'libs' , 'ApiSummarizer.jar' );
23+ final _targetJarFile = join (_toolPath, 'ApiSummarizer.jar' );
2724
25+ /// Builds the ApiSummarizer JAR using Gradle.
2826Future <void > buildApiSummarizer () async {
2927 final pkg = await findPackageRoot ('jnigen' );
3028 if (pkg == null ) {
3129 log.fatal ('package jnigen not found!' );
3230 }
3331 final gradleWrapper = await GradleTools .getGradleWExecutable ();
34- await Directory (toolPath ).create (recursive: true );
32+ await Directory (_toolPath ).create (recursive: true );
3533 final gradleArgs = [
3634 '-p' ,
3735 pkg.resolve ('java/' ).toFilePath (),
@@ -43,7 +41,7 @@ Future<void> buildApiSummarizer() async {
4341 try {
4442 final gradleProc = await Process .run (
4543 gradleWrapper! .toFilePath (), gradleArgs,
46- workingDirectory: toolPath ,
44+ workingDirectory: _toolPath ,
4745 runInShell: true ,
4846 environment: jni_util.javaEnvironment);
4947 final exitCode = gradleProc.exitCode;
@@ -53,7 +51,7 @@ Future<void> buildApiSummarizer() async {
5351
5452 if (exitCode == 0 ) {
5553 sourceJar.copySync (
56- File (targetJarFile ).uri.toFilePath (windows: Platform .isWindows));
54+ File (_targetJarFile ).uri.toFilePath (windows: Platform .isWindows));
5755 } else {
5856 printError (gradleProc.stdout);
5957 printError (gradleProc.stderr);
@@ -62,16 +60,17 @@ Future<void> buildApiSummarizer() async {
6260 } finally {}
6361}
6462
63+ /// Builds the ApiSummarizer JAR if it has not been built or is stale.
6564Future <void > buildSummarizerIfNotExists ({bool force = false }) async {
6665 // TODO(#43): This function cannot be invoked concurrently because 2 processes
6766 // will start building summarizer at once. Introduce a locking mechnanism so
6867 // that when one process is building summarizer JAR, other process waits using
6968 // exponential backoff.
70- final jarExists = await File (jarFile ).exists ();
71- final targetJarExists = await File (targetJarFile ).exists ();
69+ final jarExists = await File (_jarFile ).exists ();
70+ final targetJarExists = await File (_targetJarFile ).exists ();
7271 final isJarStale = jarExists &&
7372 await isPackageModifiedAfter (
74- 'jnigen' , await File (jarFile ).lastModified (), 'java/' );
73+ 'jnigen' , await File (_jarFile ).lastModified (), 'java/' );
7574 if (isJarStale) {
7675 log.info ('Rebuilding ApiSummarizer component since sources '
7776 'have changed. This might take some time.' );
0 commit comments