Search in sources :

Example 1 with GradleRawConfiguration

use of com.google.cloud.tools.jib.gradle.GradleRawConfiguration in project jib by GoogleContainerTools.

the class SyncMapTask method listFilesAndTargets.

/**
 * Task Action, lists files and container targets.
 */
@TaskAction
public void listFilesAndTargets() {
    Preconditions.checkNotNull(jibExtension);
    try (TempDirectoryProvider tempDirectoryProvider = new TempDirectoryProvider()) {
        GradleProjectProperties projectProperties = GradleProjectProperties.getForProject(getProject(), getLogger(), tempDirectoryProvider, jibExtension.getConfigurationName().get());
        GradleRawConfiguration configuration = new GradleRawConfiguration(jibExtension);
        // TODO: move these shared checks with SyncMapMojo into plugins-common
        if (projectProperties.isWarProject()) {
            throw new GradleException("Skaffold sync is currently only available for 'jar' style Jib projects, but the project " + getProject().getName() + " is configured to generate a 'war'");
        }
        try {
            if (!ContainerizingMode.EXPLODED.equals(ContainerizingMode.from(jibExtension.getContainerizingMode()))) {
                throw new GradleException("Skaffold sync is currently only available for Jib projects in 'exploded' containerizing mode, but the containerizing mode of " + getProject().getName() + " is '" + jibExtension.getContainerizingMode() + "'");
            }
        } catch (InvalidContainerizingModeException ex) {
            throw new GradleException("Invalid containerizing mode", ex);
        }
        try {
            String syncMapJson = PluginConfigurationProcessor.getSkaffoldSyncMap(configuration, projectProperties, jibExtension.getSkaffold().getSync().getExcludes());
            System.out.println();
            System.out.println("BEGIN JIB JSON: SYNCMAP/1");
            System.out.println(syncMapJson);
        } catch (Exception ex) {
            throw new GradleException("Failed to generate a Jib file map for sync with Skaffold", ex);
        }
    }
}
Also used : GradleProjectProperties(com.google.cloud.tools.jib.gradle.GradleProjectProperties) GradleException(org.gradle.api.GradleException) GradleRawConfiguration(com.google.cloud.tools.jib.gradle.GradleRawConfiguration) TempDirectoryProvider(com.google.cloud.tools.jib.filesystem.TempDirectoryProvider) InvalidContainerizingModeException(com.google.cloud.tools.jib.plugins.common.InvalidContainerizingModeException) InvalidContainerizingModeException(com.google.cloud.tools.jib.plugins.common.InvalidContainerizingModeException) GradleException(org.gradle.api.GradleException) TaskAction(org.gradle.api.tasks.TaskAction)

Example 2 with GradleRawConfiguration

use of com.google.cloud.tools.jib.gradle.GradleRawConfiguration in project jib by google.

the class SyncMapTask method listFilesAndTargets.

/**
 * Task Action, lists files and container targets.
 */
@TaskAction
public void listFilesAndTargets() {
    Preconditions.checkNotNull(jibExtension);
    try (TempDirectoryProvider tempDirectoryProvider = new TempDirectoryProvider()) {
        GradleProjectProperties projectProperties = GradleProjectProperties.getForProject(getProject(), getLogger(), tempDirectoryProvider, jibExtension.getConfigurationName().get());
        GradleRawConfiguration configuration = new GradleRawConfiguration(jibExtension);
        // TODO: move these shared checks with SyncMapMojo into plugins-common
        if (projectProperties.isWarProject()) {
            throw new GradleException("Skaffold sync is currently only available for 'jar' style Jib projects, but the project " + getProject().getName() + " is configured to generate a 'war'");
        }
        try {
            if (!ContainerizingMode.EXPLODED.equals(ContainerizingMode.from(jibExtension.getContainerizingMode()))) {
                throw new GradleException("Skaffold sync is currently only available for Jib projects in 'exploded' containerizing mode, but the containerizing mode of " + getProject().getName() + " is '" + jibExtension.getContainerizingMode() + "'");
            }
        } catch (InvalidContainerizingModeException ex) {
            throw new GradleException("Invalid containerizing mode", ex);
        }
        try {
            String syncMapJson = PluginConfigurationProcessor.getSkaffoldSyncMap(configuration, projectProperties, jibExtension.getSkaffold().getSync().getExcludes());
            System.out.println();
            System.out.println("BEGIN JIB JSON: SYNCMAP/1");
            System.out.println(syncMapJson);
        } catch (Exception ex) {
            throw new GradleException("Failed to generate a Jib file map for sync with Skaffold", ex);
        }
    }
}
Also used : GradleProjectProperties(com.google.cloud.tools.jib.gradle.GradleProjectProperties) GradleException(org.gradle.api.GradleException) GradleRawConfiguration(com.google.cloud.tools.jib.gradle.GradleRawConfiguration) TempDirectoryProvider(com.google.cloud.tools.jib.filesystem.TempDirectoryProvider) InvalidContainerizingModeException(com.google.cloud.tools.jib.plugins.common.InvalidContainerizingModeException) InvalidContainerizingModeException(com.google.cloud.tools.jib.plugins.common.InvalidContainerizingModeException) GradleException(org.gradle.api.GradleException) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

TempDirectoryProvider (com.google.cloud.tools.jib.filesystem.TempDirectoryProvider)2 GradleProjectProperties (com.google.cloud.tools.jib.gradle.GradleProjectProperties)2 GradleRawConfiguration (com.google.cloud.tools.jib.gradle.GradleRawConfiguration)2 InvalidContainerizingModeException (com.google.cloud.tools.jib.plugins.common.InvalidContainerizingModeException)2 GradleException (org.gradle.api.GradleException)2 TaskAction (org.gradle.api.tasks.TaskAction)2