Gradle and Bintray Plugin: Cannot cast _Decorated - java

In attempting to publish my set of plain Java libraries on Bintray using the Gradle Bintray plugin, I got the following error upon running the 'bintrayUpload' task:
Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'task ':bintrayUpload'' with class 'com.jfrog.bintray.gradle.BintrayUploadTask_Decorated' to class 'com.jfrog.bintray.gradle.BintrayUploadTask'
at com.jfrog.bintray.gradle.BintrayUploadTask.getCachedRepositories(BintrayUploadTask.groovy:663)
at com.jfrog.bintray.gradle.BintrayUploadTask_Decorated.getCachedRepositories(Unknown Source)
at com.jfrog.bintray.gradle.BintrayUploadTask.getRepository(BintrayUploadTask.groovy:683)
at com.jfrog.bintray.gradle.BintrayUploadTask.checkPackageAlreadyCreated(BintrayUploadTask.groovy:510)
at com.jfrog.bintray.gradle.BintrayUploadTask$_bintrayUpload_closure5.doCall(BintrayUploadTask.groovy:255)
at com.jfrog.bintray.gradle.BintrayUploadTask$_bintrayUpload_closure5.doCall(BintrayUploadTask.groovy)
at com.jfrog.bintray.gradle.BintrayUploadTask.bintrayUpload(BintrayUploadTask.groovy:470)
The publish tasks work perfectly; it's just the Bintray upload that is failing.
Each library is a submodule in a root project.
The Maven/Bintray part of the Gradle file in one of my submodules looks like this:
//Bintray
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
}
}
def bintrayPropertiesFile = rootProject.file("bintray.properties")
def bintrayProperties = new Properties()
bintrayProperties.load(new FileInputStream(bintrayPropertiesFile))
apply plugin: 'maven-publish'
publishing {
publications {
mavenJava(MavenPublication){
from components.java
groupId bintrayProperties['bintrayRepository']
artifactId project.name
version rootProject.libraryVersion
}
}
}
apply plugin: 'com.jfrog.bintray'
bintray {
user = bintrayProperties['bintrayUser']
key = bintrayProperties['bintrayKey']
publications = ['mavenJava']
pkg {
repo = bintrayProperties['bintrayRepository']
name = project.name
userOrg = bintrayProperties['bintrayOrganization']
licenses = [bintrayProperties['bintrayLicense']]
vcsUrl = bintrayProperties['bintrayVcs']
version {
name = rootProject.libraryVersion
released = new Date()
}
}
}
What am I doing wrong in my Gradle build file? Thanks in advance.

Add the following to your root project's build.gradle:
buildscript {
...
dependencies {
...
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
}
}
apply plugin: 'com.jfrog.bintray'
I would love to be enlightened as to why this fixes it, but it does.

Related

Gradle build error on previously working program

I have a Jave 8, SpringBoot, webService which has been running fine on Eclipse 2020-06 for months. I build using Gradle. In an attempt to get the latest version of an updated jar file from Artifactory I did :
gradlew clean
gradlew eclipse
F5 (Refresh)
This indeed pulled the required jar file but my program now failed to compile. The error is:
The import org.springframework.beans.factory.annotation cannot be resolved
And all my #Autowired commands now error.
What i've tried :
gradlew cleanEclipse eclipse
close project, close eclipse, reopen eclipse, reopen project
gradle -> Refresh Gradle project
Same a 2. preceded by reboot pc. When I do this I get:
After I did:
gradlew cleanEclipse eclipse
The following jar dissapeared from my project:
spring-beans.5.3.0.RC1.jar
This is what is causing the problem.
Is this incorrect in build.gradle:
implementation "org.springframework:spring-beans:5.+"
How do I get this jar back?
Any help appreciated.
My build.gradle file is:
plugins {
id 'org.springframework.boot' version '2.2.2.RELEASE'
id 'java'
}
repositories {
maven {
url "https://repo-int.xxxxxx.io/artifactory/cc-central"
}
maven {
url "https://code.lds.org/nexus/content/groups/main-repo"
}
maven {
url "${chemaxonRepositoryUrl}/libs-release"
credentials {
username = chemaxonRepositoryUser
password = chemaxonRepositoryPassword
}
}
}
ext {
archive_basename = "dcrws"
project_description = "Chemistry Workbench DcrWs"
springStarterVersion = '2.2.2.RELEASE'
// Jenkins/Environment Information
build_tag = System.getenv('BUILD_TAG') ?: "none"
build_by = System.getenv('NODE_NAME') ?: "none"
build_date = System.getenv('BUILD_TIMESTAMP') ?: "none"
build_system = System.getenv('JENKINS_HOME') ?: "none"
build_url = System.getenv('BUILD_URL') ?: "none"
build_user = System.getenv('USER') ?: "none"
}
// standard plugins
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'io.spring.dependency-management'
def git_info = hasProperty('git_info') ? git_info : 'https://git.git/repo,00000000'
def full_version = hasProperty('app_version') ? app_version : '0.0.0'
group = 'com.clarivate.singularity.chemworkbench'
version = full_version
archivesBaseName = ext.archive_basename
sourceCompatibility = 1.8
targetCompatibility = 1.8
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
// if master branch, use latest version of chemcur:cwbcommon, else use 0.0+ version
ext.cwbcommon_version = '1.+'
if ( full_version =~ /^0./) { ext.cwbcommon_version = '0.0+' }
ext.pwbcommon_version = '1.+'
if ( full_version =~ /^0./) { ext.pwbcommon_version = '0.0+' }
dependencies {
implementation "org.springframework.boot:spring-boot-starter-actuator:$springStarterVersion"
implementation "org.springframework.boot:spring-boot-starter-web:$springStarterVersion"
implementation "org.springframework.boot:spring-boot-starter-cache:$springStarterVersion"
implementation "org.springframework.boot:spring-boot-starter-data-jdbc:$springStarterVersion"
implementation "org.springframework.boot:spring-boot-starter-data-jpa:$springStarterVersion"
implementation "org.springframework.boot:spring-boot-starter-tomcat:$springStarterVersion"
implementation 'com.fasterxml.jackson.core:jackson-core:2.+'
implementation "org.springframework:spring-beans:5.+"
implementation "org.springframework:spring-core:5.+"
implementation "javax.servlet:javax.servlet-api:4.+"
implementation "org.apache.commons:commons-lang3:3.9+"
implementation "commons-dbutils:commons-dbutils:1.7+"
implementation "com.oracle:ojdbc6:11.2.0.1.0"
compile 'com.chemaxon:calculations:20.+'
// homegrown libs
compile ("chemcur:cwbcommon:${cwbcommon_version}") {changing = true}
compile ("chemcur:pwbcommon:${pwbcommon_version}") {changing = true}
developmentOnly "org.springframework.boot:spring-boot-devtools:$springStarterVersion"
}
springBoot {
buildInfo {
properties {
artifact = archive_basename
version = full_version
group = group
name = project_description
additional = [
'Implementation-Title': project_description,
'Implementation-Version': full_version,
"Implementation-SCM": git_info,
"Jenkins-Build-Tag": build_tag,
"Build-By": build_by,
"Build-Date": build_date,
"Build-JDK": System.getProperty('java.version'),
"Build-Gradle-Version": project.gradle.gradleVersion,
]
}
}
}

groovy.lang.MissingPropertyException: Could not get unknown property

Caused by: groovy.lang.MissingPropertyException: Could not get unknown
property 'NEXUS_USERNAME' for object of type
org.gradle.api.publication.maven.internal.deployer.DefaultGroovyMavenDeployer.
I do not understand this problem. even though I know his mistake. but I still don't understand how to solve the problem.
this is my Gradle code
apply plugin: 'idea'
apply plugin: 'kotlin'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'org.jetbrains.dokka'
buildscript {
ext.version_kotlin = '1.3.21'
ext.version_dokka = '0.9.17'
ext.version_java_util = '[2.0.1,2.1.0)'
ext.version_slf4j = '[1.7,1.8)'
ext.version_mockito = '[2.8,2.9)'
ext.version_logback = '[1.2,1.3)'
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$version_kotlin"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$version_dokka"
}
}
dokka {
outputFormat = 'html'
outputDirectory = "$projectDir/doc/javadoc"
}
version VERSION
group GROUP
repositories {
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version_kotlin"
api "com.github.michael-rapp:java-util:$version_java_util"
implementation "org.slf4j:slf4j-api:$version_slf4j"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$version_kotlin"
testImplementation "org.mockito:mockito-core:$version_mockito"
testImplementation "ch.qos.logback:logback-classic:$version_logback"
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from tasks.javadoc.destinationDir
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
artifacts {
archives jar
archives javadocJar
archives sourcesJar
}
signing {
required { gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION
repository(url: RELEASE_REPOSITORY_URL) {
authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD)
}
snapshotRepository(url: SNAPSHOT_REPOSITORY_URL) {
authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD)
}
pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL
scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}
licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}
developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
}
}
}
}
}
}
in the section is red " MavenDeployment "
I take raw materials on GitHub. I want to use this application to be able to use APRIORI logic. if anyone can help please comment below. for more details, I also include the address where I downloaded it Link

