最简单的 gradle 项目来运行时髦的脚本



我有一堆时髦的脚本,工作得很好。但是,它们总是存在加载整个JVM的"冷启动"问题。我想将它们与 gradle 一起作为任务运行(不将它们定义为任务,以便它们可以在没有 gradle 的情况下运行(,这样我就可以将 gradle 保持在守护程序模式,从而"热">

我当前的项目实际上不起作用,因为我需要的一个时髦文件不在类路径上。我可以手动加载它,但我怀疑有更简单的东西(约定?

这是我的回购的树视图

$ tree
.
├── build.gradle
├── settings.gradle
└── src
├── BBScm.groovy
├── Scm.groovy
├── StashScm.groovy
├── mixins.groovy
└── stash.groovy

这是我的build.gradle:

plugins {
id 'groovy'
}
group 'org.bongiorno'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
configurations {
groovyScript
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.5.2'
}
task analyze {
doLast{
apply from: 'src/stash.groovy'
}
}

我得到的错误很清楚:

script '/Users/cbongiorno/dev/mystuff/stash/src/stash.groovy': 22: unable to resolve class StashScm 
@ line 22, column 13.
Scm stash = new StashScm(u: srcUser, p: srcPass, baseUrl: 'https://xxxxx')
^

需要明确的是:我的问题是,最简单的方法是什么?'因为我绝对可以破解这个问题

src是放置代码进行编译并在最后术语中构建工件的地方,但如果要添加代码(以源代码形式(,则必须使用buildSrc目录

您可以在 https://docs.gradle.org/current/userguide/organizing_gradle_projects.html#sec:build_sources

以同样的方式,depedencies部分是查找项目依赖项的位置,但如果build逻辑中有依赖项,则可以使用build部分指定它,在其中指定它使用classpath单词而不是compile

最新更新