Skip to content

Commit

Permalink
Merge pull request #470 from brunobowden/update
Browse files Browse the repository at this point in the history
filenameCollisionCheck defaults to false
  • Loading branch information
brunobowden committed Sep 30, 2015
2 parents f2e1895 + 0ffe6f6 commit 3b48fb7
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,20 @@ class J2objcConfig {

// TODO: warn if different versions than testCompile from Java plugin
/**
* Makes sure that the translated filenames don't collide.
* Force filename collision check so prohibit two files with same name.
* <p/>
* Recommended if you choose to use --no-package-directories.
* 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.
*/
boolean filenameCollisionCheck = true
boolean forceFilenameCollisionCheck = false

// All access to filenameCollisionCheck should be done through this function
boolean getFilenameCollisionCheck() {
if (translateArgs.contains('--no-package-directories'))
return true
return forceFilenameCollisionCheck
}

/**
* Sets the filter on files to translate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class CycleFinderTask extends DefaultTask {
Map<String, String> getTranslateSourceMapping() { return J2objcConfig.from(project).translateSourceMapping }

@Input
boolean getFilenameCollisionCheck() { return J2objcConfig.from(project).filenameCollisionCheck }
boolean getFilenameCollisionCheck() { return J2objcConfig.from(project).getFilenameCollisionCheck() }


// Output required for task up-to-date checks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class TranslateTask extends DefaultTask {
Map<String, String> getTranslateSourceMapping() { return J2objcConfig.from(project).translateSourceMapping }

@Input
boolean getFilenameCollisionCheck() { return J2objcConfig.from(project).filenameCollisionCheck }
boolean getFilenameCollisionCheck() { return J2objcConfig.from(project).getFilenameCollisionCheck() }


// Generated ObjC files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ class Utils {
"To disable this check (which may overwrite files), modify build.gradle:\n" +
"\n" +
"j2objcConfig {\n" +
" filenameCollisionCheck false\n" +
" forceFilenameCollisionCheck false\n" +
"}\n"
throw new InvalidUserDataException(message)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,20 @@ class J2objcConfigTest {
ext.getDestSrcDirFile('test', 'resources').absolutePath
}

@Test
void testFilenameCollisionCheckIsSet_Default() {
J2objcConfig ext = new J2objcConfig(proj)
assert !ext.getFilenameCollisionCheck()
}

@Test
void testFilenameCollisionCheckIsSet_NoPackageDirectories() {
J2objcConfig ext = new J2objcConfig(proj)
ext.translateArgs('--no-package-directories')
assert !ext.forceFilenameCollisionCheck
assert ext.getFilenameCollisionCheck()
}

@Test
void testFinalConfigure_MacOSX() {
Utils.setFakeOSMacOSX()
Expand Down
2 changes: 1 addition & 1 deletion systemTests/externalLibrary1/third_party_gson/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies {
}

j2objcConfig {
filenameCollisionCheck false
forceFilenameCollisionCheck false
// For now, default config links in prebuilt Guava; that defeats the point.
translateJ2objcLibs.remove("j2objc_guava.jar")
linkJ2objcLibs.remove("guava")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ j2objcConfig {

// Iterators and the like are common names across packages. This library must
// be compiled with full directory paths.
filenameCollisionCheck false
forceFilenameCollisionCheck false
autoConfigureDeps true
// Almost always there are no tests provided in an external source jar.
testMinExpectedTests 0
Expand Down

0 comments on commit 3b48fb7

Please sign in to comment.