Reputation: 12338
We are trying to get a new project up and running in grails 3.
We created a project thusly:
grails create-app plugin-domain --profile=plugin
Now following the documentation here, in section 4.1 creating a domain class it says to do this:
./grailsw create-domain-class Vehicle
When we do this with our domain class, we get:
"could not determine grails wrapper version due to missing gradle.properties"
We dont know what grailsw is (we are used to using "grails" with 2.5), and we don't know what gradle.properties should contain, nor why it was not built by grails automatically.
Obviously this is a plugin (designed to hold the domain objects and services only), not an app, so we cant run it with run-app directly.
Interestingly, we just tried the old way, using "grails create-domain-class xxx" and it worked, so the question is why doesnt the recommended grailsw command work, and how do we fix it?
Doing some investigation, grailsw is some sort of wrapper to not require grails to be installed. Anyone running things like create-domain-class will have grails installed, so we don't quite see the point of it? It will result in grails being installed at least twice, once the proper way, and a second time by the wrapper system. What is the use case for the wrapper? In production you would drop a war on tomcat or similar, in dev all devs will have grails installed anyway. Can we ignore grailsw, or do we need to fix it?
Upvotes: 0
Views: 429
Reputation: 12228
why doesnt the recommended grailsw command work, and how do we fix it
It doesn't work because the gradle.properties
file is missing. Why it is missing, I can't know because it gets created for me when I run the command.
Jamess-MacBook-Pro:demo jameskleeh$ grails create-app foo -profile plugin
| Application created at /Users/jameskleeh/demo/foo
Jamess-MacBook-Pro:demo jameskleeh$ cd foo
Jamess-MacBook-Pro:foo jameskleeh$ cat gradle.properties
grailsVersion=3.2.9
gormVersion=6.0.10.RELEASE
gradleWrapperVersion=3.4.1
Anyone running things like create-domain-class will have grails installed, so we don't quite see the point of it?
Perhaps you can make that assumption with your team, however that doesn't apply to everyone.
It will result in grails being installed at least twice, once the proper way, and a second time by the wrapper system.
That is incorrect. Grails will not be "installed" by the wrapper in the same way you would via sdkman or simply downloading it. It will download Grails to your maven cache if it doesn't already exist. Grails will be in your maven cache the first time you resolve the dependencies for that version whether or not you use the wrapper, so it adds nothing to your system that wouldn't already be there.
What is the use case for the wrapper?
The use case for the wrapper is so that developers don't have to manage Grails versions for existing projects. You don't have to switch between installed versions when working on multiple projects that may have different versions. If you always use the wrapper, you will always be using the correct Grails version. In addition, developers that may not have Grails installed at all don't need to install Grails in order to start working on a project.
It is also not necessary to have Grails installed on your system to create projects. With the start.grails.org site you can download freshly created projects with either a click of a button or a simple curl command. You can then use the Grails wrapper with those projects and never have to have Grails installed at all.
Upvotes: 1
Reputation: 3016
grailsw required if you haven't installed gradle. You can delete it and use gradle or you can create classes manually.
gradle.properties is for build constants.
create file gradle.properties in your app root dir with folowing content:
grailsVersion=3.2.11
gormVersion=6.0.12.RELEASE
grailsWrapperVersion=3.4.1
change values to your project versions and try ./grailsw create-domain-class Vehicle again
Upvotes: 1