Generate jar file for Gradle task

Having following code:

How to generate jar file for specific Gradle task?
So I would have jar for foo module - smoke task and jar for foo module - test task.

Below is build.gradle file:

plugins {
    id 'java'
    id "com.github.johnrengelman.shadow" version "5.2.0"
}

apply plugin: "com.github.johnrengelman.shadow"
apply plugin: 'java'
apply plugin: 'maven-publish'

repositories {
    mavenCentral()
}

dependencies {
    compile project(":bar")
    implementation 'org.junit.jupiter:junit-jupiter-engine:5.6.2'
    implementation 'org.junit.jupiter:junit-jupiter-api:5.6.2'
}

task smoke(type: Test) {
    useJUnitPlatform{
        includeTags 'smoke'
    }
}

test {
    useJUnitPlatform{
    }
}

jar {
    manifest {
        attributes(
                'Implementation-Title': project.name,
                'Implementation-Version': project.version,
                'Built-By': System.getProperty('user.name'),
                'Built-JDK': System.getProperty('java.version'),
                'Build-Date': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
                'Source-Compatibility': project.sourceCompatibility,
                'Target-Compatibility': project.targetCompatibility
        )
    }
}