-
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
Automatically handle third-party libraries #372
Comments
We have the following dependencies:
And I included them as stated by you in another post with:
Everything translates fine, but when it comes to compiling the following problem occurs:
Do you know how to fix this? I also read that you are planing on automating this in next versions, which will be really convenient! The relevant parts:
|
that will translate gson joda and bsh as well. |
Does that mean it is not possible to use dependencies? Because the best thing about dependencies is that I don't have to worry about the jar files. |
How dependencies must be provided is a function of j2objc must have the source code for everything that needs to be translated into objective-c. j2objc happens to provide, for convenience, pre-translated versions of a few libraries like the JRE, junit, guava. But for gson, joda, bsh, etc. you'll need to provide the source. Or maybe you're asking: if you have and can use the source jars, does setting |
@jjroloff please see this issue and provide any more details you have re: your issue with gson. |
Actually I meant if it is possible that your plugin automatically downloads the jar file when a dependency is listed in the build script? |
On the roadmap #41 but not yet done. The main issue is resolving duplicates across multiple projects (i.e. when gson is loaded by 3 of your j2objc projects, we don't want to translate/compile/etc. it each time). For now, you'll have to put a |
@ph1lb4 - I suspect it would be useful for me to add a section to: We've covered dependencies on prebuilts, native code, and java projects, but not third-party java code in there. I'll send folks a PR (also @jjroloff) and let me know if it is clear. |
Ok thank you very much, looking forward to this feature! In the meantime I am still having troubles even with the jar files. My new build script looks as follows:
However we are still getting the same errors:
Do you know how to fix this? |
Are these source jars or classfile jars? If you unzip them do they .java files or .class files? |
If unzipped they all contain .class files |
Yep, you'll need to find source jars for each of those libraries. Put those in a 'srcLibs' directory (to keep them separate from the class jars which you still need), and then change the translateSourcepaths commands to refer to those sources jars. |
Oh I see, thank you very much for your patience and help, it builds successfully now! |
Awesome! Please take a look at #415 and let me know if it is clear enough for newcomers. |
Yes, I think the new part in the FAQ makes it much clearer. Should be good for newcomers. |
This trick worked for me: shared/build.gradle plugins {
id 'java'
id 'com.github.j2objccontrib.j2objcgradle' version '0.4.2-alpha'
}
configurations {
j2objc
}
dependencies {
compile 'com.eclipsesource.minimal-json:minimal-json:0.9.4'
j2objc 'com.eclipsesource.minimal-json:minimal-json:0.9.4:sources'
compile 'com.google.guava:guava:18.0'
compile 'com.google.j2objc:j2objc-annotations:0.9.8'
// test libraries
testCompile 'junit:junit:4.11'
testCompile 'org.mockito:mockito-core:1.9.5'
}
// Plugin settings:
j2objcConfig {
xcodeProjectDir '../ios' // Xcode workspace directory (suggested directory name)
xcodeTarget 'MyTarget' // iOS app target name (replace with existing app name)
translateArgs '-use-arc'
translateArgs '--build-closure'
extraObjcCompilerArgs '-fobjc-arc'
translateJ2objcLibs << 'hamcrest-core-1.3.jar'
configurations.j2objc.each { translateSourcepaths it.absolutePath.toString() }
finalConfigure() // Must be last call to configuration
}
|
What exactly do you mean by trick?
|
this line: |
Ok that is really great! I was just confused because you did not use it for your other dependencies. |
Yes, that's the first part of the solution: use the My current simple plan for #41 is to automatically generate a
if any dependencies of type (3) are found, If either of you have better ideas, please do tell! Thanks! |
Dependency configuration happens in 2 phases: - Dependency conversion: This converts your compile and testCompile dependencies into equivalent j2objcTranslate and j2objcLink dependencies. Namely local jars are copied to j2objcTranslate, external Maven jars are converted into their 'sources' form and copied to j2objcTranslate, and projects are copied to j2objcLink (they don't need translation). This phase is optional and controlled by j2objcConfig.autoConfigureDeps - Dependency resolution: This phase converts j2objcTranslate and j2objcLink deps into actual j2objc commands. Any source jar on j2objcTranslate is added to translateSourcepaths with --build-closure. Any project on j2objcLink is added to translateClasspaths and has its final j2objc static library linked in to this project's objective c code. This phase always runs. If your dependencies are too complicated for the plugin to figure out in the first phase, keep autoConfigureDeps=false, and just add the appropriate projets, jars, and libraries here. Also adds system tests for both project and external Maven dependencies. j2objc-contrib#180; Fixes j2objc-contrib#41; Fixes j2objc-contrib#372 TESTED=yes
Dependency configuration happens in 2 phases: - Dependency conversion: This converts your compile and testCompile dependencies into equivalent j2objcTranslate and j2objcLink dependencies. Namely local jars are copied to j2objcTranslate, external Maven jars are converted into their 'sources' form and copied to j2objcTranslate, and projects are copied to j2objcLink (they don't need translation). This phase is optional and controlled by j2objcConfig.autoConfigureDeps - Dependency resolution: This phase converts j2objcTranslate and j2objcLink deps into actual j2objc commands. Any source jar on j2objcTranslate is added to translateSourcepaths with --build-closure. Any project on j2objcLink is added to translateClasspaths and has its final j2objc static library linked in to this project's objective c code. This phase always runs. If your dependencies are too complicated for the plugin to figure out in the first phase, keep autoConfigureDeps=false, and just add the appropriate projets, jars, and libraries here. Also adds system tests for both project and external Maven dependencies. j2objc-contrib#180; Fixes j2objc-contrib#41; Fixes j2objc-contrib#372 TESTED=yes
Dependency configuration happens in 2 phases: - Dependency conversion: This converts your compile and testCompile dependencies into equivalent j2objcTranslate and j2objcLink dependencies. Namely local jars are copied to j2objcTranslate, external Maven jars are converted into their 'sources' form and copied to j2objcTranslate, and projects are copied to j2objcLink (they don't need translation). This phase is optional and controlled by j2objcConfig.autoConfigureDeps - Dependency resolution: This phase converts j2objcTranslate and j2objcLink deps into actual j2objc commands. Any source jar on j2objcTranslate is added to translateSourcepaths with --build-closure. Any project on j2objcLink is added to translateClasspaths and has its final j2objc static library linked in to this project's objective c code. This phase always runs. If your dependencies are too complicated for the plugin to figure out in the first phase, keep autoConfigureDeps=false, and just add the appropriate projets, jars, and libraries here. Also adds system tests for both project and external Maven dependencies. j2objc-contrib#180; Fixes j2objc-contrib#41; Fixes j2objc-contrib#372 TESTED=yes
Dependency configuration happens in 2 phases: - Dependency conversion: This converts your compile and testCompile dependencies into equivalent j2objcTranslate and j2objcLink dependencies. Namely local jars are copied to j2objcTranslate, external Maven jars are converted into their 'sources' form and copied to j2objcTranslate, and projects are copied to j2objcLink (they don't need translation). This phase is optional and controlled by j2objcConfig.autoConfigureDeps - Dependency resolution: This phase converts j2objcTranslate and j2objcLink deps into actual j2objc commands. Any source jar on j2objcTranslate is added to translateSourcepaths with --build-closure. Any project on j2objcLink is added to translateClasspaths and has its final j2objc static library linked in to this project's objective c code. This phase always runs. If your dependencies are too complicated for the plugin to figure out in the first phase, keep autoConfigureDeps=false, and just add the appropriate projets, jars, and libraries here. Also adds system tests for both project and external Maven dependencies. j2objc-contrib#180; Fixes j2objc-contrib#41; Fixes j2objc-contrib#372 TESTED=yes
Proposed solution is #420 |
Dependency configuration happens in 2 phases: - Dependency conversion: This converts your compile and testCompile dependencies into equivalent j2objcTranslate and j2objcLink dependencies. Namely local jars are copied to j2objcTranslate, external Maven jars are converted into their 'sources' form and copied to j2objcTranslate, and projects are copied to j2objcLink (they don't need translation). This phase is optional and controlled by j2objcConfig.autoConfigureDeps - Dependency resolution: This phase converts j2objcTranslate and j2objcLink deps into actual j2objc commands. Any source jar on j2objcTranslate is added to translateSourcepaths with --build-closure. Any project on j2objcLink is added to translateClasspaths and has its final j2objc static library linked in to this project's objective c code. This phase always runs. If your dependencies are too complicated for the plugin to figure out in the first phase, keep autoConfigureDeps=false, and just add the appropriate projets, jars, and libraries here. Also adds system tests for both project and external Maven dependencies. j2objc-contrib#180; Fixes j2objc-contrib#41; Fixes j2objc-contrib#372 TESTED=yes
Dependency configuration happens in 2 phases: - Dependency conversion: This converts your compile and testCompile dependencies into equivalent j2objcTranslation and j2objcLinkage dependencies. Namely local jars are copied to j2objcTranslation, external Maven jars are converted into their 'sources' form and copied to j2objcTranslation, and projects are copied to j2objcLinkage (they don't need translation). This phase is optional and controlled by j2objcConfig.autoConfigureDeps - Dependency resolution: This phase converts j2objcTranslation and j2objcLinkage deps into actual j2objc commands. Any source jar on j2objcTranslation is added to translateSourcepaths with --build-closure. Any project on j2objcLinkage is added to translateClasspaths and has its final j2objc static library linked in to this project's objective c code. This phase always runs. If your dependencies are too complicated for the plugin to figure out in the first phase, keep autoConfigureDeps=false, and just add the appropriate projets, jars, and libraries here. Also adds system tests for both project and external Maven dependencies. issue j2objc-contrib#180; Fixes j2objc-contrib#41; Fixes j2objc-contrib#372 TESTED=yes
@ph1lb4 - could you repost your emailed question re: translating dependent jars here?
Please provide the relevant j2objcConfig, the version of the plugin you are using, your dependencies { } block if possible, and any errors.
The text was updated successfully, but these errors were encountered: