I am getting an error build file 'C:\code\release\...
# community-support
a
I am getting an error build file 'C:\code\release\mavenUpload.gradle': 62: unable to resolve class MavenDeployment @ line 62, column 24. beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
v
The class does not exist anymore since Gradle 7.0, so you probably want to use a build that is not compatible with Gradle 7.0 with something newer. That's why builds should always use the Gradle Wrapper.
a
So I updated my gradle script according to version 7.6.1 then I got some other error as below : > No signature of method: java.io.File.call() is applicable for argument types: (mavenUpload_2guwks5x5m4z8dkvkkqsifnma$_run_closure1$_closure3$_closure5$_closure6) values: [mavenUpload_2guwks5x5m4z8dkvkkqsifnma$_run_closure1$_closure3$_closure5$_closure6@55f6a916] Possible solutions: wait(), any(), wait(long), tap(groovy.lang.Closure), any(groovy.lang.Closure), each(groovy.lang.Closure)
This is my new gradle script with 7.6.1 : plugins { id 'maven-publish' id 'signing' } group = "com.abx.xyz" archivesBaseName = "hello-abc" majVer = '0.0' version = "${majVer}.0.1" // Define artifact files def productFile = file("Path of the jar file") def javadocFile = file("path of the doc file") def sourcesFile = file("maven-sources.jar") publishing { publications { mavenJava(MavenPublication) { artifact productFile artifact sourcesFile { classifier "sources" } artifact javadocFile { classifier "javadoc" } pom { name = 'Driver' packaging = 'jar' artifactId = 'xyz' description = 'Description' url = 'url' scm { connection = 'connectionurl' url = 'url' } licenses { license { name = 'License' url = 'url' } } developers { developer { id = 'name' name = 'name' email = 'abc@xyz.com' } } dependencies { dependency { groupId = 'org.xyz' artifactId = 'abc' version = 'X.X.0' } } } } } repositories { maven { url = version.endsWith("SNAPSHOT") ? "https://oss.sonatype.org/content/repositories/snapshots/" : "https://oss.sonatype.org/service/local/staging/deploy/maven2/" credentials { username = ossrhUsername password = ossrhPassword } } } } // Signing the artifacts signing { sign publishing.publications.mavenJava }
v
You somewhere try to do
foo()
with
foo
being a
File
instance
Probably the
Copy code
artifact sourcesFile {
    classifier "sources"
}
a
artifact sourcesFile { archives(file(sourcesFile)) { extension "jar" } classifier "sources" }
v
I strongly recommend switching to Kotlin DSL. By now it is the default DSL, you immediately get type-safe build scripts, actually helpful error messages if you mess up the syntax, and amazingly better IDE support if you use a good IDE like IntelliJ IDEA or Android Studio.
Besides that those manual
artifact
calls are bad practice anyway.
a
So I am using Eclipse IDE
v
If you for example use
Copy code
java {
    withSourcesJar()
    withJavadocJar()
}
and publish
components.java
in the publication, you automatically get tasks for sources and javadoc and proper publishing configuration including proper Gradle Module Metadata.
So I am using Eclipse IDE
Well, poor you. 🙂 You could still use a good IDE for your build scripts though. 🙂
a
okay let me try it with Intellij
v
No idea how good or if at all Eclipse supports Kotlin in the meantime
a
will it help
v
Probably not, you proabably have to do
Copy code
artifact(sourcesFile) {
    classifier "sources"
}
or something like that. But as I said, Groovy DSL is very lenient in what you can write that will fail later and you do not have significant IDE support even with better IDEs. And I'm not often using those bad-practice methods, as you should properly model a component with variants and publish that instead of just pure artifacts.
a
so then it is possible to switch to Kotlin Groovy
as I can't move to Kotlin this time as it required much efforts so I was trying to resolve with Groovy DSL only.