Upgrade to gradle7 from 6.8.3

Hello,

I am upgrading from gradle 6.8.3 to gradle 7.
I am finding issues in translating the mavenLocalPublishing task in build.gradle with multiple artifacts.

in 6.8.3 - this was working

if (project.hasProperty(‘repositoryBaseURL’)) {
uploadArchives {
repositories {
mavenDeployer {
//Repository details defined in ~/.gradle/gradle.properties
repository(url: repositoryBaseURL + repositoryRelPath ) {
authentication(userName: repositoryPublishUser, password: repositoryPublishPassword)
}
addFilter(‘X’) {artifact, file → artifact.name == ‘X’}
addFilter(‘Y’) {artifact, file → artifact.name == ‘Y’}
addFilter(‘P’) {artifact, file → artifact.name == ‘P’}
addFilter(‘R’) {artifact, file → artifact.name == ‘R’}

			pom('X').version = projectVersion
			pom('Y').version = projectVersion
			pom('P').version = projectVersion
			pom('R').version = projectVersion
			setUniqueVersion(false)
		}
	}
}

}

How do I get this to gradle 7? Can someone help out please?

Thanks
Surya

The maven plugin and uploadArchives task are deprecated since quite some time and replaced by the maven-publish plugin.
Now finally they were removed: Gradle User Manual: Version 7.0
Use the maven-publish plugin instead.

Thank you for the reply.
Yes, I am trying to replace the depracated stuff and trying to rebuild.
I am now stuck at the publishing task

task publishToLocalRepo (type : Upload) {
configuration = configurations.archives
publishing {
repositories {
maven {
url project.snapshotRepoUrl
}
}

publications {
    maven(MavenPublication) {
   
            artifact jar // returns say a.jar
    }
    Y(MavenPublication) {
            artifact YJar
    }
    Z(MavenPublication) {
            artifact ZJar
    }
    P(MavenPublication) {
            artifact Pjar
    }

}

}
}

Currently problem is - all published artefacts have same name a.jar , a-1.jar , a-2.jar and a-3.jar and al of them are existing in the same directly as a.jar but I would want the jar and pom to move to separate directories each for the jar. Could you please help me achieve that?

Thanks
Srikanth

You replaced the maven plugin and uploadArchives task (which was of type Upload with a custom task of type Upload instead of using the maven-publish plugin as I recommended.

I tried to change this to -

publishing {
repositories {
maven {
url project.snapshotRepoUrl
}
}

publications {
    maven(MavenPublication) {
    //      from components.java
    jar(MavenPublication) {
            artifact jar

    }
    i18n(MavenPublication) {
            artifact i18nJar
    }
    test(MavenPublication) {
            artifact testJar
    }
    doc(MavenPublication) {
            artifact docJar
    }

}

}
}

but i get - No signature of method: build_…publishing() is a…applicable for argument types: a(build_…_run_closure30) values: [build_..._run_closure30@…]