Create and install second artifact with war and maven plugins

I am trying to create a WAR file, as well as a JAR file. I want to be able to install both to my mavenLocal. I am using the java, war and maven plugins.

I have description, group, archivesBaseName, and version declared, as well as repositories with mavenLocal() and mavenCentral(), and some dependencies.

This all creates and installs my WAR just fine. I now want to create and install a second artifact.

task myJar(type: Jar) {
    manifest {
        attributes (
            'Build-Date' : new Date(),
: System.getProperty('java.version'),
 : System.getProperty(''),
  uploadArchives {
    println "Archives Artifacts: " + configurations.archives.allArtifacts
    dependsOn myJar
    repositories {
        mavenDeployer {
            repository(url: mavenLocal().url)
            addFilter('war') {artifact, file ->
                artifact.ext == 'war'
            addFilter('searchJar') {artifact, file ->
                artifact.ext == 'jar'

The only artifact listed is the WAR, and I don’t get a JAR uploaded, although it was built and exists in my build/lib folder, alongside my WAR file.

I tried adding this:

artifacts {
    archives myJar

But that makes my “install” task fail because the POM can’t handle multiple main artifacts.

How do I get my JAR file installed?

You do need the ‘artifacts’ block, and I think you also need to add filters for ‘install.repositories.mavenInstaller’.