-
Notifications
You must be signed in to change notification settings - Fork 43
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
Support multiple source set directories #48
Conversation
project.sourceSets['test'].java.srcDirs.each { | ||
javaRoots += it.path | ||
} | ||
def sourcepath = javaRoots.join(':') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code looks good... but if you search for "src/main/java", you'll notice that the change also needs to be shared with the CycleFinderTask - line 363.
Best thing is to extract the new code to a static method on the J2objcUtils class. It'll accept "project" as a parameter and return javaRoots.join(':'). The method with then be used in both CycleFinderTask and TranslateTask. Name the method as follows:
static def sourcepathJava(Project proj) {...
…properties instead of hard-coding them. This is useful when you have multiple source-sets, such as: sourceSets { main { java.srcDirs += ['otherJavaRoot/'] } }
Thanks - commit amended to d7d5081 Also for my own reference, is it intentional that you use return to return values from methods, and not just leaving the value as the last statement in the method? Want to stay consistent with your coding style. |
I didn't realize that groovy could do returns without a return statement. I'll definitely keep the style of adding "return" as I think it helps clarity for developers not as familiar with groovy. That also seems to be the consensus of StackOverflow: |
Support multiple source set directories
Hello, how should we update projects that dont use sourceSets to be able to translate again. Since I've updated to latest version I have this error :
Thanks |
I managed to make the build pass by adding this : sourceSets {
main {
}
test {
}
} in the build.gradle, above the dependencies section. |
I'll make a fix for this later today. BTW how is it that you don't use On Tue, May 19, 2015, 8:50 AM Maxime Britto notifications@github.com
|
I don't use any plugin, when I migrated my project from ant to gradle I created a blank Android studio project to see where it would put the sources and I followed those conventions. I also used the generated build.gradle file from the blank project and it doesn't contains any sourceSets entry. My project build without any issue without this. |
It seems we assume Java plugin convention in various parts of j2objc-gradle. Do you have a link to a build.gradle file you are willing to let us use? It might be helpful when creating a diverse testset some day. |
@maxbritto , filed issue #75 to track the fix. |
Thanks I'll track it there. I was wrong before, it is actually working with creating the empty sourceSets like this : sourceSets {
main {
}
test {
}
} I'm still exploring/discovering J2OBJC so I haven't added any test yet but for the sources they are now translated like they were before this change. Thanks for the quick answer. |
Support multiple source set directories by using appropriate project properties instead of hard-coding them.
This is useful when you have multiple source-sets, such as:
sourceSets {
main {
java.srcDirs += ['otherJavaRoot/']
}
}