Skip to content

Commit

Permalink
split groovyc Ant task doco into separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
paulk-asert committed Mar 21, 2020
1 parent 8df76a2 commit abade84
Show file tree
Hide file tree
Showing 2 changed files with 207 additions and 187 deletions.
190 changes: 3 additions & 187 deletions src/spec/doc/tools-groovyc.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -61,192 +61,8 @@ a number of command line switches:
== Ant task
[[ThegroovycAntTask-groovyc]]
`<groovyc>`
~~~~~~~~~~~
[[ThegroovycAntTask-Description]]
Description
^^^^^^^^^^^
Compiles Groovy source files and, if joint compilation option is used, Java source files.
[[ThegroovycAntTask-Requiredtaskdef]]
Required taskdef
^^^^^^^^^^^^^^^^
Assuming the groovy jars are in _groovy.libs_, you will need to declare this task
at some point in the `build.xml` prior to the `groovyc` task being invoked.
[source,xml]
-----------------------------------------------------------------------
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc">
<classpath>
<fileset file="${groovy.libs}/groovy-ant-VERSION.jar"/>
<fileset file="${groovy.libs}/groovy-VERSION.jar"/>
</classpath>
</taskdef>
-----------------------------------------------------------------------
[[ThegroovycAntTask-groovycAttributes]]
<groovyc> Attributes
^^^^^^^^^^^^^^^^^^^^
[cols="<,<,<",options="header,footer"]
|=======================================================================
|Attribute |Description |Required
|srcdir |Location of the Groovy (and possibly Java) source files. |Yes
|destdir |Location to store the class files. |Yes
|classpath |The classpath to use. |No
|classpathref |The classpath to use given as a path references. |No
|sourcepath |The sourcepath to use. |No
|sourcepathref |The sourcepath to use given as a path reference. |No
|encoding |Encoding of source files. |No
|verbose |Asks the compiler for verbose output; defaults to no. |No
|includeAntRuntime |Whether to include the Ant run-time libraries in the
classpath; defaults to yes. |No
|includeJavaRuntime |Whether to include the default run-time libraries
from the executing VM in the classpath; defaults to no. |No
|includeDestClasses |This property controls whether to include the destination
classes directory in the classpath given to the compiler. The default value is "true". |No
|fork |Whether to execute groovyc using a spawned instance of the JVM;
defaults to no. |No
|memoryInitialSize |The initial size of the memory for the underlying
VM, if using fork mode; ignored otherwise. Defaults to the standard VM
memory setting. (Examples: 83886080, 81920k, or 80m) |No
|memoryMaximumSize |The maximum size of the memory for the underlying
VM, if using fork mode; ignored otherwise. Defaults to the standard VM
memory setting. (Examples: 83886080, 81920k, or 80m) |No
|failonerror |Indicates whether compilation errors will fail the build;
defaults to true. |No
|proceed |Inverse alias for _failonerror_. |No
|listfiles |Indicates whether the source files to be compiled will be
listed; defaults to no. |No
|stacktrace |if true each compile error message will contain a
stacktrace |No
|indy |Enable compilation with the ``invoke dynamic'' support when using
Groovy 2.0 and beyond and running on JDK 7 |No
|scriptBaseClass |Sets the base class for Groovy scripts |No
|stubdir |Set the stub directory into which the Java source stub files should be generated.
The directory need not exist and will not be deleted automatically - though its contents
will be cleared unless 'keepStubs' is true. Ignored when forked. |No
|keepStubs |Set the keepStubs flag. Defaults to false. Set to true for debugging.
Ignored when forked. |No
|forceLookupUnnamedFiles |The Groovyc Ant task is frequently used in the context of a build system
that knows the complete list of source files to be compiled. In such a
context, it is wasteful for the Groovy compiler to go searching the
classpath when looking for source files and hence by default the
Groovyc Ant task calls the compiler in a special mode with such searching
turned off. If you wish the compiler to search for source files then
you need to set this flag to true. Defaults to false. |No
|configscript |Set the configuration file used to customize the compilation configuration. |No
|parameters |Generates metadata for reflection on method parameter names on JDK 8 and above.
Defaults to false. |No
|previewFeatures |Enables the JEP preview features on JDK 12 and above.
Defaults to false. |No
|targetBytecode |Sets the bytecode compatibility level. |No
|javahome |Sets the `java.home` value to use, default is the current JDK's home. |No
|executable |Sets the name of the java executable to use when invoking the compiler in forked mode,
ignored otherwise. |No
|scriptExtension |Set the extension to use when searching for Groovy source files.
Accepts extensions in the form *.groovy, .groovy or groovy. |No
|updatedProperty |The property to set on compilation success. This property will not be set if
the compilation fails, or if there are no files to compile. |No
|errorProperty |The property to set on compilation failure. This property will be set if
the compilation fails. |No
|=======================================================================
*Example:*
[source,xml]
-----------------------------------------------------------------------
<path id="classpath.main">
<fileset dir="${groovy.libs}" includes="*.jar" excludes="groovy-ant-*.jar"/>
...
</path>
<groovyc srcdir="${dir.sources}" destdir="${dir.classes}" classpathref="classpath.main"
fork="true" includeantruntime="false" configscript="config.groovy" targetBytecode="1.8"/>
-----------------------------------------------------------------------
[[ThegroovycAntTask-groovycNestedElements]]
<groovyc> Nested Elements
^^^^^^^^^^^^^^^^^^^^^^^^^
[cols="<,<,<,<",options="header,footer"]
|==========================================================
|element |kind |Required |Replaces Attribute
|src |a path structure |Yes (unless srcdir is used) |srcdir
|classpath |a path structure |No |classpath or classpathref
|javac |javac task |No |N/A
|==========================================================
*Notes:*
* For path structures see for example
http://ant.apache.org/manual/using.html#path
* For usages of the `javac` task see
https://ant.apache.org/manual/Tasks/javac.html
* The nested `javac` task behaves more or less as documented for the top-level
`javac` task. `srcdir`, `destdir`, `classpath`, `encoding` and `parameters`
for the nested `javac` task are taken from the enclosing `groovyc` task. If
these attributes are specified then they are added, they do not replace. In fact,
you should not attempt to overwrite the destination. Other attributes and nested
elements are unaffected, for example `fork`, `memoryMaximumSize`, etc. may be
used freely.
[[ThegroovycAntTask-JointCompilation]]
Joint Compilation
^^^^^^^^^^^^^^^^^
Joint compilation is enabled by using an embedded `javac` element, as shown in the following example:
[source,xml]
-----------------------------------------------------------------------
<groovyc srcdir="${testSourceDirectory}" destdir="${testClassesDirectory}" targetBytecode="1.8">
<classpath>
<pathelement path="${mainClassesDirectory}"/>
<pathelement path="${testClassesDirectory}"/>
<path refid="testPath"/>
</classpath>
<javac debug="true" source="1.8" target="1.8" />
</groovyc>
-----------------------------------------------------------------------
More details about joint compilation can be found in the <<section-jointcompilation,joint compilation>> section.
See the <<groovyc-ant-task.adoc#ThegroovycAntTask-groovyc,groovyc Ant task>> documentation.
It allows the Groovy compiler to be invoked from http://ant.apache.org/[Apache Ant].
[[Gant]]
== Gant
Expand Down Expand Up @@ -433,7 +249,7 @@ for the Ant task.
It is important to know that if you don't enable joint compilation and try to compile
Java source files with the Groovy compiler, the Java source files will be compiled as
if they were Groovy sources. In some situations, this might work since most of the Java
syntax is compatible with Groovy, but semantics would be different.
syntax is compatible with Groovy, but there are a number of places where semantics could be different.
[[section-android]]
== Android support
Expand Down
Loading

0 comments on commit abade84

Please sign in to comment.