mirror of
https://github.com/tadfisher/gradle2nix.git
synced 2026-01-12 07:50:53 -05:00
Update CLI interface
This commit is contained in:
71
README.org
71
README.org
@@ -51,7 +51,7 @@ This tool is useful for both development and packaging. You can use
|
||||
|
||||
** Installation
|
||||
|
||||
A [[./default.nix][Nix expression]] (generated by =gradle2nix= itself) is provided for
|
||||
A [[./gradle.nix][Nix expression]] (generated by =gradle2nix= itself) is provided for
|
||||
convenience. The following expression will fetch and build the latest
|
||||
version of this package:
|
||||
|
||||
@@ -60,7 +60,7 @@ import (fetchTarball "https://github.com/tadfisher/gradle2nix/archive/master.tar
|
||||
#+end_src
|
||||
|
||||
If this expression is in, say, =gradle2nix.nix=, =gradle2nix= can be
|
||||
built and placed in =.//result= with the following:
|
||||
built and placed in =./result= with the following:
|
||||
|
||||
#+begin_example
|
||||
nix build -f gradle2nix.nix
|
||||
@@ -93,36 +93,49 @@ nix run github:tadfisher/gradle2nix -- --help
|
||||
** Usage
|
||||
|
||||
#+begin_example
|
||||
Usage: gradle2nix [OPTIONS] [PROJECT-DIR]
|
||||
Usage: gradle2nix [<options>] [<args>]...
|
||||
|
||||
Options:
|
||||
-g, --gradle-version VERSION Use a specific Gradle version
|
||||
-a, --gradle-args ARGS Extra arguments to pass to Gradle
|
||||
-c, --configuration NAME Add a configuration to resolve (default:
|
||||
all configurations)
|
||||
-i, --include DIR Add an additional project to include
|
||||
-p, --project PATH Only resolve these subproject paths, e.g.
|
||||
':', or ':sub:project' (default: all
|
||||
projects)
|
||||
-o, --out-dir DIR Path to write generated files (default:
|
||||
PROJECT-DIR)
|
||||
-e, --env FILENAME Prefix for environment files (.json and
|
||||
.nix) (default: gradle-env)
|
||||
-b, --build-src / -nb, --no-build-src
|
||||
Include buildSrc project (default: true)
|
||||
-q, --quiet Disable logging
|
||||
-h, --help Show this message and exit
|
||||
-t, --tasks=<tasks> Gradle tasks to run
|
||||
-p, --project=<project-dir> Path to the project root (default: Current directory)
|
||||
-o, --out-dir=<dir> Path to write generated files (default: <project>)
|
||||
-l, --lock-file=<filename> Name of the generated lock file (default: gradle.lock)
|
||||
-n, --nix-file=<filename> Name of the generated Nix file (default: gradle.nix)
|
||||
-g, --gradle-version=<version> Use a specific Gradle version
|
||||
-j, --gradle-jdk=<dir> JDK home directory to use for launching Gradle (default: JAVA_HOME)
|
||||
--log=(debug|info|warn|error) Print messages with this priority or higher (default: error)
|
||||
--dump-events Dump Gradle event logs to the output directory
|
||||
--stacktrace Print a stack trace on error
|
||||
-h, --help Show this message and exit
|
||||
|
||||
Arguments:
|
||||
PROJECT-DIR Path to the project root (default: .)
|
||||
<args> Extra arguments to pass to Gradle
|
||||
#+end_example
|
||||
|
||||
Simply running =gradle2nix= in the root directory of a project should
|
||||
be enough for most projects. This will produce two files, by default
|
||||
called =gradle-env.json= and =gradle-env.nix=, which contain the
|
||||
called =gradle.lock= and =gradle.nix=, which contain the
|
||||
pinned dependencies for the project and a standard build expression
|
||||
which can be imported or called by other Nix expressions. An example
|
||||
of such an expression can be found in this project's [[./default.nix][default.nix]].
|
||||
of such an expression can be found in this project's [[./gradle2nix.nix][gradle2nix.nix]].
|
||||
|
||||
*** For packagers
|
||||
|
||||
If you're creating a Nix package for an existing Gradle project, you
|
||||
can reduce the number of pinned dependencies by passing one or more
|
||||
=--task= arguments. This will only pin the dependencies that were
|
||||
resolved as part of the build, instead of the default behavior where
|
||||
all possible dependencies are pinned.
|
||||
|
||||
For example, if the package produces its build output via the
|
||||
=:app:installDist= task, use the following:
|
||||
|
||||
#+begin_example
|
||||
gradle2nix -t :app:installDist
|
||||
#+end_example
|
||||
|
||||
/Note:/ This may be *required* if the build resolves configurations
|
||||
at execution time.
|
||||
|
||||
*** Specifying the Gradle version
|
||||
|
||||
@@ -136,20 +149,6 @@ Gradle installed.
|
||||
gradle2nix -g 6.1
|
||||
#+end_example
|
||||
|
||||
*** Multi-project builds
|
||||
|
||||
If you want to resolve only a subset of projects in a [[https://docs.gradle.org/current/userguide/intro_multi_project_builds.html][multi-project
|
||||
build]], add the =--project= option for each project. For example, in a
|
||||
project where you only want to build the subprojects =:app= and
|
||||
=:widget=:
|
||||
|
||||
#+begin_example
|
||||
gradle2nix -p :app -p :widget
|
||||
#+end_example
|
||||
|
||||
Any [[https://docs.gradle.org/current/userguide/declaring_dependencies.html#sub:project_dependencies][project dependencies]] will be also be included when pinning
|
||||
dependency artifacts.
|
||||
|
||||
** Contributing
|
||||
|
||||
Bug reports and feature requests are encouraged.
|
||||
|
||||
Reference in New Issue
Block a user