How to integrate output of non-java task to a java project

I’m trying to integrate output of the Angular 5’s compiler into a java servlet (war) as a package containing resource files - autogenerated generated html, js, styles etc. After some struggling I’ve got this build script. The top level project is ‘topaz’, angular subproject is ‘topaz-angular’. It works, but for some reason the resulting war has two copes of scripts - one within topaz.war/WEB-INF/lib/topaz-angular.jar and another one is in topaz.war/static, not packed. Another minor defect is that MANIFEST.MF isn’t contained in the root of topaz-angular.jar, but goes to topaz-angular.jar/static.

plugins {
    id "com.moowork.node" version "1.2.0"
}

group 'org.crownjewels'
version '0.1-DEV'

apply plugin: 'war'

war.archiveName 'topaz.war'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

project('topaz-angular') {
    apply plugin: 'com.moowork.node'
    apply plugin: 'base'

    configurations {
        runtime
    }

    node {
        version = '6.11.4'
        download = false
    }

    task ngBuild(type: NpmTask, dependsOn: npm_install) {
        args = ['run', 'build']
    }

    task pack(type: Jar, dependsOn: ngBuild) {
        entryCompression = "STORED"
        from 'dist'
        into 'static'
    }

    artifacts {
        runtime pack
    }
}

dependencies {
    compile "javax.servlet:servlet-api:2.5"
    compile group: 'commons-io', name: 'commons-io', version: '2.6'
    runtime project(path: 'topaz-angular', configuration: 'runtime')
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

Finally I’ve managed to make it work as expected. Alas, I still don’t understand how exactly it works. It’s assembled from dozen of code snippets seen on Internet. What’s the relation between java plugin, configuration, artifacts and runtime project dependency here?

war.archiveName 'topaz.war'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

project('topaz-angular') {
    apply plugin: 'com.moowork.node'
    apply plugin: 'java'

    configurations {
        webjar
    }

    node {
        version = '6.11.4'
        download = false
    }

    task ngBuild(type: NpmTask, dependsOn: npm_install) {
        args = ['run', 'build']
    }

    task makeWebjar(type: Jar, dependsOn: ngBuild) {
        from(fileTree("dist")) {
            into "META-INF/resources"
        }
    }

    artifacts {
        webjar makeWebjar
    }
}

dependencies {
    compile "javax.servlet:servlet-api:2.5"
    compile group: 'commons-io', name: 'commons-io', version: '2.6'
    runtime project(path: 'topaz-angular', configuration: 'webjar')
    testCompile group: 'junit', name: 'junit', version: '4.12'
}