相关疑难解决方法(0)

Gradle不使用Maven Local Repository作为新的依赖项

我将Maven与M2_HOME定义为:

  • /Users/manuelj/apache/maven/3.2.5

我有settings.xml文件,位于:

  • /Users/manuelj/apache/maven/3.2.5/conf/settings.xml

我声明如下:

<localRepository>/Users/manuelj/apache/maven/repository</localRepository>

直到与Maven一起工作一切正常.任何新的依赖都会在那里.

我有一个基于Gradle的项目,在我的build.gradle中有很多东西,存在以下内容:

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: 'application'

version = '1.0.0'
sourceCompatibility = '1.8'

repositories {
   mavenLocal()
   mavenCentral()
}
… more
Run Code Online (Sandbox Code Playgroud)

直到这里,一切都很好.代码编译,执行良好.

我的困惑如下.

根据我的理解,Gradle mavenLocal()应该使用与<localRepository>Maven settings.xml文件中定义的路径相同的路径.

现在确认在Maven本地存储库中存在已经下载的一些依赖项.

当我执行例如gradle build时,我确实意识到了这一点

  • 如果Maven Local Repository中已存在依赖关系,则从那里使用它.
  • 如果Maven Local Repository Gradle中不存在依赖项,则将新依赖项下载到: /Users/manuelj/.gradle/caches/modules-2/files-2.1

我希望新的依赖项直接转到同一个Maven Local Repository.

因此,需要什么额外配置呢?

gradle build.gradle

31
推荐指数
3
解决办法
5万
查看次数

gradle 1.10内部maven存储库永远索引在intellij 13中

我有两个项目.一个Maven和一个Gradle.该公司还有一个内部maven存储库.我正在尝试设置Gradle以使用内部仓库.使用Intellij 13时,我将这样的repo添加到build.gradle中的Gradle

build.gradle文件:

    apply plugin: 'java'
    apply plugin: 'war'

    sourceCompatibility = 1.5
    version = '1.0'

    maven {
            url "http://nexus.company.com/nexus/repo"
        }
        mavenLocal()
        mavenCentral()
        maven {
            url "https://oss.sonatype.org/content/repositories/snapshots"
        }
Run Code Online (Sandbox Code Playgroud)

.m2/settings.xml似乎被gradle完全忽略(我尝试不将maven repo添加到build.gradle文件中,并希望gradle将查看.m2/settings.xml以确定从哪里获取工件)

.m2/settings.xml文件

    <settings>
     <mirrors>
       <mirror>
         <id>nexus</id>
         <mirrorOf>*</mirrorOf>
         <url>http://nexus.company.com/nexus/repo</url>
       </mirror>
     </mirrors>


     <profiles>
       <profile>
             <id>central-repo</id>
             <repositories>
                 <repository>
                     <id>central</id>
                     <url>http://central</url>
                     <releases><enabled>true</enabled></releases>
                     <snapshots><enabled>true</enabled></snapshots>
                 </repository>
                </repositories>
                <pluginRepositories>
                    <pluginRepository>
                        <id>central</id>
                        <url>http://central</url>
                        <releases><enabled>true</enabled></releases>
                        <snapshots><enabled>true</enabled></snapshots>
                    </pluginRepository>
                    </pluginRepositories>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>central-repo</activeProfile>
    </activeProfiles>
</settings>
Run Code Online (Sandbox Code Playgroud)

当repo为http://nexus.company.com/nexus/repo时,Intellij会在后台任务中永远旋转,说"处理索引" .没有它,一切工作都很好,除了内部工件无法下载.

但是,maven项目需要相同的工件下载并在几秒钟内就绪.

我很陌生.我犯了什么错吗?

intellij-idea gradle maven-3 maven build.gradle

5
推荐指数
1
解决办法
2861
查看次数

标签 统计

build.gradle ×2

gradle ×2

intellij-idea ×1

maven ×1

maven-3 ×1