<commit_before>plugins {
    java
}
version = "1.0"

// tag::add-to-manifest[]
tasks.getByName<Jar>("jar") {
    manifest {
        attributes(
            "Implementation-Title" to "Gradle",
            "Implementation-Version" to version
        )
    }
}
// end::add-to-manifest[]

// tag::custom-manifest[]
val sharedManifest = the<JavaPluginConvention>().manifest {
    attributes (
        "Implementation-Title" to "Gradle",
        "Implementation-Version" to version
    )
}

task<Jar>("fooJar") {
    manifest = project.the<JavaPluginConvention>().manifest {
        from(sharedManifest)
    }
}
// end::custom-manifest[]

// tag::merge[]
task<Jar>("barJar") {
    manifest {
        attributes("key1" to "value1")
        from(sharedManifest, "src/config/basemanifest.txt")
        from(listOf("src/config/javabasemanifest.txt", "src/config/libbasemanifest.txt"), closureOf<ManifestMergeSpec> {
            eachEntry(Action<ManifestMergeDetails> {
                if (baseValue != mergeValue) {
                    value = baseValue
                }
                if (key == "foo") {
                    exclude()
                }
            })
        })
    }
}
// end::merge[]

// tag::write[]
tasks.getByName<Jar>("jar").manifest.writeTo("$buildDir/mymanifest.mf")
// end::write[]<commit_msg>use typesafe from() method in manifest example instead of closure-based one<commit_after>plugins {
    java
}
version = "1.0"

// tag::add-to-manifest[]
tasks.getByName<Jar>("jar") {
    manifest {
        attributes(
            "Implementation-Title" to "Gradle",
            "Implementation-Version" to version
        )
    }
}
// end::add-to-manifest[]

// tag::custom-manifest[]
val sharedManifest = the<JavaPluginConvention>().manifest {
    attributes (
        "Implementation-Title" to "Gradle",
        "Implementation-Version" to version
    )
}

task<Jar>("fooJar") {
    manifest = project.the<JavaPluginConvention>().manifest {
        from(sharedManifest)
    }
}
// end::custom-manifest[]

// tag::merge[]
task<Jar>("barJar") {
    manifest {
        attributes("key1" to "value1")
        from(sharedManifest, "src/config/basemanifest.txt")
        from(listOf("src/config/javabasemanifest.txt", "src/config/libbasemanifest.txt")) {
            eachEntry(Action<ManifestMergeDetails> {
                if (baseValue != mergeValue) {
                    value = baseValue
                }
                if (key == "foo") {
                    exclude()
                }
            })
        }
    }
}
// end::merge[]

// tag::write[]
tasks.getByName<Jar>("jar").manifest.writeTo("$buildDir/mymanifest.mf")
// end::write[]
{'fraction_non_alphanumeric': 0.15512048192771086, 'fraction_numerical': 0.0030120481927710845, 'mean_word_length': 2.2284325637910083, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6081400', 'n_tokens_mistral': 825, 'n_tokens_neox': 818, 'n_words': 120}