Skip to content

Commit

Permalink
Document new CLI command "create-job" (#887)
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermocalvo authored Feb 2, 2024
1 parent 2686eb4 commit a11b26a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/en/ref/Command Line/create-job.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
== create-job

=== Purpose


The `create-job` command creates a new scheduled job for the given base name.


=== Examples

----
grails create-job Scheduled
grails create-job com.example.Scheduled
----

=== Description


Creates a new Quartz scheduled job with an empty 'execute' method. The argument is required.

The name of the job can include a Java package, such as `com.example` in the last example above, but if one is not provided a default is used. So the first example will create the file `grails-app/jobs/<appname>/ScheduledJob.groovy` whereas the second one will create `grails-app/jobs/com/example/ScheduledJob.groovy`. Note that the first letter of the job name is always upper-cased when determining the class name.

If you want the command to default to a different package for jobs, provide a value for `grails.project.groupId` in the link:{guidePath}/conf.html#config[runtime configuration].

Note that this command is just for convenience and you can also create jobs in your favourite text editor or IDE if you choose.

Usage:
[source,groovy]
----
grails create-job <<name>>
----

3 comments on commit a11b26a

@matrei
Copy link
Contributor

@matrei matrei commented on a11b26a Mar 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guillermocalvo Do you remember what the reason was for adding this page to the core documentation?
I don't think create-job is a valid command in the Grails CLI.

I might be missing something but to my knowledge the create-job command is part of the grails-quartz plugin.
Also this command (in grails-quartz) has not yet been upgraded to a GrailsApplicationCommand (to make it work with the new CLI in Grails 6).
And once it has been upgraded, and the grails-quartz plugin is added to a project, it can be invoked with the gradle runCommand task:

$ ./gradlew runCommand -Pargs="create-job Scheduled"

@guillermocalvo
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you remember what the reason was for adding this page to the core documentation?

@matrei Yes, we added it back to the new CLI recently.

@matrei
Copy link
Contributor

@matrei matrei commented on a11b26a Mar 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha 👍 Thanks!

Please sign in to comment.