Guava: Publish Proguard configs with Guava

Created on 27 Jul 2015  路  20Comments  路  Source: google/guava

We are working on some internally. Once they're ready, we should publish them in Guava. I don't know if there's a standard way to do this with Maven.

P3 package=general status=triaged type=other

Most helpful comment

Since Guava is dependency-free, you could publish a sibling artifact using the 'aar' packaging whose format allows embedding proguard rules.

Android users wanting the automatic rules would specify a dependency like

compile 'com.google.guava:guava:19.0@aar'

instead of just

compile 'com.google.guava:guava:19.0'

All 20 comments

Since Guava is dependency-free, you could publish a sibling artifact using the 'aar' packaging whose format allows embedding proguard rules.

Android users wanting the automatic rules would specify a dependency like

compile 'com.google.guava:guava:19.0@aar'

instead of just

compile 'com.google.guava:guava:19.0'

(Dependency-free is important because using a package qualifier on a dependency skips the deployed pom.xml for looking up transitive dependencies)

Thanks. I take it that our <optional>true</optional> dependencies on various projects' annotation artifacts aren't a problem here?

Right. Any build system parsing the pom.xml should ignore those anyway.

It would be great if there as a "it just works" solution. It all looks so good at first when a simple

compile 'com.google.guava:guava:19.0'

gives your project all the Guava goodness, but come time to build a real-world APK with

        minifyEnabled true
        shrinkResources true

the fun ends due to all the errors. The error messages are obtuse and don't even provide much clue that Guava's the cause.

Is this dead? The proguard rules in the wiki seem terribly out of date.

@netdpb any ideas?

We do have proguard.cfg files internally. We've just never published them :(

@cpovirk Any chance you could start including it in the public repo?

Shouldn't be too hard. I will make myself a note for when I'm finished with my current project (probably a couple weeks, or maybe I'll need a small project before then).

(We'll still want to do the aar setup eventually, but that will be a bigger project. Or maybe someone can provide a pull request once the files are actually present.)

@cpovirk any updates?

Ended up needing to take on another project, so I've delayed working on this again, sorry. It's still on my list.

Any updates?

Is it possible to change the build tools. If we switch to gradle or bazel like dagger, this will be much easier.

@gengjiawen I opened an issue for that some time ago: https://github.com/google/guava/issues/2850. :)

R8 now understands proguard specs in META-INF/proguard. We could use that to publish without needing to change the packaging

@ronshapiro Create resource folder in android folder and put the proguard file there ?

I was wondering if there was any follow-up to @ronshapiro's comment about including the config even inside a jar? I didn't see anything in the 27.1-android jar.

Is the recommended solution to copy-paste the contents of https://github.com/google/guava/wiki/UsingProGuardWithGuava into our own library/app proguard config?

No followup. This is another thing that "someone should do." And it's another thing that is becoming only more important over time. Hopefully that will help us make it happen.

Truth may also benefit from one of these. It looks like all we have internally is -dontwarn java.lang.SafeVarargs, but we may want to do more around our reflective access to ActualValueInference/ASM (touched recently in https://github.com/google/truth/commit/aea78e81c090e377c44287ce87e4760177a5b207 and https://github.com/google/truth/commit/0bfa285fa5ed629cb2c69e18ab0c6d0e98ef8b96).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cpovirk picture cpovirk  路  5Comments

jdesmet picture jdesmet  路  4Comments

ernestp picture ernestp  路  3Comments

Hanmac picture Hanmac  路  3Comments

PhilippWendler picture PhilippWendler  路  4Comments