Publish unique artifacts without using any plugins to compile or jar

How does one publish unique artifacts using ivy? As of now, I converted our old build scripts to gradle and with one of the projects I have a task that creates a bunch of jar files using ant.jar and places them in the libsDir directory. The project is using the Java plugin but only for its configurations and nothing else (as in assembly & build). I tried looking thru the docs and for examples but everything assumes you are using assembly & build. In simplest terms, I compiled and jar without using any built-in plugins or task types, the jar files live in a directory that I place them in and now I want to just publish them using ivy.

I tried creating my own task of type Upload but that depends on compile, which then tries to compile my code in which it is not configured for. I have my own compilation task that is not associated with the Java plugin

Thanks, Jason

If your upload task depends on a compile task, then only because Gradle has inferred an actual dependency between the two tasks (e.g. you are uploading the compilation result). There is no inherent dependency.

As to your original question, see the Publishing Artifacts chapter in the Gradle User Guide, and the samples in the full Gradle distribution. As you can see there, uploading isn’t inherently tied to the Java plugin. Alternatively, you can use the new ‘ivy-publish’ plugin (see Ivy Publishing).

I think I got around my issue…but ran into another one. I did read the docs and the examples in the code…thanks by the way… Here is a generic project setup that I have:

apply plugin: 'java'
  ext {
 projectSrcDir = "${projectDir}/src"
   // Common properties
 buildCommonDir = "${buildDir}/common"
 buildCommonClassesDir = "${buildCommonDir}/classes"
 buildCommonLibDir = "${buildCommonDir}/lib"
 buildCommonDistDir = "${buildCommonDir}/dist"
 commonJarFileName = "my-common.jar"
    buildSource= "1.6"
 buildTarget= "1.6"
}
  sourceSets {
 main {
  java {
   srcDirs = ['src']
  }
 }
}
  libsDirName = 'dist'
  group = 'com.example.gradle'
version = '1.0'
  configurations {
 archives
}
  task commonCompile(description: 'Compiles Common Java classes', type: JavaCompile) {
 def classesDir = new File(buildCommonClassesDir)
 classesDir.mkdirs()
    sourceCompatibility = buildSource
 targetCompatibility = buildTarget
  source = projectSrcDir
 classpath = configurations.compile
 destinationDir = classesDir
}
  task commonJar(description: "Creates the common Jar file", dependsOn: commonCompile, type: Jar) {
 archiveName = commonJarFileName
 destinationDir = new File(buildCommonDistDir)
 from buildCommonClassesDir
}
  compileJava.onlyIf { false }
processResources.onlyIf { false }
classes.onlyIf { false }
jar.onlyIf { false }
  artifacts {
 archives file('build/common/dist/my-common.jar')
 //archives commonJar
}
  task uploadLocal(dependsOn: commonJar, type: Upload) {
 configuration = configurations.archives
 repositories {
  ivy {
   url "${rootProject.buildDir}/repo"
  }
 }
}

My workaround was to use the onlyif actions because the uploadLocal task depends on commonJar & jar. What I didn’t want to do is run the tasks jar,classes,compileJava & processResources. When I run the uploadLocal task, it complains about the following:

Attempted to publish an artifact ‘com.example.gradle#projectExample1;1.0’ that does not exist ‘C:\Users\hambone\Documents\Development\gradle\myGradleExamples\projectExample1\build\dist\projectExample1-1.0.jar’. This behaviour has been deprecated and is scheduled to be removed in Gradle 2.0

I am assuming this is the result of using the Java plugin but how do I get around this warning message or prevent it.

Looks like you don’t need/want to apply the Java plugin anyway.

The only reason I am using the Java Plugin is for its configurations because I have dependencies which I am not showing you. Is there was around the warning message or prevent it from happening?

I’d try not to apply the Java plugin, and to declare any configurations yourself.