/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

apply plugin: 'eclipse'
eclipse {
    project {
        natures 'org.eclipse.wst.jsdt.core.jsNature'
        buildCommand 'org.eclipse.wst.jsdt.core.javascriptValidator'
    }
}

ext.dockerImageName = 'action-nodejs-v20'
apply from: '../../gradle/docker.gradle'

distDocker.dependsOn 'copyPackageJson'
distDocker.dependsOn 'copyProxy'
distDocker.dependsOn 'copyRunner'
distDocker.dependsOn 'copyService'
distDocker.dependsOn 'copyPlatform'
distDocker.dependsOn 'copyOpenWhisk'
distDocker.dependsOn 'copyKnative'
distDocker.dependsOn 'copyBuildTemplate'
distDocker.finalizedBy('cleanup')

task copyPackageJson(type: Copy) {
    from '../nodejsActionBase/package.json'
    into '.'
}

task copyProxy(type: Copy) {
    from '../nodejsActionBase/app.js'
    into '.'
}

task copyRunner(type: Copy) {
    from '../nodejsActionBase/runner.js'
    into '.'
}

task copyService(type: Copy) {
    from '../nodejsActionBase/src/service.js'
    into './src'
}

task copyPlatform(type: Copy) {
    from '../nodejsActionBase/platform/platform.js'
    into './platform'
}

task copyOpenWhisk(type: Copy) {
    from '../nodejsActionBase/platform/openwhisk.js'
    into './platform'
}

task copyKnative(type: Copy) {
    from '../nodejsActionBase/platform/knative.js'
    into './platform'
}

task copyBuildTemplate(type: Copy) {
    from '../nodejsActionBase/buildtemplate.yaml'
    into '.'
}

task cleanup(type: Delete) {
    delete 'package.json'
    delete 'app.js'
    delete 'runner.js'
    delete 'src'
    delete 'platform'
    delete 'buildtemplate.yaml'
}
