Reputation: 856
I am trying to publish jar file (output of a gradle project) to jfrog/artifactory. The project is successful when I execute gradlew build
or gradlew build artifactoryPublish
. I also see on console that Build successfully deployed. Browse it in Artifactory under https://...
but when I go to Artifactory the nothing is there. I tried following the jfrog/artifactory documentation, some questions on stackoverflow like this one and this one. Following is the snippet from my build.gradle
buildscript {
repositories {
jcenter()
}
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'
allprojects {
apply plugin: "com.jfrog.artifactory"
}
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 sourceJar(type: Jar){
from file("build/libs/mygradle-1.0.0-sources.jar")
classifier = 'sources'
}
task certify(type: Zip, group: 'build', dependsOn: 'build') {
from ("build.gradle")
from ("libs")
from ("src/test")
from ("build/libs")
from ("${buildDir}/reports/tests")
archiveFileName = "certify-resources.zip"
destinationDirectory = file("${buildDir}/certify")
}
version = '1.0.0'
group = 'com.mypro.test' // this is the package prefix the jar will go into artifactory
artifacts {
archives sourceJar
}
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
}
}
}
artifactory {
contextUrl = "${artifactory_contextUrl}" //The base Artifactory URL if not overridden by the publisher/resolver
publish {
repository {
repoKey = 'gradle-release-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
resolve {
repository {
repoKey = 'gradle-dev'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
}
I am not sure what I am missing. Could anyone suggest what I missed. Thanks
EDIT: I created new instance of rhel/artifactory and a new gradle project just to be sure that the issue is not coming from somewhere else but still
only this information Build-info successfully deployed. Browse it in Artifactory under http://100.100.11.11:8081/artifactory/webapp/builds/mygradle/1675035714284
is showing when I execute gradlew build artifactoryPublish
with
BUILD SUCCESSFUL
Upvotes: 1
Views: 3473
Reputation: 6043
The JAR component can be extracted from components.java.
Try to add it to the publication as following:
pluginJar(MavenPublication) {
groupId "${group}"
artifactId 'my-published-project'
version "${version}"
artifact sourceJar
from components.java // <- add this line
}
the java component in its default setup consists of a JAR — produced by the jar task
For more information see Component terminology and Maven publications.
EDIT: Also, since "pluginJar" is not a default publication name, we should add the publication to the list (the plugin adds mavenJava and ivyJava by default).
artifactory {
contextUrl = "${artifactory_contextUrl}" //The base Artifactory URL if not overridden by the publisher/resolver
publish {
repository {
repoKey = 'gradle-release-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
defaults {
publications('pluginJar') // <- add this
}
}
...
}
Upvotes: 1