blob: fba8acfcedf4cfc80d243a6dbc3c220185e7be64 [file] [log] [blame]
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{namespace groovy_library}
/***/
{template .soyweb}
{call buck.page}
{param title: 'groovy_library()' /}
{param navid: 'rule_groovy_library' /}
{param prettify: true /}
{param description}
A rule that is used to define a set of Groovy files that can be compiled together.
It can also be used to cross compile a set of Groovy and Java files.
{/param}
{param content}
{call buck.rule}
{param status: 'UNFROZEN' /}
{param overview}
A <code>groovy_library()</code> rule is used to define a set of Groovy files that can be compiled
together. It can also be used to cross compile a set of Groovy and Java files. The main output of a
{sp}<code>groovy_library()</code> rule is a single JAR file containing all of the compiled class
files and resources.
{/param}
{param args}
{call buck.name_arg /}
{call buck.arg}
{param name: 'srcs' /}
{param default : '[]' /}
{param desc}
The set of files to compile for this rule.
Usually these will all end in <code>.groovy</code>, but if any of the files end in
<code>.java</code>, cross compilation using the jdk found in <code>JAVA_HOME</code> will occur.
{/param}
{/call}
{call buck.arg}
{param name: 'resources' /}
{param default : '[]' /}
{param desc}
This is the same as in {call buck.java_library /}.
{/param}
{/call}
{call buck.arg}
{param name: 'deps' /}
{param default : '[]' /}
{param desc}
Rules (usually other <code>groovy_library</code> or <code>{call buck.java_library /}</code> rules)
that are used to generate the classpath required to compile this <code>groovy_library</code>.
This is the same as in {call buck.java_library /}.
{/param}
{/call}
{call buck.arg}
{param name: 'exported_deps' /}
{param default : '[]' /}
{param desc}
Other <code>groovy_library</code> and <code>{call buck.java_library /}</code> rules that depend
on this rule will also include its <code>exported_deps</code> in their classpaths.
This is the same as in {call buck.java_library /}.
{/param}
{/call}
{call buck.arg}
{param name: 'provided_deps' /}
{param default : '[]' /}
{param desc}
This is the same as in {call buck.java_library /}.
{/param}
{/call}
{call buck.arg}
{param name: 'extra_groovyc_arguments' /}
{param default : '[]' /}
{param desc}
List of additional arguments to pass into the Groovy compiler.
{/param}
{/call}
{call buck.arg}
{param name: 'source' /}
{param default : '<global value>' /}
{param desc}
Only used during cross compilation.
This is the same as in {call buck.java_library /}.
{/param}
{/call}
{call buck.arg}
{param name: 'target' /}
{param default : '<global value>' /}
{param desc}
Only used during cross compilation.
This is the same as in {call buck.java_library /}.
{/param}
{/call}
{call buck.arg}
{param name: 'java_version' /}
{param default: '<global value>' /}
{param desc}
Only used during cross compilation.
This is the same as in {call buck.java_library /}.
{/param}
{/call}
{call buck.arg}
{param name: 'extra_arguments' /}
{param default : '[]' /}
{param desc}
Only used during cross compilation.
This is the same as in {call buck.java_library /}.
{/param}
{/call}
{/param} // close args
{param examples}
{literal}<pre class="prettyprint lang-py">
# A rule that compiles a single .groovy file.
groovy_library(
name = 'example',
srcs = ['MySourceFile.groovy'],
)
</pre>
<pre class="prettyprint lang-py">
# A rule that compiles all of the .groovy files under the directory in
# which the rule is defined using glob()
groovy_library(
name = 'groovy-only',
srcs = glob(['**/*.groovy']),
)
</pre>
<pre class="prettyprint lang-py">
# A rule that cross compiles all of the .groovy and .java files under
# the directory in which the rule is defined, failing if compiling the
# java files generates any compiler warnings
groovy_library(
name = 'cross-compilation',
srcs = glob(['**/*.groovy', '**/*.java']),
java_version = 8,
extra_arguments = [
'-Werror',
],
)
</pre>{/literal}
{/param}
{/call} // close buck.rule
{/param}
{/call}
{/template}