Publish not picking up version and group

(Willie) #1

So i have this client level plugin

package com.mycompany.Myapp.dir

import com.mycompany.Myapp.core.MyappCorePlugin
import com.mycompany.Myapp.lib.validation.MyappDependsOn
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.bundling.Jar

import static com.mycompany.Myapp.lib.ProjectTaskCreater.addPluginLocal

 * TODO Make sure this project is stand alone.  It can't be a subproject or have subprojects
class MyappDirPlugin implements Plugin<Project> {

    void apply(Project project) {

        addPluginLocal(project, MyappCorePlugin)

        project.with {

            jar {

            publishing.publications {
                dirproj(MavenPublication) {
            def compileConfig = configurations.findByName('compile')
            artifactoryPublish {
                publications << 'dirproj'

            sourceSets {
                main {
                    java {
                        srcDirs = []
                    groovy {
                        srcDirs = []
                    resources {
                        srcDirs = ['src/server_classpath']
                    output.classesDir "$buildDir/dir"
                    output.resourcesDir "$buildDir/dir"

                test {
                    java {
                        srcDirs = []
                    groovy {
                        srcDirs = []
                    resources {
                        srcDirs = []

This particular plugin is supposed to add a folder of property files into the classpath of whatever project and publish them as a zip file.

now, the core plugin at the top implements artifactory and nebula. its VERY basic:

    addPluginAllProjects(project, MavenPublishPlugin)
    addPluginAllProjects(project, MavenPlugin)
    addPluginAllProjects(project, ArtifactoryPlugin)

def retMap = checkArtifactoryActive(project)
if (retMap != null) {
    artifactory {
        publish {
            repository {
                repoKey = retMap[PARAMETER_ARTIFACTORYREPO]
                username = retMap[PARAMETER_ARTIFACTORYUSER]
                password = retMap[PARAMETER_ARTIFACTORYPASS]
                maven = true
            defaults {
                publications ('nebula')
                publishArtifacts = true
                publishPom = true

Now, i keep getting errors stating that it can’t find example.jar. After 4 days of farting around trying different things, i finally opened up the pom file.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xsi:schemaLocation="" xmlns:xsi="">
    <nebula_Built_OS>Windows 7</nebula_Built_OS>
    <nebula_Created_By>1.8.0_66-b17 (Oracle Corporation)</nebula_Created_By>

Notice the group and version are blank? Now, what is different is in my build the group and version are not in the build file, the group comes from our inventory system that the core queries, and the version is passed in as a parameter to the build. Those items are queried and set in an afterEvaluate block in the core plugin. This is the first system that didn’t see it. Can anyone see what im doing wrong?

Initializing project data in the init lifecycle
(Willie) #2

Well, solved part of it. Turns out the publish plugin isn’t change aware. Meaning when my afterEvaluate block executed, none of the other plugins were updated as to the new version. When i wrapped the publishing block in an afterEvaluate, then the version numbers came up. Still doesn’t solve my problem, its still looking for the wrong file, but hey, its a new error which is progress.

I think my inventory system is flawed. How do i specify that a task execute first, no matter what. I don’t care what task is run, clean, info, jar, don’t care. under 100% of circumstances, i want task “validateInventory” to run first, but its useless if the build.gradle file isn’t already parsed. as the inventory lookup tag is in an extension, in the build file. But i can just as easily move that out of the build and into a property file if needed. I think running it first will solve a great deal of problems. So how do i do that?