Check if project is a library project

50 views
Skip to first unread message

Csaba Kozák

unread,
Nov 3, 2015, 3:58:31 AM11/3/15
to adt-dev
We are writing an annotation processor and we want to know the currently processed project is a library project or not.
In the old ways, we could just parse the project.properties file.
Is there a way to get this information in case of Gradle builds (without parsing the whole build script)?

Thanks, in advance!

Michal Bendowski

unread,
Nov 4, 2015, 5:19:18 AM11/4/15
to adt-dev
You can imagine a build.gradle file with the following code:

if (new Random().nextInt() > 42) {
apply plugin: 'com.android.application'
} else {
apply plugin: 'com.android.library'
}

so there's no reliable way to check, unless you are being invoked by a Gradle task and the task passes that information to you somehow.

HTH,

Michal

Csaba Kozák

unread,
Nov 4, 2015, 5:23:21 AM11/4/15
to adt...@googlegroups.com
Hey,

Thanks for the answer. Actually the annotation processor runs after the Gradle Android plugin generated resources etc.
So basically i am asking whether is there an indicator file which the plugin generates and we can check.
Like we are already using the full manifest generated by the Android Gradle plugin.


Csabi

--
You received this message because you are subscribed to a topic in the Google Groups "adt-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adt-dev/MXg9G8oCceY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jake Wharton

unread,
Nov 4, 2015, 5:53:33 AM11/4/15
to adt...@googlegroups.com
Related to http://b.android.com/187527. Add your use-case onto that ticket.

You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.

Csaba Kozák

unread,
Nov 5, 2015, 7:14:24 AM11/5/15
to adt...@googlegroups.com
Thanks Jake for the pointer, i added a comment on the ticket.
Reply all
Reply to author
Forward
0 new messages