@@ -78,26 +78,34 @@ publishing {
7878
7979// Force checksum generation
8080// Generate checksums after publishing
81- tasks. register(' generateChecksums' ) {
81+ // Generate checksums and cleanup maven metadata after publishing
82+ tasks. register(' generateChecksumsAndCleanup' ) {
8283 dependsOn ' publishMavenPublicationToMavenLocal'
8384
8485 doLast {
85- // Get the local maven repository path
8686 def userHome = System . getProperty(' user.home' )
8787 def localRepoPath = " ${ userHome} /.m2/repository"
8888 def groupPath = project. group. toString(). replace(' .' , ' /' )
8989 def artifactDir = new File (" ${ localRepoPath} /${ groupPath} /${ project.name} /${ project.version} " )
90+ def artifactParentDir = new File (" ${ localRepoPath} /${ groupPath} /${ project.name} " )
9091
91- println " Generating checksums in: ${ artifactDir.absolutePath} "
92+ println " Processing ${ project.name } in: ${ artifactDir.absolutePath} "
9293
9394 if (artifactDir. exists()) {
95+ // Generate checksums for all relevant files
9496 artifactDir. listFiles(). findAll { file ->
9597 file. isFile() &&
96- (file. name. endsWith(' .jar' ) || file. name. endsWith(' .pom' )) &&
97- ! file. name. contains(' maven-metadata' )
98+ (file. name. endsWith(' .jar' ) || file. name. endsWith(' .pom' ) || file. name. endsWith(' .module' )) &&
99+ ! file. name. contains(' maven-metadata' ) &&
100+ ! file. name. endsWith(' .asc' ) && // Skip signature files
101+ ! file. name. endsWith(' .md5' ) && // Skip existing checksums
102+ ! file. name. endsWith(' .sha1' ) // Skip existing checksums
98103 }. each { file ->
99104 generateChecksumsFor(file)
100105 }
106+
107+ // Clean up maven-metadata-local.xml files
108+ cleanupMavenMetadata(artifactDir, artifactParentDir)
101109 }
102110 }
103111}
@@ -126,5 +134,21 @@ def generateChecksumsFor(File file) {
126134 }
127135}
128136
137+ def cleanupMavenMetadata (File versionDir , File artifactDir ) {
138+ // Delete maven-metadata-local.xml from version directory (e.g., 1.0.7-SNAPSHOT/)
139+ def versionMetadataFile = new File (versionDir, ' maven-metadata-local.xml' )
140+ if (versionMetadataFile. exists()) {
141+ boolean deleted = versionMetadataFile. delete()
142+ println " Deleted maven-metadata-local.xml from version directory: ${ deleted ? 'SUCCESS' : 'FAILED'} "
143+ }
144+
145+ // Delete maven-metadata-local.xml from artifact directory (e.g., method-analyzer-core/)
146+ def artifactMetadataFile = new File (artifactDir, ' maven-metadata-local.xml' )
147+ if (artifactMetadataFile. exists()) {
148+ boolean deleted = artifactMetadataFile. delete()
149+ println " Deleted maven-metadata-local.xml from artifact directory: ${ deleted ? 'SUCCESS' : 'FAILED'} "
150+ }
151+ }
152+
129153// Chain the tasks
130- publishToMavenLocal. finalizedBy generateChecksums
154+ publishToMavenLocal. finalizedBy generateChecksumsAndCleanup
0 commit comments