Missing module output in multi-module build


(Chris Rankin) #1

Hi,

I am trying to modify a third-party JAR using ProGuard - and my module itself works. However, I cannot refer to my module’s output from another module in the same project. I.e.

dependencies {
    implementation project(':my-proguard-module')
}

is not importing anything. I think I must be missing something in my ProGuard module’s configuration, but the only information I can find just mentions the artifacts block - which I already have. Can anyone tell me what I am missing please?

Any help appreciated here,
Thanks,
Chris

My module’s build.gradle file looks like:

plugins {
    id 'base'
}

repositories {
    mavenCentral()
}

configurations {
    proguardSource
}

dependencies {
    proguardSource "org.testing:source-thingy:$thingy_version"
}

import proguard.gradle.ProGuardTask
task proguard(type: ProGuardTask) {
    outjars = "$buildDir/libs/${project.name}.jar"
    injars = // ... etc

    // ProGuard configuration stuff
}
def proguardJar = proguard.outputs.files.singleFile

artifacts {
    archives file: proguardJar, name: project.name, type: 'jar', extension: 'jar', builtBy: proguard
}

defaultTasks "proguard"
assemble.dependsOn proguard

The root build.gradle contains:

classpath "net.sf.proguard:proguard-gradle:$proguard_version"

(Chris Rankin) #2

OK, I think I’ve figured it out. My ProGuard module needs:

configuration {
    runtime
}

artifacts {
    runtime file: proguardJar, name: project.name, type: 'jar', extension: 'jar', builtBy: proguard
}

And then other modules include the jar using:

dependencies {
    implementation project(path: ':my-proguard-module', configuration: 'runtime')
}

It would be nicer if other projects didn’t need to specify the configuration explicitly, but at least this works.