build.gradle - error deploying artifact - maven

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

Related

why doesn't the gradle repository definition work?

I'm at a loss why gradle is ignoring the 'repository' section of a pretty simple build.gradle file. We're behind a firewall, using a JFrog repository to use our own scanned versions of things, not Maven central. When I run 'gradle compile', I get:
FAILURE: Build failed with an exception.
Where:
Build file '/Users/exampleuser/src/example/tlp-platform-portal/build.gradle' line: 2
What went wrong:
Plugin [id: 'org.springframework.boot', version: '2.6.3'] was not found in any of the following sources:
Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
Plugin Repositories (could not resolve plugin artifact 'org.springframework.boot:org.springframework.boot.gradle.plugin:2.6.3')
Searched in the following repositories:
Gradle Central Plugin Repository
But my build.gradle has no mention of Gradle central; the file looks like the attached.
--------build.gradle---------------------
id 'org.springframework.boot' version '2.6.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'war'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
maven {
url 'https://example.jfrog.io/artifactory/penalty-maven-local'
credentials {
username = System.getenv('ARTIFACT_USERNAME')
password = System.getenv('ARTIFACT_PASSWORD')
}
}
maven {
url 'https://example.jfrog.io/artifactory/dha-gradle-plugin-remote-cache'
credentials {
username = System.getenv('ARTIFACT_USERNAME')
password = System.getenv('ARTIFACT_PASSWORD')
}
}
maven {
url 'https://example.jfrog.io/artifactory/plugins-release'
credentials {
username =System.getenv('ARTIFACT_USERNAME')
password =System.getenv('ARTIFACT_PASSWORD')
}
}
maven {
url "https://example.jfrog.io/example/libs-snapshot"
credentials {
username = System.getenv('ARTIFACT_USERNAME')
password = System.getenv('ARTIFACT_PASSWORD')
}
}
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
(lots more)
Repositories for plugins resolution must be configured in the settings.gradle file, see detailed explanation why to use custom/private repositories here : https://docs.gradle.org/current/userguide/plugins.html#sec:custom_plugin_repositories

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.

quarkus gradle test not executed

I'am trying the quarkus getting-started project. With maven the contained unittest is executed. Then I tried the proposed gradle build file, because we use gradle instead of maven. When I run gradle test, the unittest is definitivly not executed (I know, because I modified it to fail).
apply plugin: 'java'
apply plugin: 'io.quarkus.gradle.plugin'
buildscript {
repositories {
mavenCentral()
maven {
//this is temporary, all dependencies should be in central soon
url 'http://repository.jboss.org/nexus/content/groups/public'
}
}
dependencies {
classpath 'io.quarkus:quarkus-gradle-plugin:0.11.0'
}
}
repositories {
mavenCentral()
maven {
url 'http://repository.jboss.org/nexus/content/groups/public'
}
}
dependencies {
compileOnly group: 'io.quarkus', name: 'quarkus-resteasy', version:'0.11.0'
testCompile group: 'io.quarkus', name: 'quarkus-junit5', version:'0.11.0'
testCompile group: 'io.rest-assured', name: 'rest-assured', version: '3.3.0'
}
Is this a bug or do I anything wrong?
OK, I found the problem. Gradle does not use JUnit5 out of the box. You have to add the following to the build.gradle to get gradle starting the tests:
test {
useJUnitPlatform()
}

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.

Fail to upload jar file to jcenter: 405 code

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?

Resources