Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# J2ObjC Gradle Plugin

This is the Gradle Plugin for [J2ObjC](https://github.com/google/j2objc), which is an open-source
tool from Google that translates Java source code to Objective-C for the iOS (iPhone/iPad)
platform. The plugin is not affiliated with Google but was developed by former Google Engineers
and others. J2ObjC enables Java source to be part of an iOS application's build, as no editing of
the generated files is necessary. The goal is to write an app's non-UI code (such as application
logic and data models) in Java, which is then shared by web apps (using GWT), Android apps,
and iOS apps.
Gradle Plugin for [J2ObjC](https://github.com/google/j2objc),
which is an open-source tool from Google that translates
Java source code to Objective-C for the iOS (iPhone/iPad) platform. The plugin is
not affiliated with Google but was developed by former Google Engineers and others.
J2ObjC enables Java source to be part of an iOS application's build, no editing
of the generated files is necessary. The goal is to write an app's non-UI code
(such as application logic and data models) in Java, which is then shared by
Android apps (natively Java), web apps (using GWT), and iOS apps (using J2ObjC).


### Usage
Expand All @@ -23,28 +24,26 @@ Android application. This if beneficial for separation between the application m
and user interface and a project which can easily be used server side as well.

The Android app, shared Java project and Xcode should be sibling directories, i.e children
of the same root level folder. Suggested names are `android, shared & ios` respectivey.
See the section below on [Folder Structure](#folder-structure).
of the same root level folder. Suggested folder names are `'android', 'shared' and 'ios'`
respectivey. See the section below on [Folder Structure](#folder-structure).

Configure `shared/build.gradle` in your Java only project:

// File: shared/build.gradle
plugins {
id 'java'
id 'com.github.j2objccontrib.j2objcgradle' version '0.3.0-alpha'
id 'com.github.j2objccontrib.j2objcgradle' version '0.4.0-alpha'
}

// Plugin settings:
j2objcConfig {
xcodeProjectDir '../ios' // Xcode workspace directory (suggested name)
xcodeTarget 'IOS-APP' // iOS app target name (replace with existing app name)

// Other Settings:
// https://github.com/j2objc-contrib/j2objc-gradle/blob/master/src/main/groovy/com/github/j2objccontrib/j2objcgradle/J2objcConfig.groovy#L30

finalConfigure() // Must be last call to configuration
}

Info on additional `j2objcConfig` settings are in (J2objcConfig.groovy)[https://github.com/j2objc-contrib/j2objc-gradle/blob/master/src/main/groovy/com/github/j2objccontrib/j2objcgradle/J2objcConfig.groovy#L30].
Within the Android application's `android/build.gradle`, make it dependent on
the `shared` project:

Expand All @@ -70,8 +69,7 @@ directory. It is integrated with Gradle's Java build plugin and may be run as fo

./gradlew shared:build

To update an existing Xcode project to load the libraries and header files, use this
additional command:
To update the existing Xcode project to load the libraries and header files:

./gradlew shared:j2objcXcode

Expand Down
15 changes: 8 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ version = '0.4.0-alpha'
pluginBundle {
website = 'https://www.github.com/j2objc-contrib/j2objc-gradle/'
vcsUrl = 'https://github.com/j2objc-contrib/j2objc-gradle'
description = 'Gradle Plugin for J2ObjC, which is an open-source tool from Google that translates ' +
'Java source code to Objective-C for the iOS (iPhone/iPad) platform. The plugin is ' +
'not affiliated with Google but was developed by former Google Engineers and others. ' +
'J2ObjC enables Java source to be part of an iOS application\'s build, as no editing ' +
'of the generated files is necessary. The goal is to write an app\'s non-UI code ' +
'(such as application logic and data models) in Java, which is then shared by web ' +
'apps (using GWT), Android apps, and iOS apps.'
description =
"Gradle Plugin for J2ObjC, which is an open-source tool from Google that translates " +
"Java source code to Objective-C for the iOS (iPhone/iPad) platform. The plugin is " +
"not affiliated with Google but was developed by former Google Engineers and others. " +
"J2ObjC enables Java source to be part of an iOS application's build, no editing " +
"of the generated files is necessary. The goal is to write an app's non-UI code " +
"(such as application logic and data models) in Java, which is then shared by " +
"Android apps, web apps (using GWT), and iOS apps (using J2ObjC)."
tags = ['android', 'java', 'j2objc', 'ios', 'iphone', 'objective-c', 'xcode']

plugins {
Expand Down