-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow gradle users to configure skaffold data
- Loading branch information
1 parent
84933d5
commit f4fa3fe
Showing
8 changed files
with
302 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...e-plugin/src/main/java/com/google/cloud/tools/jib/gradle/skaffold/SkaffoldParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2020 Google LLC. | ||
* | ||
* 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.skaffold; | ||
|
||
import com.google.common.base.Preconditions; | ||
import javax.inject.Inject; | ||
import org.gradle.api.Action; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.model.ObjectFactory; | ||
import org.gradle.api.tasks.Nested; | ||
|
||
public class SkaffoldParameters { | ||
|
||
private final SkaffoldWatchParameters watch; | ||
private final SkaffoldSyncParameters sync; | ||
|
||
@Inject | ||
public SkaffoldParameters(Project project) { | ||
ObjectFactory objectFactory = project.getObjects(); | ||
|
||
watch = objectFactory.newInstance(SkaffoldWatchParameters.class, project); | ||
sync = objectFactory.newInstance(SkaffoldSyncParameters.class, project); | ||
|
||
Preconditions.checkNotNull(watch); | ||
} | ||
|
||
public void watch(Action<? super SkaffoldWatchParameters> action) { | ||
action.execute(watch); | ||
} | ||
|
||
public void sync(Action<? super SkaffoldSyncParameters> action) { | ||
action.execute(sync); | ||
} | ||
|
||
@Nested | ||
public SkaffoldWatchParameters getWatch() { | ||
return watch; | ||
} | ||
|
||
@Nested | ||
public SkaffoldSyncParameters getSync() { | ||
return sync; | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...ugin/src/main/java/com/google/cloud/tools/jib/gradle/skaffold/SkaffoldSyncParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright 2020 Google LLC. | ||
* | ||
* 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.skaffold; | ||
|
||
import java.io.File; | ||
import java.nio.file.Path; | ||
import java.util.Collections; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
import javax.inject.Inject; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.tasks.Internal; | ||
|
||
public class SkaffoldSyncParameters { | ||
private final Project project; | ||
|
||
private Set<Path> excludes = Collections.emptySet(); | ||
|
||
@Inject | ||
public SkaffoldSyncParameters(Project project) { | ||
this.project = project; | ||
} | ||
|
||
/** | ||
* Get the excludes directive for sync functionality in skaffold. | ||
* | ||
* @return a set of absolute paths | ||
*/ | ||
@Internal | ||
public Set<Path> getExcludes() { | ||
// Gradle warns about @Input annotations on File objects, so we have to expose a getter for a | ||
// String to make them go away. | ||
return excludes; | ||
} | ||
|
||
/** | ||
* Sets excludes. {@code excludes} can be any suitable object describing file paths convertible by | ||
* {@link Project#files} (such as {@link File}, {@code List<File>}, or {@code List<String>}). | ||
* | ||
* @param paths paths to set on excludes | ||
*/ | ||
public void setExcludes(Object paths) { | ||
this.excludes = | ||
project | ||
.files(paths) | ||
.getFiles() | ||
.stream() | ||
.map(File::toPath) | ||
.map(Path::toAbsolutePath) | ||
.collect(Collectors.toSet()); | ||
} | ||
} |
127 changes: 127 additions & 0 deletions
127
...gin/src/main/java/com/google/cloud/tools/jib/gradle/skaffold/SkaffoldWatchParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
* Copyright 2020 Google LLC. | ||
* | ||
* 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.skaffold; | ||
|
||
import java.io.File; | ||
import java.nio.file.Path; | ||
import java.util.Collections; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
import javax.inject.Inject; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.tasks.Internal; | ||
|
||
public class SkaffoldWatchParameters { | ||
|
||
private final Project project; | ||
|
||
private Set<Path> buildIncludes = Collections.emptySet(); | ||
private Set<Path> includes = Collections.emptySet(); | ||
private Set<Path> excludes = Collections.emptySet(); | ||
|
||
@Inject | ||
public SkaffoldWatchParameters(Project project) { | ||
this.project = project; | ||
} | ||
|
||
/** | ||
* A set of absolute paths to include with skaffold watching. | ||
* | ||
* @return a set of absolute paths | ||
*/ | ||
@Internal | ||
public Set<Path> getBuildIncludes() { | ||
// Gradle warns about @Input annotations on File objects, so we have to expose a getter for a | ||
// String to make them go away. | ||
return buildIncludes; | ||
} | ||
|
||
/** | ||
* Sets includes. {@code includes} can be any suitable object describing file paths convertible by | ||
* {@link Project#files} (such as {@link File}, {@code List<File>}, or {@code List<String>}). | ||
* | ||
* @param paths paths to set on includes | ||
*/ | ||
public void setBuildIncludes(Object paths) { | ||
this.buildIncludes = | ||
project | ||
.files(paths) | ||
.getFiles() | ||
.stream() | ||
.map(File::toPath) | ||
.map(Path::toAbsolutePath) | ||
.collect(Collectors.toSet()); | ||
} | ||
|
||
/** | ||
* A set of absolute paths to include with skaffold watching. | ||
* | ||
* @return a set of absolute paths | ||
*/ | ||
@Internal | ||
public Set<Path> getIncludes() { | ||
// Gradle warns about @Input annotations on File objects, so we have to expose a getter for a | ||
// String to make them go away. | ||
return includes; | ||
} | ||
|
||
/** | ||
* Sets includes. {@code includes} can be any suitable object describing file paths convertible by | ||
* {@link Project#files} (such as {@link File}, {@code List<File>}, or {@code List<String>}). | ||
* | ||
* @param paths paths to set on includes | ||
*/ | ||
public void setIncludes(Object paths) { | ||
this.includes = | ||
project | ||
.files(paths) | ||
.getFiles() | ||
.stream() | ||
.map(File::toPath) | ||
.map(Path::toAbsolutePath) | ||
.collect(Collectors.toSet()); | ||
} | ||
|
||
/** | ||
* A set of absolute paths to exclude from skaffold watching. | ||
* | ||
* @return a set of absolute paths | ||
*/ | ||
@Internal | ||
public Set<Path> getExcludes() { | ||
// Gradle warns about @Input annotations on File objects, so we have to expose a getter for a | ||
// String to make them go away. | ||
return excludes; | ||
} | ||
|
||
/** | ||
* Sets excludes. {@code excludes} can be any suitable object describing file paths convertible by | ||
* {@link Project#files} (such as {@link File}, {@code List<File>}, or {@code List<String>}). | ||
* | ||
* @param paths paths to set on excludes | ||
*/ | ||
public void setExcludes(Object paths) { | ||
this.excludes = | ||
project | ||
.files(paths) | ||
.getFiles() | ||
.stream() | ||
.map(File::toPath) | ||
.map(Path::toAbsolutePath) | ||
.collect(Collectors.toSet()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.