Search code examples
proguardtycho

Tycho: generate proguard/obfuscated feature


I have a working tycho build that does:

  • build a set of bundles, for each of them:
    • build a regular bundle.jar
    • build/attach a source jar (using the tycho-source-plugin)
    • build an obfuscated jar (using proguard-maven-plugin (com.github.wvengen))
  • build a number of features, for each of them:
    • build a regular feature.jar
    • build a source-feature.jar (using tycho-extras:tycho-source-feature)
  • build a p2-repository (category.xml references the features and the source-features)
  • build/materialize a product (product file references the features)

I didn't find a way yet to create features that use the obfuscated bundle-jars. With the tycho-source-feature-plugin it is easy to create the corresponding source-features.jars from the source-bundle.jars. Is there an easy possibility to create features that use the obfuscated bundle.jars?

Visual explanation:
My workspace looks somewhat like this:

com.company.moduleA/
   + /target/com.company.moduleA-1.20.2.jar
   + /target/com.company.moduleA-1.20.2-obfuscated.jar
   + /target/com.company.moduleA-1.20.2-sources.jar
com.company.moduleB/
   + /target/com.company.moduleB-1.20.2.jar
   + /target/com.company.moduleB-1.20.2-obfuscated.jar
   + /target/com.company.moduleB-1.20.2-sources.jar
com.company.featureX/
   + target/com.company.featureX-1.20.2.jar
   + target/com.company.featureX-1.20.2-sources-feature.jar

What I'm missing is a way to generate this jar:
+ target/com.company.featureX-1.20.2-obfuscated-feature.jar

Edit:
while analyzing my problem I found that the *obfuscated.jars (plugin) are actually deployed, but not listed in the modules metadata (p2artifacts.xml) unlike the *sources.jars which are listed in p2artifacts.xml.
I assume this is a problem with the proguard-maven-plugin or with the order/phases I configured the corresponding tycho-plugins.
Any hints are welcome.


Solution

  • After many different configuration attempts I ditched the idea of building obfuscated AND non-obfuscated plugins, features and products in just one pass. I didn't find anyone or any project doing that.

    Instead I changed my tycho/maven configuration to obfuscate everything or nothing, using the same artifact-ids and names, but different repositories for deployments (i.e. there's an "obfuscated" repository and a "non-obfuscated" repository). Switching is done via maven profiles and a command line flag.