Grails® Angular Profiles
April 12, 2017
Tags: #angular
In order to be consistent with the Angular team's guidelines on naming conventions, we have renamed the Angular profiles that the Grails® framework provides. This change will take affect in Grails 3.2.9. Any existing applications will not be impacted by this change. This will only affect your project if you create a new application with Grails 3.2.9 or above, or if you upgrade an existing application.
Previously we had:
Name | Latest Version | Repo Location | Angular Versions Supported |
---|---|---|---|
angular | 3.2.2 | https://github.com/grails-profiles/angular | 1.x |
angular2 | 1.0.5 | https://github.com/grails-profiles/angular2 | 2.x |
The "angular" profile was renamed to "angularjs." Then the "angular2" profile was renamed to "angular."
Since "angularjs" is a new module, we restarted the version to 1.0.0.
Since "angular" already exists, the version had to be higher than the current version. Since the existing version is 3.2.2, we chose 4.0.0. That also happens to fall in line with the Angular version supported, however the new profile may not follow the Angular version it supports.
Now we have:
Name | Latest Version | Repo Location | Angular Versions Supported |
---|---|---|---|
angularjs | 1.0.0 | https://github.com/grails-profiles/angularjs | 1.x |
angular | 4.0.0 | https://github.com/grails-profiles/angular | 4.x |
Potential Issues Caused by This Change
Angular Profile
If you have an existing application created with the "angular" profile, you are using the profile for Angular 1.x.
dependencies {
profile org.grails.profiles:angular
}
Since the Grails framework manages the version of the profile for you, if you were to upgrade to a newer version of the Grails framework, you will get the newer version of the angular profile. That means that previously you had the Angular 1.x profile and after upgrading, you will have the Angular 4.x profile.
Fortunately the change will not change the behavior of your application in any way. The only problem you may encounter is if you attempt to use the commands provided by the AngularJS profile. You will find the commands (create-ng-controller
, create-ng-directive
, etc) won't work as they exist in the "angularjs" profile, while you have the "angular" profile.
To get the commands working again, simply change the dependency to "angularjs".
dependencies {
profile org.grails.profiles:angular //Change to "angularjs"
}
In addition, you should change the profile set in the configuration.
grails:
profile: angular //Change to "angularjs"
Angular2 Profile
If you have an existing application with the "angular2" profile and you upgrade to Grails 3.2.9 and above, you will find Gradle can't find the dependency because the Grails framework is no longer providing a version for that dependency. To fix the problem, simply change the dependency in build.gradle
.
dependencies {
profile org.grails.profiles:angular2 //Change to "angular"
}
In addition, you should change the profile set in the configuration.
grails:
profile: angular2 // Change to "angular"
Scaffolding Plugin Changes
In addition to the profiles, the plugins that provide scaffolding also needed to be renamed in the same manner.
NOTE: At the time of this post, the Angular 2.x+ scaffolding is still in a release candidate stage.
Before:
Name | Latest Version | Repo Location | Angular Versions Supported |
---|---|---|---|
angular-scaffolding | 1.0.1 | https://github.com/grails-plugins/grails-angular-scaffolding | 1.x |
angular2-scaffolding | 1.0.0.RC1 | https://github.com/grails-plugins/grails-angular2-scaffolding | 2.x + |
After:
Name | Latest Version | Repo Location | Angular Versions Supported |
---|---|---|---|
angularjs-scaffolding | 1.0.3 | https://github.com/grails-plugins/grails-angularjs-scaffolding | 1.x |
angular-scaffolding | 2.0.0.RC1 | https://github.com/grails-plugins/grails-angular-scaffolding | 2.x + |
The only change necessary is to update your build.gradle
.
Angular 2.x +
buildscript {
dependencies {
//Change to "angular-scaffolding:2.0.0.RC1"
classpath org.grails.plugins:angular2-scaffolding:1.0.0.RC1
}
}
dependencies {
//Change to "angular-scaffolding:2.0.0.RC1"
compile org.grails.plugins:angular2-scaffolding:1.0.0.RC1
}
Angular 1.x
buildscript {
dependencies {
//Change to "angularjs-scaffolding:1.0.3"
classpath org.grails.plugins:angular-scaffolding:1.0.1
}
}
dependencies {
//Change to "angularjs-scaffolding:1.0.3"
compile org.grails.plugins:angular-scaffolding:1.0.1
}
Conclusion
The goal of this change was to make determining which profile/scaffolding plugin should be used less confusing in the future. If you encounter any problems as a result of this change that were not expected, please file an issue.