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

Automatic dependency resolution. #420

Merged
merged 1 commit into from
Aug 26, 2015
Merged

Conversation

advayDev1
Copy link
Contributor

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.

#180; Fixes #41; Fixes #372

TESTED=yes

@advayDev1
Copy link
Contributor Author

@brunobowden - please do #411 first; this relies heavily on it.

#180; Fixes #41; Fixes #372

@ph1lb4 @roisagiv - please take a look. this should automatically handle the simple kinds of dependencies you've pointed out.

While the system tests do exercise the functionality, unfortunately my own project has internal native code dependencies which I haven't automated yet (I assume I am in the minority), so I cannot test this on a complicated project. So any of you trying this out would be quite helpful.

If you add autoConfigureDeps = true to j2objcConfig in shared build.gradle, and remove the extra stuff you added manually, it should work. Please let me know if it does not.

The one thing I know this cannot handle yet is #419.

@advayDev1
Copy link
Contributor Author

I will write a separate PR for updating all our docs. I think 1-hop dependencies on a third-party JAR is one of the last things we needed to simplify to get people working quickly out-of-the-box.

@advayDev1
Copy link
Contributor Author

@brunobowden - ptal; remerged/rebased. Note that all the dependency tests are in multiProject as adding a full new system test for auto deps vs. manual deps costs us a lot in terms of runtime on Travis.

I think in the end we will have 3 system tests: simple, multiProject (for all kinds of dependencies), and exhaustive (which stresses every feature we have).

@advayDev1 advayDev1 force-pushed the autoDeps branch 3 times, most recently from 4a586cc to 12ee972 Compare August 26, 2015 10:24
@@ -31,6 +31,7 @@ Paste the results below, replacing existing contents.
- [Error: implicit declaration of function 'JreRelease' is invalid in C99 [-Werror,-Wimplicit-function-declaration] JreRelease(this$0_)](#error-implicit-declaration-of-function-jrerelease-is-invalid-in-c99--werror-wimplicit-function-declaration-jrereleasethis0_)
- [How do I disable a plugin task?](#how-do-i-disable-a-plugin-task)
- [How do I setup dependencies with J2ObjC?](#how-do-i-setup-dependencies-with-j2objc)
- [How do I setup a dependency to a third-party Java library?](#how-do-i-setup-a-dependency-to-a-third-party-java-library)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should dependencies be split out to their own doc? It feels like that's becoming a substantial section unto itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my next PR, i hope to make dependencies a much shorter doc :)
it should be much simpler once this goes in.

@advayDev1 advayDev1 force-pushed the autoDeps branch 3 times, most recently from 906f38c to 02b1bf4 Compare August 26, 2015 20:37
@advayDev1
Copy link
Contributor Author

ptal @brunobowden - should be good to go

@advayDev1
Copy link
Contributor Author

if you run ./gradlew extended:dependencies from multiProject1

j2objcLinkage - J2ObjC dependencies that need to be linked into the final library, and do not need translation
\--- project :base
     \--- com.google.guava:guava:17.0

j2objcTranslation - J2ObjC dependencies that need to be transitively translated via --build-closure
\--- com.google.code.gson:gson:2.3.1

@@ -85,6 +85,21 @@ class J2objcPlugin implements Plugin<Project> {
// specified in j2objcConfig (or associated defaults in J2objcConfig).
File j2objcSrcGenDir = file("${buildDir}/j2objcSrcGen")

configurations {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add note:

// These configurations are groups of artifacts and dependencies for the plugin build
// https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.Configuration.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. i don't see the need to link to uniquely identifiable JavaDoc (or similar though). we could do that for any gradle api...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something more unusual and special. I'm thinking of my own ignorance as I was reading your code. If I need to look something up, then it's highly likely that someone else will need the same. If something seems straight forward to me, then I don't bother asking to add a reference. So it's a qualitative judgement that I agree should be limited.

@brunobowden
Copy link
Contributor

Also, should this have a separate compile and testCompile configurations?

@advayDev1
Copy link
Contributor Author

No, see my reply to you earlier. There is no way to distinguish right now.

@brunobowden
Copy link
Contributor

LGTM - great work on this. Delighted to see this up and working.

@advayDev1
Copy link
Contributor Author

Now I just want to see at least one person using it successfully ;)

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
@advayDev1
Copy link
Contributor Author

Aside @brunobowden ;
if we solve #419 and #425, I think the vast majority of our users' use-cases will be automatically configured. #425 is easy. #419 requires writing a 2nd plugin (within our plugin bundle)

advayDev1 added a commit that referenced this pull request Aug 26, 2015
Automatic dependency resolution.
@advayDev1 advayDev1 merged commit 37fbc05 into j2objc-contrib:master Aug 26, 2015
@advayDev1 advayDev1 deleted the autoDeps branch August 26, 2015 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants