j2objcConfig is used to configure the plugin with the project's build.gradle. All paths are resolved using Gradle's project.file(...) Basic Example: j2objcConfig { xcodeProjectDir '../ios' xcodeTarget 'IOS-APP' finalConfigure() } Complex Example: TODO...
| Modifiers | Name | Description |
|---|---|---|
static java.lang.String |
MIN_SUPPORTED_J2OBJC_VERSION |
|
protected boolean |
finalConfigured |
|
protected NativeCompilation |
nativeCompilation |
|
protected org.gradle.api.Project |
project |
| Constructor and description |
|---|
J2objcConfig
(org.gradle.api.Project project) |
| Type | Name and description |
|---|---|
static void |
appendArgs(java.util.List<java.lang.String> listArgs, java.lang.String nameArgs, boolean rejectSpaces, java.lang.String... args) |
protected void |
configureNativeCompilation() |
protected void |
configureNativeCompilationForUnsupported() |
protected void |
configureTaskState() |
protected void |
convertDeps() |
void |
cycleFinderArgs(java.lang.String... cycleFinderArgs)Add command line arguments for j2objc cycle_finder. |
void |
dependsOnJ2objcLib(java.lang.String beforeProjectName)@see #dependsOnJ2objcLib(org.gradle.api.Project) |
void |
dependsOnJ2objcLib(org.gradle.api.Project beforeProject)Uses the generated headers and compiled j2objc libraries of the given project when compiling this project. |
void |
enableBuildClosure()Enables --build-closure, which translates classes referenced from the list of files passed for translation, using the translateSourcepaths. |
void |
extraLinkerArgs(java.lang.String... extraLinkerArgs)Add arguments to pass to the native linker. |
void |
extraNativeLib(java.util.Map spec)Add additional native library to link to. |
void |
extraObjcCompilerArgs(java.lang.String... extraObjcCompilerArgs)Add arguments to pass to the native compiler. |
void |
extraObjcHeadersDirs(java.lang.String... extraObjcHeaderDirs)Add directories of Objective-C headers to export in addition to the translated ones. |
void |
extraObjcSrcDirs(java.lang.String... extraObjcSrcDirs)Add directories of Objective-C source to compile in addition to the translated source. |
void |
finalConfigure()Configures the j2objc build. |
static J2objcConfig |
from(org.gradle.api.Project project) |
void |
generatedSourceDirs(java.lang.String... generatedSourceDirs)Add generated source files directories, e.g. from dagger annotations. |
java.util.List<java.lang.String> |
getActiveArchs()An architecture is active if it is both supported (supportedArchs) and enabled in the current environment via the comma-separated j2objc.enabledArchs value in local.properties. |
java.util.List<org.gradle.api.Project> |
getBeforeProjects()Get J2ObjC project dependencies. |
java.io.File |
getDestLibDirFile() |
java.io.File |
getDestPodspecDirFile() |
java.io.File |
getDestSrcDirFile(java.lang.String sourceSetName, java.lang.String fileType) |
boolean |
getFilenameCollisionCheck() |
boolean |
isFinalConfigured() |
void |
mainSourceDirs(java.lang.String... dirs) |
protected void |
resolveDeps() |
void |
testArgs(java.lang.String... testArgs)Add command line arguments for j2objcTest task. |
org.gradle.api.tasks.util.PatternSet |
testPattern(groovy.lang.Closure cl)Configures the testPattern Calling this method repeatedly further modifies the existing testPattern, and will create an empty testPattern if none exists. |
void |
testSourceDirs(java.lang.String... dirs) |
void |
testingOnlyPrepConfigurations() |
void |
translateArgs(java.lang.String... translateArgs)Add command line arguments for j2objc translate. |
void |
translateClasspaths(java.lang.String... translateClasspaths)Local jars for translation e.g.: "lib/json-20140107.jar", "lib/somelib.jar". |
org.gradle.api.tasks.util.PatternSet |
translatePattern(groovy.lang.Closure cl)Configures the translatePattern. |
void |
translateSourceMapping(java.lang.String before, java.lang.String after)Adds a new source mapping. |
void |
translateSourcepaths(java.lang.String... translateSourcepaths)Source jars for translation e.g.: "lib/json-20140107-sources.jar" |
protected void |
validateConfiguration() |
static void |
verifyArgs(java.lang.String nameArgs, boolean rejectSpaces, java.lang.String... args) |
protected void |
verifyJ2objcRequirements() |
void |
xcodeTargetsIos(java.lang.String... xcodeTargetsIos)iOS app and test Xcode targets to link to the generated libraries. |
void |
xcodeTargetsOsx(java.lang.String... xcodeTargetsOsx)OS X app and test Xcode targets to link to the generated libraries. |
void |
xcodeTargetsWatchos(java.lang.String... xcodeTargetsWatchos)watchOS app and test Xcode targets to link to the generated libraries. |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Experimental functionality to automatically configure dependencies. Consider you have dependencies like:
dependencies {
compile project(':peer1') // type (1)
compile 'com.google.code.gson:gson:2.3.1' // type (3)
compile 'com.google.guava:guava:18.0' // type (2)
testCompile 'junit:junit:4.11' // type (2)
}
Project dependencies (1) will be added as a `j2objcLink` dependency.
Libraries already included in j2objc (2) will be ignored.
External libraries in Maven (3) will be added in source JAR form to
`j2objcTranslate`, and translated using `--build-closure`.
Dependencies must be fully specified before you call finalConfigure().
This will become the default when stable in future releases.
Command line arguments for j2objc cycle_finder.
A list of all possible arguments can be found here: http://j2objc.org/docs/cycle_finder.htmlExpected number of cycles, defaults to all those found in JRE.
This is an exact number rather than minimum as any change is significant.Where to assemble generated main libraries.
Defaults to $buildDir/j2objcOutputs/libWhere to assemble generated main libraries.
Defaults to $buildDir/j2objcOutputsWhere to assemble generated main source and resources files.
Defaults to $buildDir/j2objcOutputs/src/main/objcWhere to assemble generated test source and resources files.
Can be the same directory as destDir Defaults to $buildDir/j2objcOutputs/src/test/objcAdditional arguments to pass to the native linker.
Additional native libraries to link to.
Additional arguments to pass to the native compiler.
Directories of Objective-C headers to compile in addition to the translated source.
Directories of Objective-C source to compile in addition to the translated source.
Force filename collision check so prohibit two files with same name.
This will automatically be set to true when translateArgs contains '--no-package-directories'. That flag flattens the directory structure and will overwrite files with the same name.Generated source files directories, e.g. from dagger annotations.
Exact required version of j2objc.
Additional native libraries that are part of the j2objc distribution to link with the production code (and also the test code).
For example:linkJ2objcLibs = ["guava", "jsr305"]
Additional native libraries that are part of the j2objc distribution to link with the test code.
sources to translate
The minimum iOS version to build against. You cannot use APIs that are not supported in this version.
See https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/cross_development/Configuring/configuring.html#//apple_ref/doc/uid/10000163i-CH1-SW2The minimum OS X version to build against. You cannot use APIs that are not supported in this version.
See https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/cross_development/Configuring/configuring.html#//apple_ref/doc/uid/10000163i-CH1-SW2The minimum Watch OS version to build against. You cannot use APIs that are not supported in this version.
See https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/cross_development/Configuring/configuring.html#//apple_ref/doc/uid/10000163i-CH1-SW2Don't verify J2ObjC binaries. Useful for testing and power-users who know what they are doing and may wish to use a custom-build J2ObjC distribution.
Which architectures will be built and supported in packed ('fat') libraries.
The three ios_arm* architectures are for iPhone and iPad devices, while ios_i386 and ios_x86_64 are for their simulators. By default, only common modern iOS architectures will be built: ios_arm64, ios_armv7, ios_x86_64. You may choose to add any of the remaining entries from NativeCompilation.ALL_IOS_ARCHS (ios_i386 and ios_armv7s) to support all possible iOS architectures. Listing any new architectures outside of ALL_IOS_ARCHS will fail the build. Removing an architecture here will cause that architecture not to be built and corresponding gradle tasks to not be created.supportedArchs = ['ios_arm64'] // Only build libraries for 64-bit iOS devicesThe options are:
Command line arguments for j2objcTest task.
j2objcTest will fail if it runs less than the expected number of tests; set to 0 to disable.
It is a minimum so adding a unit test doesn't break the j2objc build.Filter on files to test. Note this has no effect on which tests are translated, just which tests are executed by the j2objcTest task.
If no pattern is specified, all files within the 'test' sourceSet are translated. This filter is applied on top of all files within the 'main' and 'test' java sourceSets. Use testPattern(groovy.lang.Closure) to configure.tests to translate
Command line arguments for j2objc translate.
A list of all possible arguments can be found here: http://j2objc.org/docs/j2objc.htmlLocal jars for translation e.g.: "lib/json-20140107.jar", "lib/somelib.jar". This will be added to j2objc as a '-classpath' argument.
Additional Java libraries that are part of the j2objc distribution.
For example:translateJ2objcLibs = ["j2objc_junit.jar", "jre_emul.jar"]
True iff only translation (and cycle finding, if applicable) should be attempted, skipping all compilation, linking, and testing tasks.
Sets the filter on files to translate.
If no pattern is specified, all files within the sourceSets are translated. This filter is applied on top of all files within the 'main' and 'test' java sourceSets. Use translatePattern(groovy.lang.Closure) to configure.A mapping from source file names (in the project Java sourcesets) to alternate source files. Both before and after names (keys and values) are evaluated using project.file(...).
Mappings can be used to have completely different implementations in your Java jar vs. your Objective-C library. This can be especially useful when compiling a third-party library and you need to provide non-trivial OCNI implementations in Objective-C.Source jars for translation e.g.: "lib/json-20140107-sources.jar"
The Xcode build configurations which should link to the generated debug libraries. If set to an empty array, the Debug configuration will be omitted from the "pod method".
For example:
j2objcConfig {
xcodeDebugConfigurations += ['Beta']
...
}
Directory of the target Xcode project. Suggested location is '../ios' See J2ObjC Plugin Folder Structure
The Xcode build configurations which should link to the generated release libraries. If set to an empty array, the Release configuration will be omitted from the "pod method".
For example:
j2objcConfig {
xcodeReleaseConfigurations += ['Preview']
...
}
iOS app and test Xcode targets to link to the generated libraries. This will automatically add linkage for any target in the specified list to the generated shared libraries. This should include test targets also.
Allows manual config of Xcode targets in the Podfile (default is false). When set to true, this allows manual configuring of the Podfile targets. This is necessary when your Podfile is too complex to be automatically updated. It will still add the "Pod Method" (e.g. j2objc_shared) but it will not update the targets within the Podfile. When used, you must also set xcodeTargets{Ios|Osx|Watchos) to empty.
OS X app and test Xcode targets that should be linked to the generated libraries. This will automatically add linkage for any target in the specified list to the generated shared libraries. This should include test targets also.
watchOS app and test Xcode targets that should be linked to the generated libraries. This will automatically add linkage for any target in the specified list to the generated shared libraries. This should include test targets also.
Add command line arguments for j2objc cycle_finder.
A list of all possible arguments can be found here: http://j2objc.org/docs/cycle_finder.htmlcycleFinderArgs - add args for 'cycle_finder' toolUses the generated headers and compiled j2objc libraries of the given project when compiling this project.
Generally every cross-project 'compile' dependency should have a corresponding call to dependsOnJ2objcLib. It is safe to use this in conjunction with --build-closure. Do not also include beforeProject's java source or jar in the translateSourcepaths or translateClasspaths, respectively. Calling this method is preferable and sufficient.Enables --build-closure, which translates classes referenced from the list of files passed for translation, using the translateSourcepaths.
Add arguments to pass to the native linker.
extraLinkerArgs - add arguments to pass to the native linker.Add additional native library to link to.
For example, if you built native library 'utils' in project 'common':extraNativeLib project: 'common', library: 'utils', linkage: 'static'
Add arguments to pass to the native compiler.
extraObjcCompilerArgs - add arguments to pass to the native compiler.Add directories of Objective-C headers to export in addition to the translated ones.
extraObjcHeaderDirs - add directories for Objective-C source to be compiledAdd directories of Objective-C source to compile in addition to the translated source.
extraObjcSrcDirs - add directories for Objective-C source to be compiledConfigures the j2objc build. Must be called at the very end of your j2objcConfig block.
Add generated source files directories, e.g. from dagger annotations.
generatedSourceDirs - adds generated source directories for j2objc translateAn architecture is active if it is both supported (supportedArchs) and enabled in the current environment via the comma-separated j2objc.enabledArchs value in local.properties.
If no j2objc.enabledArchs value is specified in local.properties, all supported architectures are also active, otherwise the intersection of supportedArchs and j2objc.enabledArchs is used.Get J2ObjC project dependencies. Must not be modified by caller.
Add command line arguments for j2objcTest task.
testArgs - add args for the 'j2objcTest' taskConfigures the testPattern
Calling this method repeatedly further modifies the existing testPattern, and will create an empty testPattern if none exists. For example:
translatePattern {
exclude 'CannotTranslateFileTest.java'
exclude '**/CannotTranslateDir/*.java'
include '**/CannotTranslateDir/AnExceptionToIncludeTest.java'
}
Add command line arguments for j2objc translate.
A list of all possible arguments can be found here: http://j2objc.org/docs/j2objc.htmltranslateArgs - add args for the 'j2objc' toolLocal jars for translation e.g.: "lib/json-20140107.jar", "lib/somelib.jar". This will be added to j2objc as a '-classpath' argument.
translateClasspaths - add libraries for -classpath argumentConfigures the translatePattern.
Calling this method repeatedly further modifies the existing translatePattern, and will create an empty translatePattern if none exists. For example:
translatePattern {
exclude 'CannotTranslateFile.java'
exclude '**/CannotTranslateDir/*.java'
include '**/CannotTranslateDir/AnExceptionToInclude.java'
}
Adds a new source mapping.
Source jars for translation e.g.: "lib/json-20140107-sources.jar"
translateSourcepaths - args add source jar for translationiOS app and test Xcode targets to link to the generated libraries.
xcodeTargetsIos - targets to link to the generated libraries.OS X app and test Xcode targets to link to the generated libraries.
xcodeTargetsOsx - targets to link to the generated libraries.watchOS app and test Xcode targets to link to the generated libraries.
xcodeTargetsWatchos - targets to link to the generated libraries.Groovy Documentation