Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filenameCollisionCheck defaults to false #470

Merged
merged 1 commit into from
Sep 30, 2015
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
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