Fail to upload jar file to jcenter: 405 code - gradle

I have the following build.gradle file:
apply plugin:'java'
apply plugin:'groovy'
apply plugin:'eclipse'
apply plugin:'maven'
configurations {
deployerJars
}
repositories{
jcenter()
mavenCentral()
}
version '0.1.2'
group 'io.example'
dependencies{
implementation 'org.codehaus.groovy:groovy-all:2.4.10'
testImplementation 'org.spockframework:spock-core:1.0-groovy-2.4'
}
dependencies{
deployerJars "org.apache.maven.wagon:wagon-http:2.2"
}
uploadArchives {
repositories.mavenDeployer {
configuration = configurations.deployerJars
repository( url:'https://my-private-repo.bintray.com' ){
authentication userName:'myName', password:'secret' }
}
}
If I run the task, I'm getting an exception:
Execution failed for task ':uploadArchives'.
Could not publish configuration 'archives'
Failed to deploy artifacts: Could not transfer artifact ...... Return code is: 405, ReasonPhrase: Method Not Allowed.
I tried using maven-publish plugin with no luck either.
What am I missing?

Related

Getting 401 Unauthorized during Gradle build for Atlassian Renderer library

I think by Gradle build problem is related to this Spring article about Spring Artifactory instance repo.spring.io permissions. Pls help me correct my build.gradle which has started failing recently after upgrading to Gradle 5.0.
Snippet from build.gradle
buildscript {
ext {
springBootVersion = SPRING_BOOT_VERSION
}
repositories {
mavenCentral()
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath('se.transmode.gradle:gradle-docker:1.2')
}
}
apply plugin: 'java'
repositories {
mavenCentral()
maven {
url 'https://repo.spring.io/libs-milestone'
}
maven { url "https://packages.atlassian.com/maven/repository/public" }
}
dependencies {
compile (group: 'com.atlassian.renderer', name: 'atlassian-renderer', version:'8.0.5') {
exclude(module: 'servlet-api')
exclude(module: 'radeox')
// https://mvnrepository.com/artifact/javax.activation/activation
compile group: 'javax.activation', name: 'activation', version: '1.1.1'
}
}
The error i get is
> Could not resolve com.atlassian.renderer:atlassian-renderer:8.0.5.
> Could not get resource 'https://repo.spring.io/libs-milestone/com/atlassian/renderer/atlassian-renderer/8.0.5/atlassian-renderer-8.0.5.pom'.
> Could not HEAD 'https://repo.spring.io/libs-milestone/com/atlassian/renderer/atlassian-renderer/8.0.5/atlassian-renderer-8.0.5.pom'. Received status code 401 from server: Unauthorized
Please help.
I added jCenter in the repositories in build.gradle and it worked for me.
jcenter()
I think the atlassian-renderer is no longer available with maven repo.

Plugin with id 'com.github.spotbugs' not found

I'm configuring SpotBugs plugin for a Gradle project for the first time.
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:1.6.6'
}
}
apply plugin: 'com.github.spotbugs'
When running gradle check I'm getting error Plugin with id 'com.github.spotbugs' not found. What am I doing wrong?
Gradle version 5.0.

Could not configure Gradle project (Kotlin code)

I am a pretty fresh in Gradle. I'm trying to build up a project Kotlin code with Gradle.
I have spent some time to learn that by following these instructions: https://kotlinlang.org/docs/reference/using-gradle.html
And so far, I have not succeeded in it and got some errors.
My build.gradle is shown below:
group = "kotlin"
version = "1.0-SNAPSHOT"
buildscript {
ext.kotlin_version = '1.2.50'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: "kotlin"
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
And I got the following error
org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':classpath'.
....
Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.50.

Not able to integrate testng with gradle. Error while building jar

I am new to gradle. Trying to integrate the testNG with Gradle and want to create jar file using "gradle build" command
This is how my build.gradle looks like
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = 1.5
version = '1.0'
jar {
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart',
'Implementation-Version': version,
'Main-Class': 'org.testng.TestNG'
}
}
repositories {
mavenCentral()
}
dependencies {
testCompile 'org.testng:testng:6.9.10'
}
test {
useTestNG(){
include '**/*'
}
}
uploadArchives {
repositories {
flatDir {
dirs 'repos'
}
}
}
However when I run the "gradle build" command I am getting following error for each testNG annotation
: error: cannot find symbol
#Test
^
Symbol: class Test
Location: class helloWorld

build.gradle - error deploying artifact

I'm having issues with publishing to local nexus maven repository.
I admit, I don't have much experience with using gradle.
I will say that I have tried understanding the documentation and examples that are given through the gradle website (along with a few stackoverflow questions).
I am getting the following error when I try to publish:
Execution failed for task ':publishMavenPublicationToMavenRepository'.
> Failed to publish publication 'maven' to repository 'maven'
> Error deploying artifact 'com.myproject:myproject-sdk:jar': Error deploying artifact: Resource to deploy not found: File: http://git.site.com:8081/nexus/content/repositories/releases/com/myproject/myproject-sdk/3.0.0/myproject-sdk-3.0.0.jar does not exist
the entire build.gradle file looks like this:
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'build-version'
buildscript {
repositories {
maven { url "http://git.site.com:8081/nexus/content/groups/public" }
maven { url 'https://geonet.artifactoryonline.com/geonet/public-releases' }
mavenCentral()
}
dependencies {
classpath 'nz.org.geonet:gradle-build-version-plugin:1.+'
}
}
repositories {
maven {
url "http://git.site.com:8081/nexus/content/groups/public"
}
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
compile 'com.google.code.gson:gson:2.2.4'
compile 'commons-codec:commons-codec:1.9'
}
task sourceJar(type: Jar) {
from sourceSets.main.allJava
}
publishing {
publications {
maven(MavenPublication) {
artifactId = 'myproject-sdk'
groupId = 'com.myproject'
version '3.0.0'
from components.java
artifact sourceJar {
classifier "sources"
}
}
}
repositories {
maven {
// nexus maven credentials
credentials {
username "MY_USERNAME"
password ""MY_PASSWORD"
}
if(version.endsWith('-SNAPSHOT')) {
url "http://git.site.com:8081/nexus/content/repositories/snapshots"
} else {
url "http://git.site.com:8081/nexus/content/repositories/releases"
}
}
}
}
I am using Android Studio and this project is a Java project.
I don't understand the message because it says "Resource to deploy not found" and it points to a url at nexus.
I would expect a message like "Resource to deploy not found: File: c:/directory_that_doesn't_exist/whatever.jar"
Additional Information -
The gradle tasks listed under 'All tasks' are:
assemble
build
buildDependents
buildNeeded
check
classes
clean
compileJava
compileTestJava
generatePomFileForMavenPublication
jar
javadoc
processResources
processTestResources
publish
publishMavenPublicationToMavenLocal
publishMavenPublicationToMavenRepository
publishToMavenLocal
sourceJar
test
testClasses

Resources