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

Different build environments. #35

Open
man4ik opened this issue Jan 23, 2016 · 6 comments
Open

Different build environments. #35

man4ik opened this issue Jan 23, 2016 · 6 comments

Comments

@man4ik
Copy link

man4ik commented Jan 23, 2016

Please provide a sample which has different values for different build variants.

@zsoltk
Copy link
Owner

zsoltk commented Jan 23, 2016

I'm not sure I get what you mean. Please elaborate.

@man4ik
Copy link
Author

man4ik commented Jan 23, 2016

 productFlavors {
    dev {
        buildConfigField 'String', 'EXAMPLE_0', '"some value 000"'
        buildConfigField 'boolean', 'EXAMPLE_1', 'true'
    }
    prod {
        buildConfigField 'String', 'EXAMPLE_0', 'some value 111'
        buildConfigField 'boolean', 'EXAMPLE_1', '"false"'
    }

How can I replace above code by paperwork?
Different values of same variables for different productFlavors

@zsoltk
Copy link
Owner

zsoltk commented Jan 28, 2016

Right. I'm not sure if it's even theoretically possible to do that automatically, as you define your flavors / buildtypes in the android block. Maybe there's a workaround to access the current one outside of that scope, and someone will correct me on this.

What you can do however, is you could have a plugin config like:

paperwork {
    set = [
        debugKey1: "debug value",
        prodKey1: "prod value",
    ]
}

And then at runtime access it:

paperwork.get(BuildConfig.BUILD_TYPE + "Key1");

The plugin config supports arbitrary embedded structures, so in theory you could group all your debug keys in another set on level deeper without resorting to string concatenation. On the other hand, the runtime component only supports accessing a flat structure as of the moment.

@lordcodes
Copy link

I tried putting:

paperwork {
  set = [
     someKey = "some value"
  ]
}

Inside the debug block and then again in the release block to have a switch based on build type. Unfortunately, doing it this way means you have to duplicate all the keys that you want for both build types, as each paperwork block overwrites the previous.

I cannot use the prefix approach due to having another build type for development environment and would also rather not use a prefix-based approach.

Would it be possible to make it so that you can have multiple different paperwork blocks and have all the variables be added to the JSON file?

@zsoltk
Copy link
Owner

zsoltk commented Jan 29, 2017

@andrewlord1990 I think what you want to achieve has to do more with groovy than with paperwork, i.e. merging those arrays. Also, why not try the same key approach, but instead of literals, you could have function calls on the right side, then override those functions per environment. I haven't checked, but it would make sense if it worked.

@lordcodes
Copy link

lordcodes commented Jan 29, 2017 via email

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

3 participants