I have installed Grails 3 by downloading and unloading the zip on CentOS 6.2.
grails --version shows
| Grails Version: 3.1.10
| Groovy Version: 2.4.7
| JVM Version: 1.7.0_111
grails list-plugins shows
Usage:
create-app [NAME] --profile=web
create-plugin [NAME] --profile=web-plugin
| Available Profiles
--------------------
* angular - A profile for creating applications using AngularJS
* rest-api - Profile for REST API applications
* base - The base profile extended by other profiles
* plugin - Profile for plugins designed to work across all profiles
* web - Profile for Web applications
* web-plugin - Profile for Plugins designed for Web applications
Type 'grails help' or 'grails -h' for more information.
Which mostly the same as grails list-profiles.
I thought list-plugins listed all of the plugins that were available for Grails in a central repository.
Is this a bug in Grails 3.1.10? (Which is the latest version for download and the version that sdkman tries to install as well).
Most Grails commands have to be run inside an existing application or plugin, with create-app and create-plugin being exceptions, so that's what the usage message is telling you. Since list-plugins doesn't work outside of an existing app/plugin (I'm not sure why tbh) you're seeing this low-information response.
You can see all of the available Grails 3 plugins here.
Related
I'm using Grails 3.3.6 (via sdkman) and when I try to use the dbmigration plugin to generate chagelog files it just doesn't do anything and can't figure out how to get more informative output out of the plugin. This is what's on my build.gradle:
buildscript {
...
dependencies {
...
classpath 'org.grails.plugins:database-migration:3.0.0'
...
runtime "mysql:mysql-connector-java:5.1.46"
}
}
This isn't a new project, I cloned it from a git repo and it is successfully running locally on my machine and several db migrations have been performed before (not on my machine, but the migrations folder has dozens of previous migrations, some generated with the plugin it seems). For some reason though, using the db migration plugin from the CLI isn't really working for me even though the project is successfully running locally. This is the output I get after modifying a model class:
[user#machine project-root]$ grails dbm-gorm-diff add-field-to-model.groovy --add
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/home/user/.sdkman/candidates/grails/3.3.6/lib/org.codehaus.groovy/groovy/jars/groovy-2.4.15.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Usage:
create-app [NAME] --profile=web
create-plugin [NAME] --profile=web-plugin
| Available Profiles
--------------------
* angular - A profile for creating Grails applications with Angular 5+
* rest-api - Profile for REST API applications
* base - The base profile extended by other profiles
* angularjs - A profile for creating applications using AngularJS
* plugin - Profile for plugins designed to work across all profiles
* profile - A profile for creating new Grails profiles
* react - A profile for creating Grails applications with a React frontend
* react-webpack - A profile for creating Grails applications with a React frontend using Webpack
* webpack - A profile for creating applications with node-based frontends using webpack 2
* web - Profile for Web applications
* rest-api-plugin - Profile for REST API plugins
* vue - A profile for creating Grails applications with a Vue.js frontend
* web-jboss7 - A Profile for Creating a JBoss 7.1 EAP Project
* web-plugin - Profile for Plugins designed for Web applications
Type 'grails help' or 'grails -h' for more information.
From what I've read online that warning is normal for certain versions of grails and/or groovy depending on your jdk version. The point is that the migration groovy script isn't generated as expected. I used variations grails envname dbm-gorm-diff --add add-field-to-model.groovy
I installed Grails 3.3.1 using SDKMAN!. Now I tried to list the available profiles using
grails list-profiles
and got the following error:
| Error Error occurred running Grails CLI: Could not find artifact org.grails.profiles:angular:jar:4.0.1 in grailsCentral (https://repo.grails.org/grails/core) (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.grails.profiles:angular:jar:4.0.1 in grailsCentral (https://repo.grails.org/grails/core)
at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:39)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:581)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:249)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:367)
at org.springframework.boot.cli.compiler.grape.AetherGrapeEngine.resolve(AetherGrapeEngine.java:319)
at org.springframework.boot.cli.compiler.grape.AetherGrapeEngine.grab(AetherGrapeEngine.java:129)
at org.springframework.boot.cli.compiler.grape.AetherGrapeEngine.grab(AetherGrapeEngine.java:121)
at org.grails.cli.profile.repository.MavenProfileRepository.getAllProfiles(MavenProfileRepository.groovy:134)
at org.grails.cli.profile.commands.ListProfilesCommand.handle(ListProfilesCommand.groovy:43)
at org.grails.cli.GrailsCli.executeCommandWithArgumentValidation(GrailsCli.groovy:287)
at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:263)
at org.grails.cli.GrailsCli.main(GrailsCli.groovy:159)
| Error Error occurred running Grails CLI: Could not find artifact org.grails.profiles:angular:jar:4.0.1 in grailsCentral (https://repo.grails.org/grails/core)
Do I have to change the repo?
Turns out the grails repo https://repo.grails.org/grails/core was down. When up, it returns list of the available artifacts and the above command should return a list of all available profiles as follows:
grails list-profiles Resolving dependencies.. | Available Profiles
angular - A profile for creating Grails applications with Angular 2
rest-api - Profile for REST API applications
base - The base profile extended by other profiles
angularjs - A profile for creating applications using AngularJS
plugin - Profile for plugins designed to work across all profiles
profile - A profile for creating new Grails profiles
react - A profile for creating Grails applications with a React frontend
rest-api-plugin - Profile for REST API plugins
web - Profile for Web applications
web-jboss7 - A Profile for Creating a JBoss 7.1 EAP Project
web-plugin - Profile for Plugins designed for Web applications
webpack - A profile for creating applications with node-based frontends using webpack 2
I am doing sample application from git-hub [book-flow] I created domain classes,controller classes and also views of the book -flow application, then I executed the application in development mode but the application is terminated automatically in console it showed
Loading Grails 2.1.1
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application.....
| Compiling 2 source files.....
| Running Grails application
I unable to find where is the problem and I want to know that where can I find the applications on grails other than github.
Srujan
I thought I give you more of an insight into grails now that I have a little time on my hands...
most of the grails should remember one day not too long ago we were also in the same boat and had no idea where to start...
I would suggest getting hold of a good book such as definitive guide to grails 2 and reading/experimenting....
To create a basic app with one object :
The following is using grails command line - so refer to No console output available on linux when executing grails/groovy for expoerting out java grails - I Guess you are windows so same but on windows environment...
$ grails create-app grails-example
$ cd grails-example
$ grails create-domain-class Books
$ vi grails-app/domain/grails/example/Books.groovy
cat grails-app/domain/grails/example/Books.groovy
package grails.example
class Books {
String name
static constraints = {
}
}
vi is a linux editing tool so use notepad and go to that path and as you can see I added
String name
save file now run:
$ grails generate-controller grails.example.Books
$ grails generate-view Books
$ grails generate-view grails.example.Books
$ grails run-app
As for general beginners guide, I came across this site today and have probably used in the past without noticing it...
http://grails.asia/grails-tutorial-for-beginners/
Best of luck and welcome to Grails. I have enjoyed every moment of working with it...
I want to know the versions of the software used while developing the project, Suppose If there is an existing project In grails ,so I want to know the version of grails as well as version of Groovy for that project
Metadata regarding a project in Grails is kept in application.properties.
Within this file you will find the version of Grails used for the project under the key app.grails.version.
The version of Groovy used however is not kept in this file and is determined by the version of Grails being used. To determine the version of Groovy used by a specific version of Grails visit the introduction section of the Grails documentation.
edit
As pointed out in another answer, if you have target version of Grails already downloaded you can search for the version of Groovy being used by that version of Grails.
*nix
$ cd grails-X.X.X
$ find . -name "groovy*jar"
win32
> cd grails-x.x.x
> dir /s "groovy*.jar"
From controllers/services:
def appVersion=Metadata.current.'app.grails.version'
def appName=Metadata.current.'app.name'
From gsp:
App Version <g:meta name="app.version"/>
Built with Grails <g:meta name="app.grails.version"/>
Added extra information to figure out a grails application version from raw text files :
If you have a grails 3 application, you should find a build.gradle in the main root of your application folder:
version "0.1" According to this grails 3 project the version of this application is 0.1
Grails version is 3.1.1 according to gradle.properties
On a grails 2 project you will find application.properties in the main project root:
According to this grails 2 project
grails version is 2.4.4
App version is 0.1
If you already have a project and want to learn which grails version it uses. You can find it in gradle.properties file.
The content of the file is like the following
grailsVersion=4.0.1
gorm.version=7.0.2.RELEASE
As of Grails 3, this is:
Version <g:meta name="info.app.version"/>
Notice the info.
http://docs.grails.org/3.0.17/ref/Tags/meta.html
use application.properties in the root of the grails application
To find out which version of groovy is used with particular version of grails I always use simple find:
$ cd grails-X.X.X
$ find . -name "groovy*jar"
Maybe I'm just too lazy to dig into websites... ;-)
You can see application name,grails version,application version from application.properties file of grails project
I face the same issue, I found simplest way to find version by simple command.
run
grails clean
then it prints
Welcome to Grails 1.3.7 - http://grails.org/
I installed Grails 2.4.0 but my current project needs Grails 2.1.1 version So is it possible to change from Grails 2.4.0 to Grails 2.1.1 version
Mac/Linux
The easiest way to install Grails 3 on Mac and Linux is to use SDKMAN! which we used in the previous section to install Java.
# Install SDKMAN if you haven't
$ curl -s get.sdkman.io | bash
# Install Grails 3
$ sdk install grails 3.3.8
To verify Grails was installed successfully:
$ grails -v
| Grails Version: 3.3.8
| Groovy Version: 2.4.15
| JVM Version: 1.8.0_181
You can also use SDKMAN to switch between Grails versions:
# Easily switch between different versions:
$ sdk use grails 3.2.11
To learn more check out the SDKMAN usage guide http://sdkman.io/usage.html
Windows
Posh-GVM (PowerShell GVM) is the Windows equivalent to SDKMAN (SDKMAN’s original name was GVM - Groovy Version Manager). A few things to note on a Windows system is to keep any whitespace out of your file path and be careful of file and directory length limits. I recommend keeping your Grails app source at C:\source to avoid most issues.
WARNING: The gvmtool dot net URL now redirects to a spam site. A check of archive.org shows it previously redirected to SDKMan.
Are you using Linux or Mac OS X? If so, definitely look into using GVM. You can install different versions of Grails on one machine and easily switch between them by running a command like gvm use grails 2.1.1.
If you are on Windows then you can use GVM with Cygwin or you could try Posh-GVM, which is GVM for PowerShell.
Yes, GVM is a great tool for installing and switching between different versions of Grails