<obfuscate>

Description

Runs PreEmptive Protection - DashO using either an existing project file, a project file defined in the buildfile, or an existing project file augmented by the buildfile.

This task can be used in one of three different manners:

NOTE: Configuring and augmenting DashO project files via Ant has been deprecated and does not support configuring the latest features. See Migrating Ant-based Configuration to DashO in the User Guide.

The <obfuscate> task supports all DashO project file elements except for <dasho>, <propertylist>, and <property>. The <obfuscate> tag takes the place of <dasho> in the project file structure. See the Project File Reference in the DashO User Guide.

Properties used in project elements in the buildfile are expanded by Ant, not by DashO.

Multiple warnings may be emitted during the build, but the process will stop immediately with an exit code of 1 if an error is encountered.


Task Specific Parameters

Attribute Description Required
project The name of an existing DashO project file to be executed or augmented. No
force If true, build continues when reflection is detected. No; defaults to false.
androidDexDir The name of the directory where the obfuscated jar and support jars should be copied to. Used in android development. No

General Parameters

Attribute Description Required
append If true the file specified by output and error will have output appended rather than being overwritten. No; defaults to false
dashohome The location of DashOPro.jar. See Setting DashO Home for details. No
dir The directory where the process will be invoked. No; defaults to the basedir of the buildfile.
error Name of a file to which to write the error output. (Error messages print to the error output) No
errorProperty Name of a property in which to store the standard error output. (Error messages print to the standard error output) No
failonerror If true stops the buildprocess if the process exits with a returncode other than 0. No; defaults to true
if Execute only if the named property has been set. No
jvm The command used to invoke the Java Virtual Machine. The command is resolved by java.lang.Runtime.exec(). No; default is java.
maxmemory Max amount of memory to allocate to the process. No
newenvironment If true the old environment settings will not be propogated when new environment variables are specified. No; defaults to false.
output Name of a file to which to write the output of the process. No
outputProperty Name of a property in which to store the standard output. No
printstacktraces If true stack traces will be printed for errors. No; defaults to false.
quiet If true output will be terse. No; defaults to false.
resultproperty The property name which will contain the return code from the task. No
timeout Stop the process if it doesn't finish within the specified time in milliseconds. No
unless Execute only if the named property has not been set. No
verbose If true additional information will be printed. No; defaults to false.
deleteTempProject If false the created .dox file will not be deleted when DashO finishes. (Set verbose=true to show the file location) No; defaults to true.

Parameters specified as nested elements

NOTE: Ant-based .dox configuration has been deprecated. This includes most of these nested elements.

global (Deprecated)

The <global> element's use is as described in the <global> Section of the DashO User Guide. In addition to the elements described in the user's guide the following nested elements are added:

<makepublic value="..."/>

Sets make public to true, false, or auto. See Makepublic and Nomakepublic Global Options in the DashO User Guide.

<leavedebugginginfo value="true/false"/>

Sets the leavedebugginginfo global option (deprecated).

<fornamedetection value="true/false"/>

Sets the fornamedetection global option.

<renameforname value="true/false"/>

Sets the renameforname global option.

<ignorenotfoundclasses value="true/false"/>

Sets the ignorenotfoundclasses global option.

<ignorebrokencalls value="true/false"/>

Sets the ignorebrokencalls option.

<bypassdasho value="true/false"/>

Sets the bypassdasho global option.

inputpath (Deprecated)

The <inputpath> element's use is as described in the <inputpath> Section of the DashO User Guide. In addition to the elements described in the user's guide the following element has been added:

<fileset>

The <fileset> element adds jars or zip files to the inputpath. See FileSet for details.

classpath (Deprecated)

The <classpath> element's use is as described in the <classpath> Section of the DashO User Guide. In addition to the elements described in the user's guide the following element has been added:

<fileset>

The <fileset> element adds jars or zip files to the classpath. See FileSet for details.

entrypoints (Deprecated)

The <entrypoints> element's use is as described in the <entrypoints> Section of the DashO User Guide.

Note that attributes with dashes such as "rename-class" and "rename-members" cannot be used in ant. The same attributes are supported but without the dash. ("renameclass" and "renamemembers")

renaming (Deprecated)

The <renaming> element's use is as described in the <renaming> Section of the DashO User Guide. In addition to the elements described in the user's guide the following attributes have been added:

Attribute Description Required
report Equivalent to the nested elements <mapping>/<mapreport>/<file path="..."/>. No
input Equivalent to the nested elements <mapping>/<mapinput>/<file path="..."/>. No
output Equivalent to the nested elements <mapping>/<mapoutput>/<file path="..."/>. No
overwrite Equivalent to the nested elements <mapping>/<mapoutput overwrite="...">. No
overloadinduction If true uses Overload Induction™ rather than simple renaming. No; defaults to true

Likewise the following nested element has been modified:

<mapping report="..." input="..." output="..."/>

The report, input, and output attributes have been added.

Attribute Description Required
report Equivalent to the nested elements <mapreport>/<file path="..."/>. No
input Equivalent to the nested elements <mapinput>/<file path="..."/>. No
output Equivalent to the nested elements <mapoutput>/<file path="..."/>. No
overwrite Equivalent to the nested elements <mapping>/<mapoutput overwrite="...">. No

removal (Deprecated)

