0

I am trying to add a manifest to a jar containing classpaths of dependency jar files. I found this solution here. Initially my build.gradle file was like this and worked properly.

plugins {
    id 'java'
}

group 'com.iiot-wizards'
version '2.0.0.1'

repositories {
    mavenCentral()
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.2'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.2'

    implementation files('lib/Utils-2.0.0.1.jar')

    // https://mvnrepository.com/artifact/org.apache.commons/commons-compress
    implementation group: 'org.apache.commons', name: 'commons-compress', version: '1.21'

    // https://mvnrepository.com/artifact/commons-io/commons-io
    implementation group: 'commons-io', name: 'commons-io', version: '2.11.0'

}

jar {
    manifest {
        attributes(
                'Class-Path': 'TinyLog-2.0.0.1.jar commons-io-2.11.0.jar commons-compress-1.21.jar Utils-2.0.0.1.jar'
        )
    }
}
test {
    useJUnitPlatform()
}

I changed jar section to this one as per accepted answer:

jar {
    manifest {
        attributes(
                "Class-Path": configurations.compile.collect { it.getName() }.join(' '))
    }
}

Now I am getting following error. What am I doing wrong here?

    Build file 'C:\Users\rmheg\OneDrive\Projects\SCADA\Trunk\source\Services\Libraries\iiot-wizards-log-manager\build.gradle' line: 29
        
        A problem occurred evaluating root project 'iio

t-wizards-log-manager'.
    > Could not get unknown property 'compile' for configuration container of type org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.
    
    * Try:
    Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Exception is:
    org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'iiot-wizards-log-manager'.
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
        at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.lambda$apply$0(DefaultScriptPluginFactory.java:133)
        at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:77)
    org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:52)
        at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
    Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'compile' for configuration container of type org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.
        at org.gradle.internal.metaobject.AbstractDynamicObject.getMissingProperty(AbstractDynamicObject.java:85)
        at org.gradle.internal.metaobject.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:62)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer_Decorated.getProperty(Unknown Source)
        at build_cq4j0h36ia4t86100eai5gnrj$_run_closure3$_closure5.doCall(C:\Users\rmheg\OneDrive\Projects\SCADA\Trunk\source\Services\Libraries\iiot-wizards-log-manager\build.gradle:29)
Ram
  • 921
  • 1
  • 19
  • 36

0 Answers0