Skip to content

Commit

Permalink
Add a translateOnly mode that skips compilation-dependent tasks.
Browse files Browse the repository at this point in the history
Related to #345; Fixes #347
  • Loading branch information
advayDev1 committed Aug 14, 2015
1 parent 4fecf27 commit 9ad56b2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
15 changes: 13 additions & 2 deletions FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ and building the J2ObjC source:
3. Configure j2objcConfig in `shared/build.gradle` so CycleFinder uses the annotated J2ObjC
source and whitelist. Note how this gives and expected cycles of zero.

```
```gradle
// File: shared/build.gradle
j2objcConfig {
cycleFinderArgs '--whitelist', 'J2OBJC_REPO/jre_emul/cycle_whitelist.txt'
Expand All @@ -244,7 +244,18 @@ Development is officially supported only on Mac OS X. This matches the
In practice, the j2objcCycleFinder and j2objcTranslate tasks may work, though it is
strongly suggested to use this for experimentation only and do all proper development
on OS X. The team will reject any bugs related to systems that don't meet the
[minimum requirements](README.md#minimum-requirements).
[minimum requirements](README.md#minimum-requirements). You can attempt just
j2objcCycleFinder and j2objcTranslate with:

```gradle
// File: shared/build.gradle
j2objcConfig {
...
translateOnlyMode = true
...
finalConfigure()
}
```

To experiment on Windows (skipping the unsupported tasks), the following may work:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ class J2objcConfig {
appendArgs(this.translateSourcepaths, 'translateSourcepaths', translateSourcepaths)
}

/**
* True iff only translation (and cycle finding, if applicable) should be attempted,
* skipping all compilation, linking, and testing tasks.
*/
boolean translateOnlyMode = false


// Do not use groovydoc, this option should remain undocumented.
// WARNING: Do not use this unless you know what you are doing.
Expand Down Expand Up @@ -530,6 +536,18 @@ class J2objcConfig {
}
}
}

// Support translation-only mode.
if (translateOnlyMode) {
project.tasks.all { Task task ->
// First pattern matches all native-compilation tasks.
// Second pattern matches plugin-specific tasks beyond translation.
if ((task.name =~ /^.*((J|j)2objc(Executable|StaticLibrary|SharedLibrary|Objc))$/).matches() ||
(task.name =~ /^j2objc(Assemble|PackLibraries|Test)(Debug|Release)$/).matches()) {
task.enabled = false
}
}
}
}
boolean isFinalConfigured() {
return finalConfigured
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import com.github.j2objccontrib.j2objcgradle.tasks.TranslateTask
import com.github.j2objccontrib.j2objcgradle.tasks.Utils
import com.github.j2objccontrib.j2objcgradle.tasks.XcodeTask
import org.gradle.api.DefaultTask
import org.gradle.api.InvalidUserDataException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
Expand Down Expand Up @@ -112,6 +111,10 @@ class J2objcPlugin implements Plugin<Project> {
description "Run the cycle_finder tool on all Java source files"
enabled false
}

// NOTE: When adding new tasks, consider whether they fall under 'translate-only' mode, and
// filter them in J2objcConfig.finalConfigure otherwise.

// Note the '(debug|release)TestJ2objcExecutable' tasks are dynamically created by the Objective-C plugin.
// It is specified by the testJ2objc native component in NativeCompilation.groovy.
// TODO: copy and run debug and release tests within j2objcTestContent at the
Expand Down

0 comments on commit 9ad56b2

Please sign in to comment.