Disable automatic loading for groovy grapes

Sample script ss.groovy:

@Grab(group='org.codehaus.groovy.modules.http-builder', 
      module='http-builder', 
      version='0.5.0')
import groovyx.net.http.HTTPBuilder

println('done')

for some reason, it takes ~ 25 seconds to load when starting from

groovy ss.groovy

and ~ 5 seconds when starting with

groovy -Dgroovy.grape.autoDownload=false ss.groovy

according qaru.site/questions/1762997 / ... . I tried to perform manual initialization with

Grape.enableAutoDownload = false
Grape.grab(group:'org.codehaus.groovy.modules.http-builder', 
           module:'http-builder',
           version:'0.5.0')
import groovyx.net.http.HTTPBuilder
println('done')

but this fails when importing with:

/tmp/ss.groovy: 3: unable to resolve class groovyx.net.http.HTTPBuilder
 @ line 3, column 1.
  import groovyx.net.http.HTTPBuilder
  ^

Is there an affordable way:

  • Do not download artifacts automatically (preferable, since this allows you to solve other problems, for example, an external site down while the artifact already exists in the local cache)
  • Make launch faster any other way.

, script, , , (, ). , ), groovy (, ~/.groovy/grapeConfig.xml ).

+3
3

: , @GrabConfig(autoDownload=false) Groovy 2.2

+2

?

http://nexus.sonatype.org/

Nexus - . Groovy Nexus:

<ivysettings>
  <settings defaultResolver="downloadGrapes"/>
  <resolvers>
    <chain name="downloadGrapes">
      <filesystem name="cachedGrapes">
        <ivy pattern="${user.home}/.groovy/grapes/[organisation]/[module]/ivy-[revision].xml"/>
        <artifact pattern="${user.home}/.groovy/grapes/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/>
      </filesystem>
      <!-- Local Nexus Repository -->
      <ibiblio name="nexus" root="http://localhost:8081/nexus/repositories/public" m2compatible="true"/>
    </chain>
  </resolvers>
</ivysettings>
0

This is not possible with the current (Groovy 1.8.1) implementation. I created a ticket for improvement: http://jira.codehaus.org/browse/GROOVY-4943 .

0
source

Source: https://habr.com/ru/post/1762996/


All Articles