Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle Artifactory publication error

I'm new working with Gradle and Artifactory and I used an example that is not working correctly from this example site I have this error message:

Extension of type 'PublishingExtension' does not exist. Currently registered extension types: [DefaultExtraPropert iesExtension, DefaultArtifactPublicationSet_Decorated, ReportingExtension_Decorated, DefaultProjectComponentContai ner_Decorated, DefaultProjectSourceSet_Decorated, DefaultBinaryContainer_Decorated]

I have an error in this line:

defaults{
    publications ('mavenJava')
}

Some one could help me with this I have been stuck in this issue for so long.

After reviewing the links as JBaruch recommended and compare with the code I changed the plugin but still the same problem. Maybe I'm confusing something? (That is why I will post the whole source code)

buildscript {
    repositories {
        maven {
            url 'http://.../artifactory/libs-release'
            credentials {
                username = "${artifactory_user}"
                password = "${artifactory_password}"
            }
            name = "maven-main-cache"
        }
    }
    dependencies {
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.0.1"
    }
}

apply plugin: 'scala'
apply plugin: 'maven-publish'
apply plugin: "com.jfrog.artifactory"

version = '1.0.0-SNAPSHOT'
group = 'com.buransky'

repositories {
    add buildscript.repositories.getByName("maven-main-cache")
}

dependencies {
    compile 'org.scala-lang:scala-library:2.11.2'
}

tasks.withType(ScalaCompile) {
    scalaCompileOptions.useAnt = false
}

artifactory {
    contextUrl = "${artifactory_contextUrl}"
    publish {
        repository {
            repoKey = 'libs-snapshot-local'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true

        }
        defaults{
            publications ('mavenJava')
        }
    }
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }
}

Thank you very much

like image 357
Mäū Cárdenas Avatar asked Feb 18 '15 14:02

Mäū Cárdenas


2 Answers

You didn't apply the maven-publish plugin that is expected to be present with artifactory plugin.

Please take a look at the documentation, also this answer might help (note the plugins names change).

like image 171
JBaruch Avatar answered Nov 12 '22 14:11

JBaruch


I lost a lot of time on this since Artifactory docs use outdated Android Studio & gradle plugins versions, so here is my working conf with AS 1.5.1 and gradle 1.5.0 :

global build.gradle

buildscript {
  repositories {
    jcenter()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'
    classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"
  }
}

module build.gradle

apply plugin: 'com.jfrog.artifactory'
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'

publishing{
  publications {
    maven(MavenPublication)  {
        groupId packageName
        version = libraryVersion
        artifactId project.getName()
        artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
    }
  }
}

artifactory {
  contextUrl = // yours
  publish {
    repository {
        // The Artifactory repository key to publish to
        repoKey = 'libs-release-local'
        username = // yours
        password = // yours
    }
    defaults {
        publishArtifacts = true
        publications ('maven')

        // Properties to be attached to the published artifacts.
        properties = ['qa.level': 'basic', 'dev.team': 'core']
        // Publish generated POM files to Artifactory (true by default)
        publishPom = true
    }
  }
}
like image 40
Rémy DAVID Avatar answered Nov 12 '22 15:11

Rémy DAVID