Simon
10/02/2023, 9:56 AMimport java.util.jar.JarFile
import org.yaml.snakeyaml.Yaml
apply plugin: 'java'
apply plugin: 'groovy'
// apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
buildscript {
dependencies{
classpath("org.yaml:snakeyaml:2.0")
}
repositories {
maven {
url '<https://jfrog.rosenvold.tech/artifactory/plugins>'
credentials {
username = "admin" // Artifactory username
password = "" // Artifactory password
}
}
mavenCentral()
}
// dependencies { classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.5.4" }
}
buildscript {
repositories {
maven {
url '<https://plugins.gradle.org/m2/>'
}
}
dependencies {
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:5.1.9'
}
}
repositories {
mavenCentral()
mavenLocal()
}
artifactory {
contextUrl = "<https://jfrog.rosenvold.tech/artifactory>"
publish {
repository {
repoKey = 'plugins'
username = "admin" // Artifactory username
password = "" // Artifactory password
// maven = true
}
defaults {
publications('mavenJava')
}
// publishBuildInfo = true
}
}
ext.filesToPublish = []
ext.dir= new File("_plugins")
def files = ext.dir.list().findAll { it.endsWith('.jar') }
files.each {
ext.filesToPublish << new File(ext.dir, it)
}
println(filesToPublish.toString())
publishing {
publications {
for ( f in filesToPublish ) {
def jarFile = new JarFile(f)
def pluginYml = (jarFile.getEntry("plugin.yml") != null) ? jarFile.getEntry("plugin.yml") : jarFile.getEntry("bungee.yml")
if (pluginYml != null) {
def yaml = new Yaml()
def plugin = yaml.load(jarFile.getInputStream(pluginYml))
def ARTIFACT_ID = plugin.name
def ARTIFACT_VERSION = plugin.version.toString()
if(ARTIFACT_VERSION.contains(" ")) {
ARTIFACT_VERSION = ARTIFACT_VERSION.replace(" ", "-")
}
def ARTIFACT_GROUP = plugin.name
def pomFileName = "${ARTIFACT_ID}-${ARTIFACT_VERSION}.pom"
def artifactPath = "${ARTIFACT_GROUP.replace(".", "/")}/${ARTIFACT_ID}/${ARTIFACT_VERSION}/${pomFileName}"
def repositoryUrl = "<https://jfrog.rosenvold.tech/artifactory/plugins/>"+"${artifactPath}"
println("# searching for existing artifact with name ${ARTIFACT_ID} version ${ARTIFACT_VERSION}")
println("# URL: ${repositoryUrl}")
println("")
// if (urlExists(repositoryUrl)) {
// println("Artifact with version $ARTIFACT_VERSION already exist - increase the version to publish")
// } else {
// println("# No existing artifact found. Preceding to publish")
// println("")
mavenJava(MavenPublication) {
artifact f
groupId ARTIFACT_GROUP
artifactId ARTIFACT_ID
version ARTIFACT_VERSION
println("Published $ARTIFACT_ID")
}
}
}
// mavenJava(MavenPublication) {
// from components.java
// // Specify the JAR file to include in the publication
// artifact(file("_plugins/GadgetsMenu-5.9.0.jar"))
// // Define other publication details (groupId, artifactId, version, etc.)
// groupId = 'group'
// artifactId = 'test'
// version = '1.0.1'
// }
}
}
When I use the command gradle artifactoryPublish --info
I get the following output. It successfully finds jar files in my _plugins
folder but only the last jar (GadgetsMenu-5.9.0.jar) is published.
coder@coder-fuglen-fuglen-dev:~/TFB-Network$ gradle artifactoryPublish --info
Initialized native services in: /home/coder/.gradle/native
Initialized jansi services in: /home/coder/.gradle/native
The client will now receive all logging from the daemon (pid: 1658). The daemon log file: /home/coder/.gradle/daemon/7.3/daemon-1658.out.log
Starting 3rd build in daemon [uptime: 1 mins 53.768 secs, performance: 100%, non-heap usage: 21% of 256 MiB]
Using 4 worker leases.
Not watching /home/coder/TFB-Network since the file system is not supported
Watching the file system is configured to be enabled if available
File system watching is active
Starting Build
Settings evaluated using settings file '/home/coder/TFB-Network/settings.gradle'.
Projects loaded. Root project using build file '/home/coder/TFB-Network/build.gradle'.
Included projects: [root project 'TFB-Network']
> Configure project :
Evaluating root project 'TFB-Network' using build file '/home/coder/TFB-Network/build.gradle'.
[_plugins/GSit-1.4.10.jar, _plugins/HexNicks-3.1.1.jar, _plugins/GadgetsMenu-5.9.0.jar]
# searching for existing artifact with name GSit version 1.4.10
# URL: <https://jfrog.rosenvold.tech/artifactory/plugins/GSit/GSit/1.4.10/GSit-1.4.10.pom>
Published GSit
# searching for existing artifact with name HexNicks version 3.1.1
# URL: <https://jfrog.rosenvold.tech/artifactory/plugins/HexNicks/HexNicks/3.1.1/HexNicks-3.1.1.pom>
Published HexNicks
# searching for existing artifact with name GadgetsMenu version 5.9.0
# URL: <https://jfrog.rosenvold.tech/artifactory/plugins/GadgetsMenu/GadgetsMenu/5.9.0/GadgetsMenu-5.9.0.pom>
Published GadgetsMenu
All projects evaluated.
Selected primary task 'artifactoryPublish' from project :
Tasks to be executed: [task ':generatePomFileForMavenJavaPublication', task ':artifactoryPublish', task ':extractModuleInfo', task ':artifactoryDeploy']
Tasks that were excluded: []
:generatePomFileForMavenJavaPublication (Thread[Execution worker for ':',5,main]) started.
> Task :generatePomFileForMavenJavaPublication
Caching disabled for task ':generatePomFileForMavenJavaPublication' because:
Build cache is disabled
Task ':generatePomFileForMavenJavaPublication' is not up-to-date because:
Task.upToDateWhen is false.
:generatePomFileForMavenJavaPublication (Thread[Execution worker for ':',5,main]) completed. Took 0.012 secs.
:artifactoryPublish (Thread[Execution worker for ':',5,main]) started.
> Task :artifactoryPublish
Caching disabled for task ':artifactoryPublish' because:
Build cache is disabled
Task ':artifactoryPublish' is not up-to-date because:
Task has not declared any outputs despite executing actions.
Collecting deployment details in task ':artifactoryPublish'
:artifactoryPublish (Thread[Execution worker for ':',5,main]) completed. Took 0.041 secs.
:extractModuleInfo (Thread[Execution worker for ':',5,main]) started.
> Task :extractModuleInfo
Caching disabled for task ':extractModuleInfo' because:
Build cache is disabled
Task ':extractModuleInfo' is not up-to-date because:
Task.upToDateWhen is false.
Extracting details for :extractModuleInfo
Artifacts for configuration 'annotationProcessor' were not all resolved, skipping
Artifacts for configuration 'apiElements' were not all resolved, skipping
Artifacts for configuration 'archives' were not all resolved, skipping
Artifacts for configuration 'compileClasspath' were not all resolved, skipping
Artifacts for configuration 'compileOnly' were not all resolved, skipping
Artifacts for configuration 'default' were not all resolved, skipping
Artifacts for configuration 'implementation' were not all resolved, skipping
Artifacts for configuration 'runtimeClasspath' were not all resolved, skipping
Artifacts for configuration 'runtimeElements' were not all resolved, skipping
Artifacts for configuration 'runtimeOnly' were not all resolved, skipping
Artifacts for configuration 'testAnnotationProcessor' were not all resolved, skipping
Artifacts for configuration 'testCompileClasspath' were not all resolved, skipping
Artifacts for configuration 'testCompileOnly' were not all resolved, skipping
Artifacts for configuration 'testImplementation' were not all resolved, skipping
Artifacts for configuration 'testRuntimeClasspath' were not all resolved, skipping
Artifacts for configuration 'testRuntimeOnly' were not all resolved, skipping
:extractModuleInfo (Thread[Execution worker for ':',5,main]) completed. Took 0.005 secs.
:artifactoryDeploy (Thread[Execution worker for ':',5,main]) started.
[pool-3-thread-1] Deploying artifact: <https://jfrog.rosenvold.tech/artifactory/plugins/GadgetsMenu/GadgetsMenu/5.9.0/GadgetsMenu-5.9.0.jar>
[pool-3-thread-1] Deploying artifact: <https://jfrog.rosenvold.tech/artifactory/plugins/GadgetsMenu/GadgetsMenu/5.9.0/GadgetsMenu-5.9.0.pom>
> Task :artifactoryDeploy
Caching disabled for task ':artifactoryDeploy' because:
Build cache is disabled
Task ':artifactoryDeploy' is not up-to-date because:
Task has not declared any outputs despite executing actions.
Deploying build info...
Build-info successfully deployed. Browse it in Artifactory under <https://jfrog.rosenvold.tech/artifactory/webapp/builds/TFB-Network/1696238344028>
:artifactoryDeploy (Thread[Execution worker for ':',5,main]) completed. Took 0.096 secs.
BUILD SUCCESSFUL in 671ms
4 actionable tasks: 4 executed
Some of the file system contents retained in the virtual file system are on file systems that Gradle doesn't support watching. The relevant state was discarded to ensure changes to these locations are properly detected. You can override this by explicitly enabling file system watching.