如何为本地.m2存储库设置archiveBaseName [英] how to set archiveBaseName for local .m2 repository

查看:223
本文介绍了如何为本地.m2存储库设置archiveBaseName的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将依赖项升级到项目,该依赖项最终将成为我项目的依赖项.我已经进行了升级,并且想在将其发布到要使用的存储库之前在本地进行测试.我正在学习Gradle,一些Google搜索向我展示了如何将项目添加到settings.gradle文件.但是,依赖项项目使用别名作为其依赖项(请参见下面的build.gradle).

I'm trying to upgrade a dependency to a project that will ultimately become a dependency to my project. I've made the upgrade and I want to test it locally before I put it out on the repo to be used. I'm learning Gradle and a few Google searches showed me how to add the project to the settings.gradle file. But the dependency project uses aliases for their dependencies (see build.gradle below).

settings.gradle

include ':TransportImpl'

更改为:

include ':TransportImpl', ':jeromq'
project(':jeromq').projectDir = new File("../zeromq/jeromq")

build.gradle

//project.ext.set("JEROMQ", 'THIRD-PARTY:jeromq:0.4.2')
project.ext.set("JEROMQ", ':jeromq')

如果我取消注释原始行(如上面的注释所示),因为该apk位于回购中,因此它会被识别.我猜想这仅适用于外部库.

If I uncomment the original line (shown commented above), because that apk is in the repo it gets recognized. I'm guessing that this only works for external libraries.

我尝试过的其他事情:

//project.ext.set("JEROMQ", 'C:/Users/username/.m2/repository/THIRD_PARTY/jeromq/0.5.1-SNAPSHOT/jeromq-0.5.1-SNAPSHOT-jeromq.jar')
//project.ext.set("JEROMQ", 'C:\\Users\\username\\.m2\\repository\\THIRD_PARTY\\jeromq\\0.5.1\\jeromq-0.5.1-jeromq.jar')
//implementation filetree(dir: 'C:\\Users\\username\\.m2\\repository\\THIRD_PARTY\\jeromq\\0.5.1', include:['jeromq-0.5.1-jeromq.jar'])

任何人都可以给我一个提示,告诉我如何分配一个指向本地存储库的变量并使用该变量设置archiveBaseName吗?

Can anyone give me a tip on how I can assign a variable that points to the local repository and use that variable to set an archiveBaseName?

新信息:

我们的jeromq项目的gradle.build

gradle.build for our jeromq project

apply plugin : 'maven'
apply plugin : 'maven-publish'

// Top-level build file where you can add configuration options common to all sub-projects/modules.
ext {
    // Nexus paths
    nexusUrl='https://nexus.path'
    Releases='/Private_Releases'

    nexusUsername = project.findProperty("nexusUsername") ?: (System.getenv("NEXUS_USERNAME") ?: "user_name"
    nexusPassword = project.findProperty("nexusPassword") ?: (System.getenv("NEXUS_PASSWORD") ?: "password")

    // Project versions
    jeromqVersion = "0.5.1-SNAPSHOT"
}

allprojects {
    // Read only repositories for dependencies; this should never be used to publish
    repositories {
        mavenCentral()
        jcenter()
    }
}

将其用作依赖项的项目从其build.gradle文件中使用以下内容找到它:

The project that uses it as a dependency finds it using the following from its build.gradle file:

// Create aliases for dependencies
project.ext.set("EASY_MOCK", 'Test:easymock:3.5.1')
project.ext.set("OBJENESIS", 'Test:objenesis:2.6')
// **************** HERE ***************************
// THIRD-PARTY is configured to look on the nexus server
project.ext.set("JEROMQ", 'THIRD-PARTY:jeromq:0.4.2') ... or 0.5.1 or 0.5.1-SNAPSHOT ...

allprojects {
  // Read only repositories for dependencies; this should never be used to publish
  repositories {
    mavenCentral()
    mavenLocal()
//      maven {
//          // trying to add my local repo, 
//          // BUT this still does not change where THIRD-PARTY is pointing to
//          url 'file://C:/Users/me/.m2/repository/THIRD_PARTY/jeromq/0.5.1-SNAPSHOT/jeromq-0.5.1-SNAPSHOT-jeromq.jar'
//      }
    maven {
      name 'ReleasesName'
      url "$nexusUrl$ReleasesName
      }
    }
    maven {
      name 'ReleasesNameSnapshots'
      url "$nexusUrl$ReleasesNameSnapshots"

      credentials {
        username "${rootProject.ext.nexusReadOnlyUsername}"
        password "${rootProject.ext.nexusReadOnlyPassword}"
      }
    }
    jcenter {
      url "https://jcenter.bintray.com/"
    }
  }

我需要该依赖项的别名的唯一原因是因为它已在其他地方使用.

The only reason I need the alias for that dependency is because it is used in other places.

推荐答案

我不确定您要问的是什么,但我认为您要尝试的完全不对.

I'm not entirely sure what you are asking, but I think what you are trying is completely off.

您要包含的构建是Maven构建,而不是Gradle构建,因此您不太可能将其视为Gradle构建来简单对待.

The build you are trying to include is a Maven build, not a Gradle build, so it is unlikely you can simply treat it as it were a Gradle build.

即使这是Gradle构建,像您那样包含它也不是正确的方法.您如何尝试将多项目构建中的多个项目包括在内,而不包括外部库.

And even if it were a Gradle build, including it like you did would not be the right way. How you tried it is for including multiple projects of a multi-project build, not including external libraries.

如果它是Gradle构建,则将使用复合构建,该复合构建将有效声明的二进制依赖项替换为子构建"的构建输出.但这公平地仅与Gradle构建完全兼容.

If it were a Gradle build, you would use a composite build, which effectively replaces a declared binary dependency by the build output of a "sub-build". But afair this only works cleanly with a Gradle build.

为什么不简单地mvn install修改后的jeromq版本,将mavenLocal()添加到依赖项中,并依赖于刚刚安装的版本?这将是本地测试新的Maven构建的依赖关系的常用方法.

Why don't you simply mvn install your modified jeromq version, add mavenLocal() to your dependencies and depend on that just installed version? That would be the usual way for locally testing new Maven built dependencies.

这篇关于如何为本地.m2存储库设置archiveBaseName的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