0

我想让 grails 自动解析 Google Code 项目的依赖项:

https://code.google.com/p/google-api-java-client/

Maven 示例如下所示:

<project>
  <repositories>
    ...
    <repository>
      <id>google-api-services</id>
      <url>http://google-api-client-libraries.appspot.com/mavenrepo</url>
    </repository>
    ...
  </repositories>
  <dependencies>
    ...
    <dependency>
      <groupId>com.google.apis</groupId>
      <artifactId>google-api-services-storage</artifactId>
      <version>v1beta1-rev21-1.14.1-beta</version>
    </dependency>
    ...
  </dependencies>
</project>

这是我尝试过的命令:

grails install-dependency com.google.apis:google-api-services-storage:google-api-services-storage --repository=http://google-api-client-libraries.appspot.com/mavenrepo

失败的结果:

There was an error resolving the dependency 'com.google.apis:google-api-services-storage:google-api-services-storage'.
This could be because you have passed an invalid dependency name or because the dependency was not found in one of the default repositories.
Try passing a valid Maven repository with the --repository argument.
spider:cloud-storage-prototype spider$ 
4

1 回答 1

2

如果您使用现代版本的 grails,您应该将以下行添加到您的 grails-app/conf/BuildConfig.groovy:

grails.project.dependency.resolution = {

[...]

repositories {

[...]

    mavenRepo "http://google-api-client-libraries.appspot.com/mavenrepo"

[...]

dependencies {

[...]

    compile 'com.google.apis:google-api-services-storage:v1beta1-rev21-1.14.1-beta'

但是,如果您希望在 lib/ 文件夹中安装依赖项,您可以使用:

grails install-dependency com.google.apis:google-api-services-storage:v1beta1-rev21-1.14.1-beta --repository=http://google-api-client-libraries.appspot.com/mavenrepo

于 2013-04-02T10:12:59.080 回答