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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ Tracked issue: https://github.com/j2objc-contrib/j2objc-gradle/issues/130**
xcodeProjectDir "${projectDir}/../ios" // Xcode workspace directory
xcodeTarget "IosApp" // Xcode application target name

// More: https://github.com/j2objc-contrib/j2objc-gradle/blob/master/src/main/groovy/com/github/j2objccontrib/j2objcgradle/J2objcPluginExtension.groovy#L25
// Help information on other settings:
// https://github.com/j2objc-contrib/j2objc-gradle/blob/master/src/main/groovy/com/github/j2objccontrib/j2objcgradle/J2objcPluginExtension.groovy#L25

// You must include this call (at the end of the block) even if you do not configure any other settings.
// You must include this call (at the end of j2objcConfig) regardless of settings
finalConfigure()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,16 @@ class J2objcPlugin implements Plugin<Project> {
void apply(Project project) {
// This avoids a lot of "project." prefixes, such as "project.tasks.create"
project.with {
if (!plugins.hasPlugin('java')) {
def message =
"j2objc plugin didn't find the 'java' plugin in the '${project.name}' project.\n"+
"This is a requirement for using j2objc. Please see usage information at:\n" +
"\n" +
"https://github.com/j2objc-contrib/j2objc-gradle/#usage"
throw new InvalidUserDataException(message)
}

extensions.create('j2objcConfig', J2objcPluginExtension, project)

afterEvaluate { evaluatedProject ->

// Validate minimally required parameters.
// j2objcHome() will throw the appropriate exception internally.
assert J2objcUtils.j2objcHome(evaluatedProject)

J2objcUtils.throwIfNoJavaPlugin(evaluatedProject)

if (!evaluatedProject.j2objcConfig.isFinalConfigured()) {
def message = "You must call finalConfigure() in j2objcConfig, ex:\n" +
"j2objcConfig {\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,21 @@ class J2objcUtils {
return System.getProperty('os.name').toLowerCase().contains('windows')
}

static void throwIfNoJavaPlugin(Project proj) {
if (!proj.plugins.hasPlugin('java')) {
String message =
"j2objc plugin didn't find the 'java' plugin in the '${proj.name}' project.\n" +
"This is a requirement for using j2objc. Please see usage information at:\n" +
"\n" +
"https://github.com/j2objc-contrib/j2objc-gradle/#usage"
throw new InvalidUserDataException(message)
}
}

// Retrieves the configured source directories from the Java plugin SourceSets.
static SourceDirectorySet srcDirs(Project proj, String sourceSetName, String fileType) {
throwIfNoJavaPlugin(proj)

assert fileType == 'java' || fileType == 'resources'
assert sourceSetName == 'main' || sourceSetName == 'test'
SourceSet sourceSet = proj.sourceSets.findByName(sourceSetName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ public class J2objcUtilsTest {
J2objcUtils.isWindows()
}

@Test(expected = InvalidUserDataException.class)
public void testThrowIfNoJavaPlugin_NoJavaPlugin() {
J2objcUtils.throwIfNoJavaPlugin(proj)
}

// TODO: testThrowIfNoJavaPlugin_JavaPluginExists

// TODO: testSrcDirs() - requires 'java' plugin

// TODO: testSourcepathJava() - requires 'java' plugin
Expand Down