Passing command Line Arguments for grails run-app through gradle task - grails

I have a grails 3 application for which I am trying to pass command line arguments to my application when I am running it through gradle bootRun task.
I want to read the arguments in my config file for runtime operations. As per the grails documentation for yml configration here I tried to add the following to my build.gradle file
run {
systemProperties = System.properties
}
When I add that configuration and run my task I get the following error:
3:11:20 PM: Executing external task 'bootRun -Dcolor=red -Dfruit=apple'...
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\docs\projects\jet\build.gradle' line: 85
* What went wrong:
A problem occurred evaluating root project 'jet'.
> Could not find method run() for arguments [build_6lnm3xriwcnri1zrvfit1niuu$_run_closure8#4446881a] on root project 'jet'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 8.892 secs
Could not find method run() for arguments [build_6lnm3xriwcnri1zrvfit1niuu$_run_closure8#4446881a] on root project 'jet'.
3:11:32 PM: External task execution finished 'bootRun -Dcolor=red -Dfruit=apple'.
Please let me know if there is anything I am missing here or if there is a better way of doing this.

So I find out what the issue was.
Grails 3.0 uses bootRun as target instead of run. Changing adding the below code fixed the issue.
bootRun {
systemProperties = System.properties
}
Hope this helps everyone.

Related

Flutter Picking Wrong Keystore path and giving error key.jks not found

I followed all the steps on the Flutter official site and thought I'd done everything correctly but it is failing to locate the keystore file when I build it.
This is the error message I get showing it taking wrong path instead of
D:\flutterapps\testapp\key.jks:
PS D:\flutterapps\testapp> flutter build apk
Initializing gradle... 1.3s
Resolving dependencies... 4.3s
Gradle task 'assembleRelease'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:validateSigningRelease'.
> Keystore file 'D:\flutterapps\testapp\android\app\ D: lutterappspublishkey.jks' not found for signing config 'release'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
Gradle task 'assembleRelease'... Done 5.3s
Gradle task assembleRelease failed with exit code 1
PS D:\flutterapps\testapp>
On Windows you have to use 2 backslashes to indicate the path separation.
In your key.properties, you should have something like this:
storeFile=D:\\flutterapps\\testapp\\key.jks
You don't need to copy your key.jks file to your flutter project.
modified key.properties file with
storePassword=123456
keyPassword=123456
keyAlias=key
storeFile=key.jks
instead of this
storePassword=123456
keyPassword=123456
keyAlias=key
storeFile=D:\flutterapps\testapp\key.jks
and also moved key.jks to
D:\flutterapps\testapp\android\app\key.jks
as this path shown in error inside terminal
Thanks all.
it's wherever call it from in your build.gradle. insert this:
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
and call this in above your android{}:
def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
and that key.properties file (which should be in your root android folder) should have this:
storePassword=12345
keyPassword=12345
keyAlias=key
storeFile=/Users/me/somekey.jks
Yeah, for me... I forgot to change my signingConfig to singingConfigs.release in my build.gradle file.
buildTypes {
release {
//CHANGE THIS TO RELEASE
signingConfig signingConfigs.debug
}
}
In build.gradle
Replace
def keystorePropertiesFile = rootProject.file('key.properties')
to
def keystorePropertiesFile = rootProject.file('app/key.properties')
I was having the same issue, I ended up having quotes around my path.
In key.properties, change
storeFile="D:\\mypath\\tokeystore\\key.jks"
to
storeFile=D:\\mypath\\tokeystore\\key.jks

Grails 3.2.11 plugin bintrayUpload missing grails-plugin.xml

I follow the grails 3 plugin tutorial. I create a project:
https://github.com/fabiooshiro/no-surprises
$ gradle bintrayUpload
> Configure project :
Gradle now uses separate output directories for each JVM language, but this build assumes a single directory for all classes from a source set. This behaviour has been deprecated and is scheduled to be removed in Gradle 5.0
at build_84d0cz3ffyc3w9ul7qh3qjt2t.run(/home/ivt/investtools/no-surprises/build.gradle:17)
The setTestClassesDir(File) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the setTestClassesDirs(FileCollection) method instead.
at build_84d0cz3ffyc3w9ul7qh3qjt2t.run(/home/ivt/investtools/no-surprises/build.gradle:17)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':publishMavenPublicationToMavenLocal'.
> Failed to publish publication 'maven' to repository 'mavenLocal'
> Invalid publication 'maven': artifact file does not exist: '/home/ivt/investtools/no-surprises/build/classes/java/main/META-INF/grails-plugin.xml'
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED in 1s
11 actionable tasks: 2 executed, 9 up-to-date

Custom Ant Task Not Working On Build Server

I've got a custom Ant task that I'm using successfully from gradle on my local machine:
task fetchRelMod {
doLast {
println 'Fetching the RelMod'
ant.taskdef(name:'relmod',
classpath:'retrievePBSInfo.jar:hsjt400-4-9.jar',
classname:"com.myco.ant.tasks.RetrievePBSRelModString")
ant.relmod(user:project.ext.props.getProperty('fetchrelmod.username'),
password:project.ext.props.getProperty('fetchrelmod.password'),
prodCode:project.ext.props.getProperty('profile.pbs.product.code'),
branch:project.ext.props.getProperty('profile.pbs.branch'),
state:project.ext.props.getProperty('profile.pbs.relmod.selector'))
project.ext.set('iseries_relmod',ant.relmodStub)
project.ext.set('iseries_relmodAndDate', ant.relmod)
}
}
I've got the jar files sitting next to build.gradle for now, out of simplicity... they exist in the same location on the build server. Works great locally. When I run my build from my build server (either through Jenkins or going on the box and running Gradle directly), I get the following:
sudo /var/lib/jenkins/tools/hudson.plugins.gradle.GradleInstallation/gradle214/bin/gradle all -DisQUABuild=true
Building My App
Loading Properties files...
QUA Build. Using build-qua.props
:fetchRelMod
Fetching the RelMod
:fetchRelMod FAILED
FAILURE: Build failed with an exception.
* Where:
Build file '/var/lib/jenkins/workspace/MyApp/build.gradle' line: 141
* What went wrong:
Execution failed for task ':fetchRelMod'.
> taskdef class com.myco.ant.tasks.RetrievePBSRelModString cannot be found
using the classloader AntClassLoader[/var/lib/jenkins/workspace/myApp/hsjt400-4-9.jar]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.104 secs
What concerns me is that there are two jar files in the classpath and it only mentions one in the error. Does anyone have any ideas as to what might be going on?

ElasticSearch plugin causing server to stop in Grails 3.1.6

I'm trying to add ElasticSearch plugin in my Grails 3.1.6 project.
I installed plugin as:
dependencies {
//..
compile 'org.grails.plugins:elasticsearch:1.0.0.2'
//..}
And configured application.yml as
elasticSearch:
client:
node: local
datastoreImpl: hibernateDatastore
But when I try to run application, i'm getting error as below:
BUILD SUCCESSFUL
Total time: 5.118 secs
|Running application...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':bootRun'.
> A problem occurred starting process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe''
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Error |
Failed to start server (Use --stacktrace to see the full trace)
Process finished with exit code 1
I'm using IntellijIdea v2016 as IDE.
Would someone please help me to figure out the error spot please.
Thanks.
This isn't related to the plugin, it's a Boot/Gradle problem caused by having a classpath that causes the process to fail because the combined length of the process command is larger than the max Windows allows. This was fixed in 3.1.2 but you have to add a small config setting to build.gradle since it's not a problem in Linux or OSX:
grails {
pathingJar = true
}
See https://github.com/grails/grails-core/issues/9125 for more info.

Grails 3 "Build failed with an exception" using assets-pipeline with sass-grails-asset-pipeline

I'm trying to use the grails asset-pipeline plugin with the sass extension on Grails 3. Unfortunately, following the documentation to configure them in the build.gradle file isn't useful because this error is generated:
FAILURE: Build failed with an exception.
* Where:
Build file '/MyProject/build.gradle' line: 17
* What went wrong:
Could not compile build file '/MyProject/build.gradle'.
> startup failed:
build file '/MyProject/build.gradle': 17: only id(String) method calls allowed in plugins {} script block
See http://gradle.org/docs/2.3/userguide/plugins.html#sec:plugins_block for information on the plugins {} block
# line 17, column 5.
provided ":sass-asset-pipeline:$assetsPipelineSassVersion"
^
1 error
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.128 secs
| Error Error initializing classpath: startup failed:
build file '/MyProject/build.gradle': 17: only id(String) method calls allowed in plugins {} script block
See http://gradle.org/docs/2.3/userguide/plugins.html#sec:plugins_block for information on the plugins {} block
# line 17, column 5.
provided ":sass-asset-pipeline:$assetsPipelineSassVersion"
^
1 error
(Use --stacktrace to see the full trace)
0
I've found a solution with this gradle configuration (version variables are defined in gradle.properties):
buildscript {
dependencies {
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:$assetsPipelineVersion"
}
}
apply plugin: 'com.bertramlabs.asset-pipeline'
assets {
minifyJs = true
minifyCss = true
from '/img'
from '/js'
from '/css'
from '/fonts'
}
dependencies {
compile "org.grails.plugins:asset-pipeline"
runtime "org.grails.plugins:asset-pipeline"
assets "com.bertramlabs.plugins:sass-asset-pipeline:$assetsPipelineSassVersion"
}

Resources