@@ -135,7 +135,14 @@ class J2objcPluginExtension {
135135 String translateFlags = " --no-package-directories"
136136 // -classpath library additions from ${projectDir}/lib/, e.g.: "json-20140107.jar", "somelib.jar"
137137 String [] translateClassPaths = []
138-
138+
139+ // WARNING: Do not use this unless you know what you are doing.
140+ // If true, incremental builds will be supported even if --build-closure is included in
141+ // translateFlags. This may break the build in unexpected ways if you change the dependencies
142+ // (e.g. adding new files or changing translateClassPaths). When you change the dependencies and
143+ // the build breaks, you need to do a clean build.
144+ boolean UNSAFE_incrementalBuildClosure = false
145+
139146 // Additional libraries that are part of the j2objc release
140147 // TODO: warn if different versions than testCompile from Java plugin
141148 // TODO: just import everything in the j2objc/lib/ directory?
@@ -196,7 +203,6 @@ class J2objcPluginExtension {
196203 // automatically. You will most likely want to use --build-closure in the translateFlags as well.
197204 boolean appendProjectDependenciesToSourcepath = false
198205
199-
200206 // COMPILE
201207 // Skip compile task if true
202208 boolean compileSkip = false
@@ -676,12 +682,14 @@ class J2objcTranslateTask extends DefaultTask {
676682 // we have to check if translation has been done before or not
677683 // if it is only an incremental build we must remove the --build-closure
678684 // argument to make fewer translations of dependent classes
679- // NOTE: TODO there is one case which fails, when you have translated the code
685+ // NOTE: There is one case which fails, when you have translated the code
680686 // make an incremental change which refers to a not yet translated class from a
681687 // source lib. In this case due to not using --build-closure the dependent source
682- // we not be translated, this can be fixed with a clean and fresh build
683- def translateFlags = " ${ project.j2objcConfig.translateFlags} "
684- if (translatedFiles > 0 ) {
688+ // we not be translated, this can be fixed with a clean and fresh build.
689+ // Due to this issue, incremental builds with --build-closure are enabled ONLY
690+ // if the user requests it with the UNSAFE_incrementalBuildClosure flag.
691+ def translateFlags = project. j2objcConfig. translateFlags
692+ if (translatedFiles > 0 && project.j2objcConfig.UNSAFE_incrementalBuildClosure ) {
685693 translateFlags = translateFlags. toString(). replaceFirst(" --build-closure" ," " ). trim()
686694 }
687695
0 commit comments