The <removal> element's use is as described in the <removal> Section of the DashO User Guide.

methodCallRemoval (Deprecated)

The <methodCallRemoval> element's use is as described in the <methodCallRemoval> Section of the DashO User Guide.

optimization (Deprecated)

The <optimization> element's use is as described in the <optimization> Section of the DashO User Guide.

output (Deprecated)

The <output> element's use is as described in the <output> Section of the DashO User Guide. In addition to the elements described in the user's guide the following attributes have been added:

Attribute Description Required
dir Equivalent to the nested element <dir path="..."/>. No
jar Equivalent to the nested element <jar path="..."/>. No
manifest Equivalent to the nested element <jar manifest="..."/>. No
apk Equivalent to the nested element <apk path="..."/>. No

report (Deprecated)

The <report> element's use is as described in the <report> Section of the DashO User Guide.

controlflow (Deprecated)

The <controlflow> element's use is as described in the <controlflow> Section of the DashO User Guide.

stringencrypt (Deprecated)

The <stringencrypt> element's use is as described in the <stringencrypt> Section of the DashO User Guide.

premark (Deprecated)

The <premark> element's use is as described in the <premark> Section of the DashO User Guide. In addition to the elements described in the user's guide the following attributes have been added:

Attribute Description Required
passphrase Equivalent to the nested element <passphrase>...</passphrase>. No
watermark Equivalent to the nested element <watermark>...</watermark>. No
encoding Equivalent to the nested element <encoding name="..."/>. No

Likewise the following nested elements have been modified:

<passphrase value="..."/>

The value attribute has been added. It is equivalent to <passphrase>...</passphrase>.

<watermark value="..."/>

The value attribute has been added. It is equivalent to <watermark>...</watermark>.

constantpooltag (Deprecated)

The <constantpooltag> element's use is as described in the <constantpooltag> Section of the DashO User Guide. In addition to the elements described in the user's guide the following attribute has been added:

Attribute Description Required
value Equivalent to <constantpooltag>...</constantpooltag>. No

instrumentation (Deprecated)

The <instrumentation> element's use is as described in the <instrumentation> Section of the DashO User's Guide.

Note that the nested <property> tag is different from Ant's : it only supports the name and value attributes.

includenonclassfiles (Deprecated)

The <includenonclassfiles> element's use is as described in the <includenonclassfiles> Section of the DashO User Guide.

preverifier (Deprecated)

The <preverifier> element's use is as described in the <preeverifier> Section of the DashO User Guide. In addition to the elements described in the user's guide the following attribute has been added:

Attribute Description Required
path Equivalent to <preverifier>...</preverifier>. No

arg and jvmarg

Use nested <arg> and <jvmarg> elements to specify arguments to DashO and the JVM respectively. See Command line arguments.

sysproperty

Use nested <sysproperty> elements to specify system properties required by DashO. This tag uses the same syntax as <env>: see the <exec> task for details.

env

Use nested <env> elements to add or replace environment variables passed to the process. See the <exec> task for details.

<includelist> and <excludelist> Elements (Deprecated)

The project file's <includelist> and <excludelist> elements contain an additional attribute:

Attribute Description Required
replace If true the nested <classes> elements replace the existing values in the project file. If false the elements augment existing values in the project file. No; defaults to false.

The replace attribute can be used when the buildfile is used to augment an existing project file.

Examples

<obfuscate project="samples/simpleapp/project.dox">
    <sysproperty key="lib_dir" value="new_libs"/>
    <sysproperty key="collections_ver" value="2.1"/>
</obfuscate>

This task invokes a pre-existing project file. <sysproperty> elements are used to set path information and library version information that is used inside the project file.

<property name="ver.short" value="6.5"/>
<property name="ver.type" value="BETA"/>

<tstamp>
    <format property="rel.date" pattern="yyyy-MM-dd"/>
</tstamp>

<obfuscate project="project.dox">
    <output jar="logicfoundry_${rel.date}_${ver.short}_${ver.type}.jar"/>
</obfuscate>

This example shows how values in the buildfile override those in the project file. The project file is originally configured to send its output to a directory, but the buildfile settings change that to a jar. The properties referenced in the path attribute are defined in and expanded by Ant, not DashO.

<property name="projectname" value="contrib"/>

<obfuscate force="true" dir="${user.home}">
    <global>
        <ignorenotfoundclasses value="true"/>
        <fornamedetection value="true"/>
    </global>
    <classpath>
        <fileset dir="${ant.home}/lib">
            <include name="*.jar"/>
            <exclude name="ant-contrib-*.jar"/>
        </fileset>
    </classpath>
    <entrypoints>
        <quickjars dir="${ant.home}/lib">
            <include name="ant-contrib-*.jar"/>
        </quickjars>
    </entrypoints>
    <report file="${projectname}-report.txt"/>
    <output jar="${projectname}.jar"/>
    <renaming option="on" report="${projectname}-mapreport.txt">
        <excludelist>
            <classes name="net.sf.antcontrib.**"/>
        </excludelist>
    </renaming>
</obfuscate>

This example shows an entire project file defined in the buildfile - in this case a quick jar project. It illustrates the use of extensions to the project file syntax including the use of <fileset>s and using properties defined by Ant. Note that use of the dir attribute to give the execution of DashO a location other than the location of the buildfile.