Custom logback.groovy and Gradle

Hi

We have a project that has been migrated to Gradle but we are having some trouble getting a logback.groovy file containing a custom logging implementation read by the application while developing and executing the application using IDEA.

Currently the file is stored in project_name -> src ->main -> resources -> logback.groovy

We get the following console output when executing the application:

16:57:37,541 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy] 16:57:37,541 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml] 16:57:37,542 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.xml] 16:57:37,544 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Setting up default configuration.

Any help would be much appreciated.

Thanks! Peter.

Isn’t the application built by IDEA? How is Gradle involved in this?

The application is built by IDEA.

There is a similar problem here: http://stackoverflow.com/questions/15153662/logback-configuration-in-groovy-and-different-class-paths-in-gradle-idea

But that persons solution is to use gradle run from inside of IDEA which is not an option for us.

Let me change that,

The application needs to be run from IDEA but to build the JAR we use Gradle because the option to do it using IDEA seems to be greyed out in IDEA

How do you accomplish this? How do you tell IDEA to run the application built by Gradle?

Thanks for your patience with this, I will try and example this to the best of my ability.

While being developed we would like to be able to build and run the project using IDEA. Gradle as far as we know limits us as not being able to debug the application if we use the Gradle Run command inside of IDEA. If Gradle was capable of letting us debug inside of IDEA that would be acceptable. Gradle seemed to have an icon in IDEA for running in debug but it didn’t seem to hit any breakpoints.

Regarding the file:

When the file is in the Gradle resources folder the file can be found when using the Gradle Run command but it does throw an exception but we can tackle that battle when we come to it.

But while the file is in the Gradle resources folder we cant use IDEA to run the project as it cannot find the file at all.

I expect that using Gradle as the underlying build tool for IDEA will become a stronger option in IDEA 13. (This is what powers Android Studio.)

But while the file is in the Gradle resources folder we cant use IDEA to run the project as it cannot find the file at all.

It’s a matter of configuring IDEA to identify the files as resource files, so that it copies them over to its output directory (Preferences->Project Settings->Compiler->Resource patterns).

Hi,

I have put a good bit of time into trying to get this to work this morning with help from Google.

As far as I can see my resource pattern is okay as .groovy is contained within it already and the folder is marked as source yet IDEA still cant find the file.

Pattern: !?.java;!?.form;!?.class;!?.groovy;!?.scala;!?.flex;!?.kt;!?.clj

That pattern excludes Groovy files. Try to get rid of the Groovy part. Or better, add “logback.groovy”, then check if it ends up in the IDEA output directory.

Yup, it found the file and I’m getting the same exception as when run with Gradle.

Thank you for your help!