0

Proguard has options for -keep-ing a class based on its package name/hierarchy.

Is it possible to -keep based on the source file's actual path?

Example:

java/com/a/b/c/Class.java contains package com.a.b.c.Class tests/com/a/b/c/ClassTest.java contains package com.a.b.c.ClassTest

There may be a large number of "*Test" classes and I want to Proguard -keep everything under tests/* for testing purposes. It should not keep any classes which happen to match "*Test" outside of the tests/* directory.

It doesn't seem like this would be possible with package matching since it has the same package as those classes under java/*

arcyqwerty
  • 10,325
  • 4
  • 47
  • 84

1 Answers1

1

No, this is not possible. ProGuard does not consider the file path when applying rules.

You could use annotations for your test classes, e.g.

@TestClass
public class MyTest {
   ...
}

and then add a configuration like this:

-keep @TestClass class * { *; } 
T. Neidhart
  • 6,060
  • 2
  • 15
  • 38