gpt4 book ai didi

file - 如何将 Artifactory 上传到 Artifactory/在 Artifactory 没有扩展名的构建系统 (Gradle Maven Ant) 中使用它

转载 作者:行者123 更新时间:2023-12-02 16:41:43 27 4
gpt4 key购买 nike

我有以下文件,我想将其作为 9.8.0 版本 Artifactory 上传到 Artifactory。

注意:前两个文件没有扩展名(它们是可执行文件,即如果您打开它们/cat,您将看到垃圾字符)。

CVS 中给定版本 9.8.0 的文件夹/文件如下:

com.company.project/gigaproject/v9.8.0/linux/gigainstallcom.company.project/gigaproject/v9.8.0/solaris/gigainstallcom.company.project/gigaproject/v9.8.0/win32/gigainstall.execom.company.project/gigaproject/v9.8.0/gigafile.dtdcom.company.project/gigaproject/v9.8.0/gigaanotherfile.dtdcom.company.project/gigaproject/v9.8.0/giga.jarcom.company.project/gigaproject/v9.8.0/giga.war

上传上述具有扩展名的文件非常简单...您以有权部署 Artifactory 的管理员/用户身份登录 Artifactory,单击“部署”选项卡,浏览找到 Artifactory 文件,然后选择文件,单击“上传”按钮。

Enter image description here

接下来您将看到一个屏幕(如上所示)。您将在此页面上的字段中调整您想要的内容,一旦单击“部署 Artifactory ”,您就完成了。您只需确保在上传时选择正确的 file.extension 文件,并确保文件扩展名正确显示在“目标路径”框中(版本为 -x.x.x 等) .

我的问题:

问题 1:如何上传没有扩展名的 Artifactory ?看起来 Artifactory 默认情况下将 Artifactory 作为 .jar 扩展名。如何上传 Linux 和 Solaris 上的“gigainstall” Artifactory (如上面的文件夹/文件结构所示)?我发现我可以使用 Artifactory 名称为 gigainstall-linux 和 gigainstall-solaris 并区分它,但我不知道如何告诉 Artifactory 该 Artifactory 没有任何扩展名。

我认为开发团队不会开始生成具有适当扩展的这个 Artifactory (因为这个 Artifactory 可能在其他项目中的任何地方进行硬编码,他们目前从 CVS/SVN 源代码控制的某个地方获取它 - 这本身就是一个在源代码控制版本工具中存储 Artifactory 是不好的做法)。

Enter image description here

问题 2:我如何告诉构建系统(例如 Gradle)在“编译”任务期间使用非扩展 Artifactory 。在 build.gradle 的依赖项 { .. } 部分下,我将添加如下所示的内容,但我不确定非扩展文件(我上面提到的文件夹/文件结构中的前两个)。

dependencies {     //compile 'com.company.project:gigainstall-linux:9.8.0@'     //compile 'com.company.project:gigainstall-linux:9.8.0@??????'     //compile 'com.company.project:gigainstall-linux:9.8.0@""'     //compile 'com.company.project:gigainstall-linux:9.8.0@"none"'     //compile 'com.company.project:gigainstall-linux:9.8.0@"NULL_or_something"'     // The following will easily get giga.jar version giga-9.8.0.jar from Artifactory repository     compile 'com.company.project:giga:9.8.0'     // The following will easily get giga.war     compile 'com.company.project:giga:9.8.0@war'     // Similarly, other extension based artifacts can be fetched from Artifactory     compile 'com.company.project:gigafile:9.8.0@dtd'     compile 'com.company.project:gigaanotherfile:9.8.0@dtd'}

最佳答案

答案 1(将以不同的方式涵盖 2):使用“部署”选项卡下的 Artifactory“Artifact Bundle”功能部分可以实现 AT 的技巧至少以我们想要的方式上传 Artifactory ,首先创建一个 zip 文件(包含其中的结构和 Artifactory )--或者您可以使用/调用 Artifactory REST API上传 Artifactory 方式。

高层想法:

创建一个名为 gigaproject.zip 的 zip 文件或 Artifactory 可以读取的任何名称.zip/.tar/压缩文件。在 zip 内,创建结构 - 如何将这些 Artifactory 加载到 Artifactory

gigaproject.zip 将包含以下文件夹/结构/文件。

情况1:

com/company/project/gigaproject/9.8.0/linux/gigainstallcom/company/project/gigaproject/9.8.0/solaris/gigainstallcom/company/project/gigaproject/9.8.0/win32/gigainstall.execom/company/project/gigaproject/9.8.0/gigafile.dtdcom/company/project/gigaproject/9.8.0/gigaanotherfile.dtdcom/company/project/gigaproject/9.8.0/giga.jarcom/company/project/gigaproject/9.8.0/giga.war

NOTE: In case 1 example, I didn't use any -x.x.x in the filename (i.e. I'm using plain and simple giga.jar instead of giga-9.8.0.jar).

Enter image description here

The above Upload/Deploy will result the files (as shown in the following snapshot):

Enter image description here

So, we have achieved what we wanted. Actually (visibly speaking yes), but not in a way Artifactory usually stores these artifacts (as they should -x.x.x version embedded in the file name and where artifact id should match the artifact filename). Now, if you want to consume the following in a Gradle build file, you CANNOT as first, you haven't uploaded the filename with -x.x.x version name in it, secondly, the artifact id in our case 1 tree was "gigaproject" (after com/company/project folder), so Gradle way of defining what artifact id and what artifact file name you want won't work.

compile 'com.company.project:gigaproject:CANNOTSAY_HOW_TO_GET_GIGA_JARorGIGAINSTALL_with_without_extension'

结论:可以以任何结构上传任何文件(Artifactory 中带/不带扩展名),但这取决于您的构建系统如何使用它或是否能够使用它。- 我从 Artifactory 存储库中删除了刚刚使用案例 1 .zip 文件创建的结构,以尝试下一个案例#2,并删除了我创建的 .zip 文件。

情况2:

让我们为每个 Artifactory 创建一个单独的版本化文件名,并以 Artifactory 实际存储它们的格式创建结构(在 TreeView 中的存储库中看到的 Artifactory ),并创建一个包含该结构的 .zip 文件。让我们使用相同的“Artifact Bundle”功能来上传此 .zip 文件,以上传 Artifactory 中所需的各个 Artifactory - 其中artifact-id(我们在尝试使用它时提到的第二个值)将与 Artifactory 中的artifactfile 名称相匹配。

.zip 文件的文件夹/文件结构:

com/company/project/gigainstall/9.8.0/gigainstall-9.8.0.linuxcom/company/project/gigainstall/9.8.0/gigainstall-9.8.0.solariscom/company/project/gigainstall/9.8.0/gigainstall-9.8.0.execom/company/project/gigafile/9.8.0/gigafile-9.8.0.dtdcom/company/project/gigaanotherfile/9.8.0/gigaanotherfile-9.8.0.dtdcom/company/project/giga/9.8.0/giga-9.8.0.jarcom/company/project/giga/9.8.0/giga-9.8.0.war

NOTE: This time, we'll be using the same "Artifact Bundle" feature and for similar files (gigainstall under both Linux/Solaris folders), I took the approach of creating gigainstall folder (containing gigainstall-9.8.0.linux and gigainstall-9.8.0.solaris file names) i.e. when we'll consume these artifacts in Gradle under dependencies { ... } section for compile, we'll use x.x.x@ way to fetch these artifacts from Artifactory.

Enter image description here

OK, once "Artifact Bundle" Deploy/Upload was successfully complete, I got the following message.

Successfully deployed 7 artifacts from archive: gigaproject.zip (1 seconds).

Now, let's see how it looks like in Artifactory while searching for one of the artifact/in Tree view. You can see we have the files now in place, with filename-x.x.x.extension way so that I can consume them easily in Gradle.

In Gradle build file (build.gradle), I'll mention:

dependencies {  compile "com.company.project:gigainstall:9.8.0@linux"  compile "com.company.project:gigainstall:9.8.0@solaris"  compile "com.company.project:gigainstall:9.8.0@linux"  compile "com.company.project:giga:9.8.0  compile "com.company.project:giga:9.8.0@war  compile "com.company.project:gigafile:9.8.0@dtd  compile "com.company.project:gigaanotherfile:9.8.0@dtd}


OH OH!! - That didn't work, see below for Gradle error. Why? - Artifactory Bundle upload/deploy feature uploads a zip file content what you have in the .zip but it DOES NOT create a .pom file per artifact it deploys. Thus, making the Gradle build to fail. May be in Ant this might succeed. This occurred for each individual .jar/.war/.dtd/etc file. I'm just showing one error example.

While doing gradle clean build

Could not resolve all dependencies for configuration ':compile'.
> Could not resolve com.company.project:gigafile:0.0.0.
Required by:
com.company.project:ABCProjectWhichConsumesGIGAProjectArtifacts:1.64.0
> Could not GET 'http://artifactoryserver:8081/artifactory/ext-snapshot-local/com/company/project/gigafile/0.0.0/gigafile-0.0.0.pom'. Received status code 409 from server: Conflict

案例 3:我们采用一种简单的方法(解决方法,但会减少很多麻烦)。创建具有以下结构的 gigaproject.zip 文件,此方法采用 - 文件夹/文件结构中的各个 Artifactory/文件名中没有嵌入 x.x.x 版本值。我们将使用“Single Artifact”方法(这将在 Artifactory 提供的上传/部署过程中自动创建 gigaproject.zip 文件的 .pom)。使用这种方法,您仍然可以获得 gigainstall 文件,而无需对其名称进行任何扩展。在上传/部署步骤中,正如您已经看到的,您上传 gigaproject.zip,artifactory 会将其上传到给定的目标存储库,格式为“gigaproject-x.x.x.zip”,其中 x.x.x 9.8.0。请参阅下面的图像快照。

gigaproject/linux/gigainstallgigaproject/solaris/gigainstallgigaproject/win32/gigainstall.exegigaproject/gigafile.dtdgigaproject/gigaanotherfile.dtdgigaproject/gigaproject.zipgigaproject/giga.jargigaproject/giga.war

Now, upload it in Artifactory using "Single Artifact" feature. Click "Deploy Artifact" once you tweak the values for GroupId, ArtifactId, Version, etc.

Enter image description here

Enter image description here

Once this is uploaded. You'll see in the zip artifact in the target repository (I took a bad example, usually this would be libs-snapshot-local or libs-release-local instead of ext-...), you'll be able to consume the ZIP artifact directly in Graddle:

dependencies {
// This is the only line we need now.
compile "com.company.project:gigaproject:9.8.0@zip"
}

一旦 .zip 可用于 Gradle 构建系统,现在您可以告诉 Gradle 在构建/工作空间区域中的某个位置解压此 .zip 文件,您可以在其中提供实际(解压的)文件(gigainstall、.dtd、.jar) 、.war 等)到构建过程/步骤。

PS:我猜案例 1 和 2 也适用于 Ant。



答案2:如果您以任一方式上传了非扩展文件。确保您也手动创建/上传了其 POM 文件(即,如果我将 gigainstall-9.8.0 作为 Artifactory 上传到 com/company/project/gigainstall/9.8.0/gigainstall-9.8.0,然后在同一级别,我必须/应该创建它的 POM 文件(请参阅自定义 jar Artifactory 的简单模板 .pom 文件,或者在通过“单个 Artifactory ”部署上传扩展文件时,您会看到什么POM 编辑器窗口显示)并上传两者,这样 Gradle 就不会错误地指出没有 POM 冲突/错误。Ant 可能不需要 pom(我没有检查)。

一旦它出现在 Artifactory 中,以下行应该可以工作 - 或者如果您找到其他方法,请发表评论。

dependencies {
// See nothing mentioned after - x.x.x@
compile "com.company.package:gigainstall:9.8.0@"
}

关于file - 如何将 Artifactory 上传到 Artifactory/在 Artifactory 没有扩展名的构建系统 (Gradle Maven Ant) 中使用它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24536706/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com