aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/SubmitMojo.java
blob: eebb7f4e73849bae0bca0ae121631d1c5c78c5cb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.hosted.plugin;

import ai.vespa.hosted.api.Submission;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

import java.nio.file.Paths;

/**
 * Submits a Vespa application package and corresponding test jars to the hosted Vespa API.
 *
 * @author jonmv
 */
@Mojo(name = "submit")
public class SubmitMojo extends AbstractVespaMojo {

    @Parameter(property = "applicationZip")
    private String applicationZip;

    @Parameter(property = "applicationTestZip")
    private String applicationTestZip;

    @Parameter(property = "authorEmail")
    private String authorEmail;

    @Parameter(property = "repository")
    private String repository;

    @Parameter(property = "branch")
    private String branch;

    @Parameter(property = "commit")
    private String commit;

    @Parameter(property = "sourceUrl")
    private String sourceUrl;

    @Parameter(property = "projectId")
    private String projectId;

    @Parameter(property = "risk")
    private String risk;

    @Parameter(property = "description")
    private String description;

    @Override
    public void doExecute() {
        applicationZip = firstNonBlank(applicationZip, projectPathOf("target", "application.zip")).orElseThrow();
        applicationTestZip = firstNonBlank(applicationTestZip, projectPathOf("target", "application-test.zip")).orElseThrow();
        Submission submission = new Submission(optionalOf(repository), optionalOf(branch), optionalOf(commit),
                                               optionalOf(sourceUrl), optionalOf(authorEmail),
                                               Paths.get(applicationZip), Paths.get(applicationTestZip),
                                               optionalOf(projectId, Long::parseLong), optionalOf(risk, Integer::parseInt),
                                               optionalOf(description));

        getLog().info(controller.submit(submission, id.tenant(), id.application()).message());
    }

}