配置
在Grails 3.2.11手册的Plugins and Multi-Project Builds section之后,假设我可以使用终端中的下一个命令设置多项目:
echo "Creating the root folder..."
mkdir test-multi-project
cd test-multi-project
echo "Creating the settings.gradle file..."
echo "include 'myapp', 'myplugin'" >> settings.gradle
echo "Creating the Grails application..."
grails create-app myapp
echo "Creating the Grails plugin..."
grails create-plugin myplugin
echo "Configuring the dependency between the application and the plugin..."
echo "grails { plugins { compile project(':myplugin') } }" >> myapp/build.gradle
echo "Executing the Grails application..."
cd myapp
grails run-app
错误
但是,当我尝试使用这些命令创建并配置Grails应用程序和插件时,grails run-app
命令会抛出下一个错误:
FAILURE: Build failed with an exception.
* Where:
Build file '~/test-multi-project/myapp/build.gradle' line: 61
* What went wrong:
A problem occurred evaluating root project 'myapp'.
> Project with path ':myplugin' could not be found in root project 'myapp'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
CONFIGURE FAILED
Total time: 4.835 secs
| Error Error initializing classpath: Project with path ':myplugin' could not be found in root project 'myapp'. (Use --stacktrace to see the full trace)
其他信息
我已经使用Grails 3.2.8,3.2.9,3.2.10和3.2.11测试了上述命令,并且代码抛出相同的错误。
另一方面,我使用Grails 3.2.3,3.2.5和3.2.7测试了上述命令,项目执行正常。此外,Grails登录页面显示应用程序已使用“mypluin”。
注意,我使用sdk来处理Grails版本。这些命令是使用Java 1.7和Yosemite执行的:
问题:
我想知道我还需要做什么或者我做错了什么才能使这段代码适用于Grails 3.2.11
提前致谢。
答案 0 :(得分:1)
Jeff Brown解决了上述问题,删除了multi-project-test2/myapp/settings.gradle
文件并将下一行添加到multi-project-test2/settings.gradle
文件中:
project(':myapp').name = 'myapp'
正如您在下一个GitHub的提交中看到的那样:https://github.com/esalomon/multi-project-test2/commit/d92c3fbc67156bcd1af9f47dc6f2984534154bad
经过上述更新后,multi-project-test2可以下载,它可以正常使用。
答案 1 :(得分:0)
在这一点上可能出现了问题:
echo "grails { plugins { compile project(':myplugin') } }" >> myapp/build.gradle
该段需要添加到该文件的现有块而不是新块(不是我测试过的)
手动执行这些步骤后会发生什么?它是否以这种方式工作?如果是这样的话,你是否想过对文件进行差异化改变,看看有什么不同。
您提供的脚本很棒,也许其他人希望通过它来运行但我怀疑它已经被指出了。
您应该查看ed
类似这样的例子:
我正在使用grails 3.2.8 app,它在依赖段中以这样结束:
runtime "com.h2database:h2"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
现在如果我执行
test328$ ed -s build.gradle <<EOF >/dev/null
g/^ testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
a
compile project(':myplugin')
.
w
q
EOF
你现在可以看到:
tail -n20 build.gradle
runtime "com.h2database:h2"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
compile project(':myplugin')
}
新条目已添加。您需要在grails生成的现有文件中找到一个指针,并使用上面的指针来添加条目
ed脚本用于演示这个,因为显然它以前不够清楚