Setting location of Grape configuration file
Asked Answered
D

1

7

How do you configure Grape to look for a custom configuration file at a location other than the default of ~/.groovy/grapeConfig.xml? Unfortunately the official documentation at http://groovy.codehaus.org/Grape appears to be incomplete and doesn't cover this particular case.

For example, I'd like to specify a path such as $PROJECT_DIR/src/main/resources/groovyConfig.xml so that other members in my team don't have to create and maintain their own groovyConfig.xml files in their user/home directories.

Drive answered 16/5, 2013 at 1:32 Comment(0)
D
10

To set a custom path to the Grape configuration file, set the grape.config system property, e.g. if grape.config is set to /home/user/customGrapeConfig.xml then Grape will use that as the configuration file.

The full list of options related to Grape configuration files, according to a Groovy Developers' mailing list thread, is as follows:

  1. Grape will use the value of the system property grape.config (if it is set) as the path to the configuration file.
  2. If grape.config is not set, then:
    • If the groovy.root system property is set, Grape will look for the configuration file in the directory specified; otherwise
    • If groovy.root is not set, it uses ${user.home}/.groovy/ as the Groovy root directory and looks for a configuration file there.
  3. If no configuration file is found to exist as per the previous steps, the defaultGrapeConfig.xml is retrieved from GrapeIvy's classloader (i.e. from the Groovy JAR).
Drive answered 16/5, 2013 at 1:32 Comment(3)
This algorithm resides in git-wip-us.apache.org/repos/asf?p=groovy.git;a=blob;f=src/main/…Dredge
I wanted to integrate Groovy Grape/Ivy with a local Maven cache. GrapeIvy only reads Maven artifacts. A reimplementation that uses Maven for both reading and writing cached artifacts appears here: github.com/yihtserns/grape-mavenDredge
the new link for the algorithm is now git-wip-us.apache.org/repos/asf?p=groovy.git;a=blob;f=src/main/… (as per @eelghEEz comment)Delorasdelorenzo

© 2022 - 2024 — McMap. All rights reserved.