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

Add support for android library plugin #305

Closed
yomik opened this issue Mar 11, 2015 · 10 comments
Closed

Add support for android library plugin #305

yomik opened this issue Mar 11, 2015 · 10 comments
Milestone

Comments

@yomik
Copy link
Contributor

yomik commented Mar 11, 2015

0.4.8 added support for Android gradle plugin (com.android.application).

However, it lacks support for Android libraries (com.android.library). It would be nice to have support for these as well.

@joelittlejohn
Copy link
Owner

Could you elaborate a bit on what you can and can't do with the current android support? I don't fully understand why this plugin needs to explicitly support these libraries. Can you not simply add this dependency yourself? Or do you need this plugin to recognise com.android.library as something that should be treated as an android plugin?

Hopefully @ben-manes and @samskiter could offer an opinion on this too :)

@samskiter
Copy link
Collaborator

@joelittlejohn this is probably the same basic issue as #266

@yomik i guess you are receiving an error about the java plugin being incompatible with the android plugin.

I imagine that this should be an easy fix for someone who knows more about the system.

Looks as though it would just require an addition here:

https://github.com/joelittlejohn/jsonschema2pojo/blob/master/jsonschema2pojo-gradle-plugin/src/main/groovy/org/jsonschema2pojo/gradle/GenerateJsonSchemaTask.groovy#L44

@joelittlejohn
Copy link
Owner

Is this something that every Gradle plugin has to go through? Something
doesn't feel right about this but I don't know enough Gradle projects to
understand this :)
On 11 Mar 2015 16:38, "Sam Duke" notifications@github.com wrote:

@joelittlejohn https://github.com/joelittlejohn this is probably the
same basic issue as #266
#266

@yomik https://github.com/yomik i guess you are receiving an error
about the java plugin being incompatible with the android plugin.

I imagine that this should be an easy fix for someone who knows more about
the system.

Looks as though it would just require an addition here:

https://github.com/joelittlejohn/jsonschema2pojo/blob/master/jsonschema2pojo-gradle-plugin/src/main/groovy/org/jsonschema2pojo/gradle/GenerateJsonSchemaTask.groovy#L44


Reply to this email directly or view it on GitHub
#305 (comment)
.

@samskiter
Copy link
Collaborator

im probably less familiar. are there any other ways to integrate other than as a plugin?

@ben-manes
Copy link
Collaborator

I didn't realize that the Android stack has two plugins (library and application). As Sam said, its probably as simple as adding an OR condition to inspect for that plugin as well. I'd like to have a sample project like last time to verify with.

Most Gradle plugins don't have this complexity with Android as they don't need to integrate into a compilation workflow. This is one of the few cases where Maven's phase model is easier than a task graph, because the code generation would always occur prior to the compiler plugin's execution. In Gradle, we need to setup the dependencies which due to Android's non-standard workflow adds complexity. We could of course make our users configure the DAG themselves, but that would annoy them and spam you with a lot of basic setup questions.

If @yomik provided a sample project, perhaps by extending @samskiter's, this should be an easy task.

@joelittlejohn
Copy link
Owner

Fantastic, thanks for the detailed explanation Ben.
On 11 Mar 2015 19:46, "Ben Manes" notifications@github.com wrote:

I didn't realize that the Android stack has two plugins (library and
application). As Sam said, its probably as simple as adding an OR condition
to inspect for that plugin as well. I'd like to have a sample project like
last time to verify with.

Most Gradle plugins don't have this complexity with Android as they don't
need to integrate into a compilation workflow. This is one of the few cases
where Maven's phase model is easier than a task graph, because the code
generation would always occur prior to the compiler plugin's execution. In
Gradle, we need to setup the dependencies which due to Android's
non-standard workflow adds complexity. We could of course make our users
configure the DAG themselves, but that would annoy them and spam you with a
lot of basic setup questions.

If @yomik https://github.com/yomik provided a sample project, perhaps
by extending @samskiter https://github.com/samskiter's, this should be
an easy task.


Reply to this email directly or view it on GitHub
#305 (comment)
.

@yomik
Copy link
Contributor Author

yomik commented Mar 12, 2015

Sorry, I should have given more details.

@ben-manes I checked the official Android documentation (https://developer.android.com/tools/building/plugin-for-gradle.html) and apparently the library part is omitted. It is referenced in the (outdated) documentation : http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Library-projects but has the deprecated naming "android-library", which changed to "com.android.library" (this has been announced in the changelog of the Android gradle plugin at some time but I couldn't find it).

@samskiter I'm getting the error "generateJsonSchema: Java or Android plugin required", thrown exactly where the link you gave points at.

I believe the fix consists in adding "com.android.library" to the condition, with the same call to configureAndroid().

I will try to provide a sample project later.

I realize that this is very confusing for a non-Android developer :/

@ben-manes
Copy link
Collaborator

@yomik Take a look at the sample that Sam provided us for the android-application plugin support. You could either extend it or adapt a new example based on it, if that helps.

yomik added a commit to yomik/jsonschema2pojo that referenced this issue Mar 13, 2015
yomik added a commit to yomik/jsonschema2pojo that referenced this issue Mar 16, 2015
joelittlejohn added a commit that referenced this issue Mar 16, 2015
#305 : Add android lib sample + Add support for android library plugin
@ben-manes
Copy link
Collaborator

@yomik Just checked up on this issue and I see that you have a branch with a sample and the fix. If it works, can you send a pull request? The changes lgtm except that I'd ask to keep it to 100c by indenting the second clause in the if statement.

@ben-manes
Copy link
Collaborator

Oh, just found #311. Closing

@joelittlejohn joelittlejohn added this to the 0.4.10 milestone Mar 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants