我正在尝试将我的gradle项目创建的jar(在build/lib中)文件发布/部署到artifactory。为了简单起见,我安装了一个没有docker的本地artifactory-oss安装。
无法发布项目“:”的pom,因为它不包含Maven插件安装任务,并且任务“:artifactoryPublish”未指定自定义pom路径。
> Task :artifactoryDeploy
Deploying build info...
Build-info successfully deployed. Browse it in Artifactory under http://100.100.11.11:8081/artifactory/webapp/builds/mygradle/1846079453857
我尝试按照jfrog文档和other resources,但它仍然只是推动构建信息。
我的gradle.build如下所示
buildscript {
repositories {
jcenter()
maven {
url 'http://100.100.11.11:8081/artifactory/gradle-release-local'
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
}
dependencies {
//Check for the latest version here: http://plugins.gradle.org/plugin/com.jfrog.artifactory
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"
}
}
plugins {
// Apply the java-library plugin to add support for Java Library
id 'java-library'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
}
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'io.spring.dependency-management'
repositories {
// Use jcenter for resolving dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}
dependencies {
// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:29.0-jre'
// Use JUnit test framework
testImplementation 'junit:junit:4.13'
}
task createPom {
doLast{
pom {
project {
groupId 'edc'
artifactId 'mygradle'
version '1.0.0'
}
}.writeTo("pom.xml")
}
}
allprojects {
apply plugin: 'com.jfrog.artifactory'
group = 'org.jfrog.example.gradle'
version = "4.21.0"
status = "release"
}
configurations {
published
}
def f1 = file("to_deploy.txt")
def f2 = file("build/libs/mygradle-1.0.0-sources.jar")
artifacts {
published file: f1, name: f1.getName(), type: 'txt'
published file: f2, name: f2.getName(), type: 'jar'
}
artifactoryPublish {
skip = false //Skip build info analysis and publishing (false by default)
contextUrl = 'http://100.100.11.11:8081/artifactory'
publications ('ALL_PUBLICATIONS')
clientConfig.publisher.repoKey = 'gradle-release-local'
clientConfig.publisher.username = "${artifactory_user}"
clientConfig.publisher.password = "${artifactory_password}"
}
artifactory {
contextUrl = 'http://100.100.11.11:8081/artifactory'
publish {
repository {
repoKey = 'gradle-release-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
defaults {
publications('ALL_PUBLICATIONS')
publishConfigs('published')
publishBuildInfo = true
publishArtifacts = true
publishPom = true
publishIvy = true
}
}
resolve {
repository {
repoKey = 'maven-remote'
username = "admin"
password = "password"
}
}
}
task sourceJar(type: Jar){
from file("build/libs/mygradle-1.0.0-sources.jar")
}
publishing {
publications {
pluginJar(MavenPublication) {
groupId "${group}"
artifactId 'mygradle' // this is the package suffix the jar will go into in artifactory
version "${version}"
artifact sourceJar
from components.java
}
}
}
我知道在这个build.gradle文件中可能会有一些额外的东西,但我添加这些东西只是为了尝试一下。是否可以在不设置jenkins的情况下将gradle项目发布/部署到artifactory?如果可以,那么我的build.gradle哪里不足?
我知道这是可能的与maven建设项目。因为我已经做到了。
2条答案
按热度按时间ee7vknir1#
关于您的查询,是的,您可以使用JFrog CLI作为替代或另一种方式将Gradle客户端集成到Artifactory应用程序。这将有助于解析依赖关系,部署来自Artifactory的构建工件,并收集将存储在Artifactory中的构建信息。有关此方面的更多详细信息,您可以在此处参考我们的CLI Wiki页面。
unguejic2#
为我修复这个问题的是添加
maven
插件(我以前只有maven-publish
插件):