0

I need to publish a couple of obfuscated jar files with their POM (before obfuscation) to a Nexus repository with Gradle.

The problem is if I select components.java then the non-obfuscated jar file is deployed.

I am using yGuard for obfuscation, and now in my build file I have created pom file, clean jar file and obfuscated jar file, but cannot find a way to publish the pom and obfuscated jar file together to our Nexus repository.

By the way the project is a multi module java-library project.

In my main build.gradle file I have something like

configure(subprojects) {
  apply plugin: 'java-library'
  apply plugin: 'maven-publish'

  jar {
    archiveFileName = "${project.name}-${project.version}-clean.jar"
    into("META-INF/maven/$project.group/$project.name") {
      from { generatePomFileForCleanPublication }
      rename '.*', 'pom.xml'
    }
  }

  publishing {
    publications {
       clean(MavenPublication) {
         from components.java
         withBuildIdentifier()
       }
    }

    repositories {
      maven {
        name 'nexus'
        url 'SOME URL'
        allowInsecureProtocol = true
        credentials {
          username 'someUserName'
          password 'somePassword'
        }
      }
    }
  }
}

so the pom is created according to module dependencies, but now I cannot publish the obfuscated jar file with same POM file.


Notes: The obfuscated jar files are generated in same folder as 'build\lib' without '-clean.jar` suffix.

Notes: when I remove from components.java and add my own artifact (obfuscated file) the generated pom won't have dependencies, and I couldn't find a way to override the jar file added to publication.

Amir Pashazadeh
  • 7,170
  • 3
  • 39
  • 69

0 Answers0