Pregunta

I am porting a project build from ANT to Gradle. Everything has been done exception the obfuscation part, the obfuscation task in build.xml is as:

<taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="${ant.yguard.path}"/>

<target name="obfuscate-no-test" depends="no-test-jar">
  <yguard>
    <inoutpairs>
      <fileset dir="${dir.dist}">
        <include name="**/*.jar"/>
        <exclude name="**/*_obf.jar"/>
        <exclude name="**/*-doc.jar"/>
      </fileset>
    </inoutpairs>

    <externalclasses>
      <path refid="path.lib.biz"/>
      <path refid="path.lib.share"/>
      <path refid="path.lib.web"/>
    </externalclasses>

    <rename logfile="${rename.log}">
      <property name="naming-scheme" value="best"/>

      <keep>
        <class classes="none" fields="none" methods="none">
          <patternset>
            <include name="com.payeshgaran.framework.internal.**.*"/>
          </patternset>
        </class>

        <class classes="public" fields="protected" methods="protected">
          <patternset>
            <include name="com.payeshgaran.framework.**.*"/>
            <exclude name="com.payeshgaran.framework.internal.**.*"/>
          </patternset>
        </class>
      </keep>

      <adjust replacecontent="true">
        <include name="META-INF/*.tld"/>
      </adjust>
    </rename>
  </yguard>
</target>

For porting this to gradle I did this:

task obfuscate(dependsOn: [":ext:build", ":biz:build", ":web:build"]) {
    ant.taskdef(name: "yguard",
            classname: "com.yworks.yguard.YGuardTask",
            classpath: "$rootProject.projectDir/lib/ant/yguard-2.5.1.jar")

    ant.yguard() {
        inoutpairs {
            fileset(dir: distFolder) {
                include(name: "**/*.jar")
                exclude(name: "**/*_obf.jar")
                exclude(name: "**/*-doc.jar")
            }
        }

        externalClasses {
            fileset(dir: libsFolder) {
                include(name: '**/*.jar')
            }
        }

        rename(logFile: "$distFolder/rename.log") {
            property(name: "naming-scheme", value: "best")

            keep() {

            }

            adjust(replaceContent: "true") {
                include(name: "META-INF/*.tld")
            }
        }
    }
}

Well the things go fine except I can not define a class objects (inside the keep object) cause its a reserved word in groovy.

What can I do for that?

¿Fue útil?

Solución

Try:

    keep {
        'class'( classes:"none", fields:"none", methods:"none" ) {
            ...
        }
    }
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top