diff --git a/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/BuildDockerTask.java b/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/BuildDockerTask.java new file mode 100644 index 0000000000..8e6eb13ed4 --- /dev/null +++ b/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/BuildDockerTask.java @@ -0,0 +1,36 @@ +/* + * Copyright 2018 Google LLC. All Rights Reserved. + * + * Licensed 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. + */ + +package com.google.cloud.tools.jib.gradle; + +import javax.annotation.Nullable; +import org.gradle.api.DefaultTask; +import org.gradle.api.tasks.TaskAction; + +/** Builds a container image and exports to the default Docker daemon. */ +public class BuildDockerTask extends DefaultTask { + + @Nullable private JibExtension jibExtension; + + @TaskAction + public void buildDocker() { + getLogger().warn("Doing gradle jibBuildDocker!"); + } + + void setJibExtension(JibExtension jibExtension) { + this.jibExtension = jibExtension; + } +} diff --git a/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/JibPlugin.java b/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/JibPlugin.java index 5fac628646..042f213186 100644 --- a/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/JibPlugin.java +++ b/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/JibPlugin.java @@ -36,5 +36,11 @@ public void apply(Project project) { "jibDockerContext", DockerContextTask.class, dockerContextTask -> dockerContextTask.setJibExtension(jibExtension)); + project + .getTasks() + .create( + "jibBuildDocker", + BuildDockerTask.class, + buildDockerTask -> buildDockerTask.setJibExtension(jibExtension)); } } diff --git a/jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/BuildDockerMojo.java b/jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/BuildDockerMojo.java new file mode 100644 index 0000000000..2ee09b6690 --- /dev/null +++ b/jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/BuildDockerMojo.java @@ -0,0 +1,32 @@ +/* + * Copyright 2018 Google LLC. All rights reserved. + * + * Licensed 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. + */ + +package com.google.cloud.tools.jib.maven; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.ResolutionScope; + +/** Builds a container image and exports to the default Docker daemon. */ +@Mojo(name = "buildDocker", requiresDependencyResolution = ResolutionScope.RUNTIME_PLUS_SYSTEM) +public class BuildDockerMojo extends JibPluginConfiguration { + + @Override + public void execute() throws MojoExecutionException, MojoFailureException { + getLog().warn("Doing maven jib:buildDocker!"); + } +}