Signing maven jar with Gradle 5.4.1 results in Could not set unknown property 'keyId'

I'm trying to produce a maven signed jar but if I receive this exception
groovy.lang.MissingPropertyException: Could not set unknown property 'keyId' for object of type org.gradle.plugins.signing.SigningExtension
This is my build.gradle
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
}
apply from: 'gradle.properties'
group 'com.foo'
version '1.0.0'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
// dependencies
}
task sourcesJar(type: Jar) {
archiveClassifier = 'sources'
from sourceSets.main.allJava
}
task javadocJar(type: Jar) {
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
publishing {
publications {
myLibrary(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
}
}
repositories {
maven {
name = 'myRepo'
url = "file://${buildDir}/repo"
}
}
}
signing.keyId='MY_KEY'
signing.password='MY_SECRET'
signing.secretKeyRingFile=/NOT_TO_PUBLISH/secret-keys.gpg
signing {
sign publishing.publications.myLibrary
}
If I comment on the signing sections all works fine and my publications are generated.
Any helps would be appreciated
The documentation has them without quote marks:
signing.keyId=24875D73
signing.password=secret
signing.secretKeyRingFile=/Users/me/.gnupg/secring.gpg
I'm sure you have, but have you tried without quote marks?
The documentation above also contains an alternate way of setting the values, do you get a different response?
allprojects {
ext."signing.keyId" = id
ext."signing.secretKeyRingFile" = file
ext."signing.password" = password
}
Additionally, are you using an up to date version of Gradle (so it properly supports the plugin)?

gradle publish does not include dependencies in pom

When I try to publish artifacts to a personal artifactory repository,
when I look in the repository I notice that the pom that was published does not include the dependencies that the proeject has,
can you please explain what is wrong with my build?
buildscript {
repositories {
jcenter()
}
dependencies {
// Add this line
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.0.1"
}
}
// Apply the java plugin to add support for Java
apply plugin: 'java'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
apply plugin: 'maven'
group 'CaptchaSolving'
version '1.0.0'
sourceCompatibility = 1.5
// In this section you declare where to find the dependencies of your project
repositories {
// Use 'jcenter' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
maven {
url 'https://artifactory.lyoko.pw:443/libs-release-local'
credentials {
username = "${artifactory_username}"
password = "${artifactory_password}"
}
}
}
sourceSets {
main {
java {
srcDir 'src/'
}
}
}
// In this section you declare the dependencies for your production and test code
dependencies {
compile(group: 'com.pragone.custom', name: 'jpHash', version: '1.0.1')
}
task assembleRelease(type: Jar, dependsOn:classes) {
classifier = 'release'
manifest {
attributes 'Implementation-Title': project.group,
'Implementation-Version': version,
'Main-Class': ''
}
baseName = project.name
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
artifacts {
archives assembleRelease
}
def libraryGroupId = group
def libraryArtifactId = rootProject.name
def libraryVersion = version
publishing {
publications {
jar(MavenPublication) {
groupId libraryGroupId
version libraryVersion
artifactId libraryArtifactId
artifact("$buildDir/libs/${artifactId}-${libraryVersion}.jar")
}
}
}
artifactory {
contextUrl = 'https://artifactory.lyoko.pw'
publish {
repository {
repoKey = 'libs-release-local'
username = artifactory_username
password = artifactory_password
}
defaults {
publications('jar')
publishArtifacts = true
properties = ['qa.level': 'basic', 'dev.team': 'core']
publishPom = true
}
}
}
as you can see, there is only one dependency,
and the pom that gets published is:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>CaptchaSolving</groupId>
<artifactId>CaptchaSolving</artifactId>
<version>1.0.0</version>
</project>
(obtained from the view tab at artifactory)
as you can see
it has none of the repositories that I specified.
so I just want the resulting pom to include the repositories and the dependencies this project depends on.
I managed to solve the problem after seeing this post and trying a few things out.
It appears, the block:
publishing {
publications {
jar(MavenPublication) {
groupId libraryGroupId
version libraryVersion
artifactId libraryArtifactId
artifact("$buildDir/libs/${artifactId}-${libraryVersion}.jar")
}
}
}
was missing:
from components.java
so the final solution is:
publishing {
publications {
jar(MavenPublication) {
from components.java
groupId libraryGroupId
version libraryVersion
artifactId libraryArtifactId
artifact("$buildDir/libs/${artifactId}-${libraryVersion}.jar")
}
}
}

How to install or publish submodules of gradle project as a jar

I want to install submodules of my project as jar to maven local repository. I searched a gradle script for publish. I found. But it install only one jar and it has not classes of submodules. How can I proceed?
my-project
|
|__subprj1
| |__src
| |__ com
| |__Abc.java
|
| |__pom.xml
|__subprj2
| |
| |__pom.xml
|
|__ build.gradle
|__ publish.gradle
build.gradle:
apply plugin: "java"
apply from : 'publish.gradle'
ext {
GROUPID = "my-project"
VERSION = "1.0.0"
robovmVersion = "1.5.0"
androidVersion = "4.4"
gwtVersion = "2.6.0"
jglfwVersion = "1.1"
lwjglVersion = "2.9.2"
jlayerVersion = "1.0.1-gdx"
jorbisVersion = "0.0.17"
junitVersion = "4.11"
}
buildscript {
repositories { mavenCentral() }
dependencies {
classpath "com.android.tools.build:gradle:1.2.3"
classpath "org.robovm:robovm-gradle-plugin:1.5.0"
}
}
configure(allprojects - project('...'')) {
apply plugin: "eclipse"
apply plugin: "idea"
apply plugin: "java"
compileJava.options.encoding = 'UTF-8';
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
group = GROUPID
version = VERSION
// set source Java version
sourceCompatibility = 1.6
targetCompatibility = 1.6
sourceSets.main.java.srcDirs = ["src"]
sourceSets.main.resources.srcDirs = ["src"]
// create a custom configuration for local dependencies such as Android runtime
configurations {
optional
compile.extendsFrom optional
}
}
project("...) {
}
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption("Xdoclint:none", "-quiet")
}
}
}
task fetchNatives << {
ant.importBuild "fetch.xml"
fetch.execute()
copy.execute()
}
publish.gradle:
apply plugin: 'maven'
apply plugin: 'signing'
group = 'my-project'
version = '1.0.0'
ext.packaging = 'jar'
def isDevBuild
def isCiBuild
def isReleaseBuild
def sonatypeRepositoryUrl
//set build variables based on build type (release, continuous integration, development)
if(hasProperty("release")) {
...
} else if (hasProperty("snapshot")) {
...
} else {
isDevBuild = true
println "Performing local build"
}
repositories {
mavenCentral()
}
task artifactDocs(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}
task artifactSources(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
artifacts {
archives jar
archives artifactDocs
archives artifactSources
}
if(isReleaseBuild) {
signing {
sign configurations.archives
}
} else {
task signArchives {
// do nothing
}
}
uploadArchives {
repositories {
if (isDevBuild) {
mavenLocal()
}
}
}
First, your submodules must be handled as gradle subprojects. So you have to create build.gradle files for them and include them in the root project via settings.gradle file.
Second, in the build.gradle file of each subproject, you can define your deployment code. To install something in your local maven repository ($HOME/.m2), I use the gradle maven plugin. After configuring it correctly, I run install on this subproject:
gradle subproject1:install
Here an example configuration of such a subproject to install it locally:
apply plugin: 'maven'
...
group = 'com.example.subproject2'
configurations {
deployerJars
}
dependencies {
...
deployerJars "org.apache.maven.wagon:wagon-http:2.2"
}
...
def installer = install.repositories.mavenInstaller

Categories

Resources