【问题标题】:Configure Artifactory with grails project使用 grails 项目配置 Artifactory
【发布时间】:2014-10-16 08:57:39
【问题描述】:

我正在尝试使用远程 Artifactory 配置 Grails 项目,但未能正确配置它。

Envionmanet 设置

  1. grails-2.4.3
  2. artifactory.version 3.3.0

BuildConfig.groovy

grails.project.dependency.resolver = "maven" // or ivy

grails.project.ivy.authentication = {
    repositories {
        mavenRepo "http://SERVER/artifactory/grails-remote"
    }
    credentials {
        realm = "Artifactory Realm"
        host = "SERVER"
        username = "USERNAME"
        password = "PASSWORD"
    }
}

grails.project.dependency.resolution = {
    // inherit Grails' default dependencies
    inherits("global") {
        // specify dependency exclusions here; for example, uncomment this to disable ehcache:
        // excludes 'ehcache'
    }
    log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
    checksums true // Whether to verify checksums on resolve
    legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility

    repositories {
        inherits true // Whether to inherit repository definitions from plugins
        mavenRepo id: 'Artifactory', url: "http://SERVER/artifactory/grails-remote"
    }

    dependencies {
        // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
        // runtime 'mysql:mysql-connector-java:5.1.29'
        // runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'
        test "org.grails:grails-datastore-test-support:1.0-grails-2.4"
    }

    plugins {
        // plugins for the build system only
        build ":tomcat:7.0.55"

        // plugins for the compile step
        compile ":scaffolding:2.1.2"
        compile ':cache:1.1.7'
        compile ":asset-pipeline:1.9.6"

        compile ":rabbitmq:1.0.0"

        // plugins needed at runtime but not for compilation
        runtime ":hibernate4:4.3.5.5" // or ":hibernate:3.6.10.17"
        runtime ":database-migration:1.4.0"
        runtime ":jquery:1.11.1"
    }
}

为项目执行 refresh-dependencies 命令后出现以下异常

Loading Grails 2.4.3
|Configuring classpath
Error |
Resolve error obtaining dependencies: The following artifacts could not be resolved: org.grails.plugins:scaffolding:zip:2.1.2, org.grails.plugins:cache:zip:1.1.7, org.grails.plugins:webxml:zip:1.4.1, org.grails.plugins:asset-pipeline:zip:1.9.6, org.grails.plugins:rabbitmq:zip:1.0.0, org.grails.plugins:hibernate4:zip:4.3.5.5, org.grails.plugins:database-migration:zip:1.4.0, org.grails.plugins:jquery:zip:1.11.1: Could not find artifact org.grails.plugins:scaffolding:zip:2.1.2 in Artifactory (http://SERVER/artifactory/grails-remote) (Use --stacktrace to see the full trace)
Error |
Resolve error obtaining dependencies: The following artifacts could not be resolved: org.grails.plugins:scaffolding:zip:2.1.2, org.grails.plugins:cache:zip:1.1.7, org.grails.plugins:webxml:zip:1.4.1, org.grails.plugins:asset-pipeline:zip:1.9.6, org.grails.plugins:rabbitmq:zip:1.0.0, org.grails.plugins:hibernate4:zip:4.3.5.5, org.grails.plugins:database-migration:zip:1.4.0, org.grails.plugins:jquery:zip:1.11.1: Could not find artifact org.grails.plugins:scaffolding:zip:2.1.2 in Artifactory (http://SERVER/artifactory/grails-remote) (Use --stacktrace to see the full trace)
Error |
Resolve error obtaining dependencies: The following artifacts could not be resolved: org.grails.plugins:scaffolding:zip:2.1.2, org.grails.plugins:cache:zip:1.1.7, org.grails.plugins:webxml:zip:1.4.1, org.grails.plugins:asset-pipeline:zip:1.9.6, org.grails.plugins:rabbitmq:zip:1.0.0: Could not find artifact org.grails.plugins:scaffolding:zip:2.1.2 in Artifactory (http://SERVER/artifactory/grails-remote) (Use --stacktrace to see the full trace)
Error |
The following artifacts could not be resolved: org.grails.plugins:scaffolding:zip:2.1.2, org.grails.plugins:cache:zip:1.1.7, org.grails.plugins:webxml:zip:1.4.1, org.grails.plugins:asset-pipeline:zip:1.9.6, org.grails.plugins:rabbitmq:zip:1.0.0: Could not find artifact org.grails.plugins:scaffolding:zip:2.1.2 in Artifactory (http://SERVER/artifactory/grails-remote)
|Run 'grails dependency-report' for further information.
Process was killed

我已阅读并尝试了以下链接中描述的几种解决方案,但无济于事

  1. How to configure grails 2.4.0 to resolve artifacts from artifactory with authentication?
  2. http://wordpress.transentia.com.au/wordpress/2014/04/09/artifactory-and-grails/

更新1:

仔细查看Artifactory's apache catalina log 后,我发现某些插件会导致一些禁止错误。

2014-10-15 15:16:19,596 [ajp-bio-8019-exec-10] [INFO ] (o.a.r.s.RepositoryBrowsingServiceImpl:236) - Error while listing remote resources for codehaus/org/grails/grails-datastore-gorm-mongo: Unable to retrieve http://repository.codehaus.org/org/grails/grails-datastore-gorm-mongo/: 403: Forbidden

谁能帮我看看配置有什么问题?

您好, 马扬克

【问题讨论】:

  • 有人可以指导我吗?我仍然在同一条线上。

标签: grails grails-2.0 artifactory


【解决方案1】:

而不是使用grails.project.ivy.authentication 定义存储库身份验证,您可能应该使用以下方式定义存储库:

grails.project.dependency.resolution = {
    repositories {
        grailsCentral()
        ....
        mavenRepo(name: 'name', url: 'https://host/artifactory/reponame') {
            auth(username: 'username', password: 'password')
        }
        ....
    }
}

【讨论】:

  • 感谢您的回复。我尝试了您建议的更改,但无济于事。我仍然在运行同样的错误。您在 repositories 标签中提到了 grailsCentral(),我相信它会直接从 grails Central repo 下载插件,但我希望所有库和插件下载都应该通过 Artifactory。
  • 您确定您的工件正确代理 grails central 吗?
  • 你能告诉我如何验证吗?
  • 您需要将 Grails Central 添加为 Artifactory 中的远程存储库
猜你喜欢
  • 1970-01-01
  • 2011-09-30
  • 1970-01-01
  • 1970-01-01
  • 2016-03-31
  • 2018-12-04
  • 1970-01-01
  • 2017-02-15
  • 2022-11-28
相关资源
最近更新 更多