# Do Something Different in Android Library Depending on Parent Project

**URL:** <https://discuss.gradle.org/t/do-something-different-in-android-library-depending-on-parent-project/27080>\
**Category:** Help/Discuss\
**Tags:** android\
**Created:** [May 24, 2018, 5:07pm UTC](https://discuss.gradle.org/t/do-something-different-in-android-library-depending-on-parent-project/27080 "2018-05-24T17:07:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![datadino](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@datadino](https://discuss.gradle.org/u/datadino)\
**Post date:** [May 24, 2018, 5:07pm UTC](https://discuss.gradle.org/t/do-something-different-in-android-library-depending-on-parent-project/27080/1 "2018-05-24T17:07:08Z")

</div>

I have a Android Library project that takes a config file and it uses to generate all the required `BuildConfig` values. The config file is given via a project property `PROPS` and used passed in via command line:

```
./gradlew -PPROPS=../somefile.xml build 

```

When the Android Library project is included in an Android Application project, the same `PROPS` file is used via the command line. All good so far.

The root project has 2 Android Application sub-projects and both depend on the Android Library project.

Today they have to be built separately and with the config file passed in:

```
// First project
./gradlew -PPROPS=../some-file-a.xml projecta:build

// Second project
./gradlew -PPROPS=../some-file-b.xml projectb:build

```

I don’t like this and would like to just be able to say:

```
./gradlew build

```

And have it build both projects, but each of the projects requires that the common Android Library project be given a different config file.

I’ve tried setting the `PROPS` property during the configuration step in each of the Android application projects:

```
// In projecta/build.gradle
rootProject.ext.PROPS='../some-file-a.xml'

// In projectb/build.gradle
rootProject.ext.PROPS='../some-file-b.xml'

```

But since that both projects set the same property, once the Android Library project runs it just sees the last one that gets set. This breaks my build because it configures the Android Library the same (based on the last config file set).

**Question**

Ideally, I’d like to be able to, at build-time, determine what file the Android Library project should use based on which top-level Android Application project it is part of.

I understand that what I’m asking for may not be the “Gradle Way” so I’m also interested in learning about the proper way to do this, if one exist.

**Update**

Using configuration on demand (Set org.gradle.configureondemand=true in gradle.properties) I am able to build each project individually using a default config file for each project:

```
// First Project
./gradlew projecta:build

// Second Project
./gradlew projectb:build

```

But still can’t build both at once:

```
./gradlew build
```
