Skip to content

Instantly share code, notes, and snippets.

@simon04
Last active February 15, 2022 06:14
Show Gist options
  • Save simon04/6865179 to your computer and use it in GitHub Desktop.
Save simon04/6865179 to your computer and use it in GitHub Desktop.

Revisions

  1. simon04 revised this gist Oct 30, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ I struggled with with the jar MANIFEST file built with Gradle containing an empt


    Wrong (`jar` before `dependencies`):
    ```
    ```gradle
    jar {
    manifest.attributes(
    // Class-Path won't contain "guava-15.0.jar"
    @@ -23,7 +23,7 @@ dependencies {
    ```

    Correct (`jar` after `dependencies`):
    ```
    ```gradle
    repositories {
    mavenCentral()
    }
  2. simon04 created this gist Oct 7, 2013.
    41 changes: 41 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    Gradle, Java plugin, Jar MANIFEST, Class-Path is empty
    ======================================================

    I struggled with with the jar MANIFEST file built with Gradle containing an empty `Class-Path`. I traced down the problem to the order of the `dependencies` and `jar` blocks in the `build.gradle` file:


    Wrong (`jar` before `dependencies`):
    ```
    jar {
    manifest.attributes(
    // Class-Path won't contain "guava-15.0.jar"
    'Class-Path': configurations.runtime.files.collect { it.name }.join(' ')
    )
    }
    repositories {
    mavenCentral()
    }
    dependencies {
    compile group: 'com.google.guava', name: 'guava', version: '15.0'
    }
    ```

    Correct (`jar` after `dependencies`):
    ```
    repositories {
    mavenCentral()
    }
    dependencies {
    compile group: 'com.google.guava', name: 'guava', version: '15.0'
    }
    jar {
    manifest.attributes(
    // results in "Class-Path: guava-15.0.jar"
    'Class-Path': configurations.runtime.files.collect { it.name }.join(' ')
    )
    }
    ```