How do I get a gradle property into intellij while debugging? - gradle

I write test automation. I'm using Log4j2 in my gradle project, and I do development with Intellij. My automation runs at the end of a build. And everything that happens when the automation runs is logged using Log4j2. I pass in the properties that Log4j2 needs via the build.gradle file. The config properties that I pass to Log4j2 are the location of the config file, where to put the output log file, and what logging level I want. But when I'm writing tests and running them manually in intellij, it's like I'm short-circuiting the build.gradle file, and I get no properties and no logging when I do. How do I fix that?

Related

Maven Failsafe Integration Test Classpath

I have an spring application which reads properties file content from etcd server and then writes the content of that into applications properties file. After that I use that properties file to load my propertyManager.
Code implementation is done but when I try to create integration-tests, there is an small problem:
I use MyClass.class.getResource(configFilePath) to get URL of my properties file and since it points to a file inside of a JAR file while working integration tests. I can't write what I read from etcd server to my properties file since its in JAR file(under target) now.
I tried to add additionalClasspathElement ${project.build.directory}\conf to my classpath and use properties file inside of that folder but its not working.
Is there a way for me to change classpath of integration test via failsafe plugin?
Note: Springs etcd support is not want I want to use. I want to change my classpath when I run my integration tests.

Accessing Properties From Gradle in Groovy

I'm trying to set a variable/property within Gradle during a war build for deployment. However, when I try setting it, it seems it just gets set to null whenever I try accessing it from groovy. I'm building on a local machine with the command (I've tried both):
gradle build -Dgrails.env=development -Dtest.variable=/app/testing/development or gradle war -Dgrails.env=development -Dtest.variable=/app/testing/development
Then I deploy the WAR file to a Tomcat server.
But when I try accessing that variable by System.getProperty("test.variable") I am receiving a null error on that property. What do I need to do to set a command-line variable in Gradle and have it be accessible in Groovy when I try to deploy the WAR file on a server? I know the grails.env is working as it is reading the proper values in the application.yml file, but I cannot access the given property that I am trying to set.

What exactly happens when you hit the IntelliJ "run" button? [duplicate]

IntelliJ IDEA 2016.3 add the ability to delegate build/run to Gradle.
It's clear that when the delegate option is on Gradle is doing everything.
My question is what exactly IntelliJ is doing when this option is off?
I'm asking this because I have custom code inside my Gradle files and it does not seems like this code is executed when building in IntelliJ. When I run gradlew build everything works just fine.
IntelliJ has its own build system, called JPS, which uses the IntelliJ IDEA project and .iml files as the project model. When you're using IntelliJ IDEA's default build system to build the project, it does not execute any code in Maven or Gradle files; it uses its own logic, which can only be extended by writing plugins to JPS.

Running Gradle Wrapper commands resets Spring application.properties file

I have added spring.redis.host and spring.redis.port properties to the applications.properties file of my Spring boot application (Apache Fineract) in order to configure it with Redis. However, every time I run any gradle wrapper command, such as ./gradlew clean tomcatRunWar or ./gradlew build, the application.properties file gets reset to the initial version and my edits cannot be seen.
Is there any way for ensuring that gradle wrapper takes into consideration the custom edits that I am making to it? Thanks.

How maven pom.xml file convert configurations into system properties?

As we all know, suppose we define 'transportation' in pom.xml in maven,
after we run command like 'mvn jetty:run' the property 'db.name' can be discovered by other configuration, like 'hibernate.cfg.xml'. That's fine.
But now, I configure this project to run on tomcat directly , by 'run on server' from eclipse, instead of by maven command. (I did this by configure a project facets in eclipse, make it can use 'run on server' menu). You can see now I just run with eclipse, nothing to do with 'maven' or 'pom.xml', but it still use properties like 'db.name'. If I need change to another db, I had to change the 'db.name' property, then run some command in maven to make it take effect.
Can any body give some explanation about how it works? Does maven command generate some file at some place that takes the properties?
Properties are set for virtual machine. Maven run new/existing (dependent on configuration) instance of runtime environment. So you can pass properties as
-Dkey=value (or <key>value</key> in pom)
Check in eclipse configuration if you can pass arguments when you run tomcat?
Eclipse maven plugin (from Eclipse foundation) understands the pom.xml and usually syncs with any changes.
But sometimes I observed that it goes out of sync, and to fix that problem I need to delete the temporary folders/files created by Eclipse (.settings, .classpath and .project) and import again.

Resources