Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for NiA :app project to use declarative syntax #91

Merged
merged 6 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add roborazzi support for NiA
  • Loading branch information
tresat committed Jun 10, 2024
commit 27328d74ad55e34bb9ba90d453bf19f186e36f37
2 changes: 2 additions & 0 deletions unified-prototype/unified-plugin/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ android = "8.3.0"
androidTools = "31.3.0"
hilt = "2.50"
room = "2.6.1"
roborazzi = "1.7.0"

#Other Libs
apache-commons = "3.3.1"
Expand Down Expand Up @@ -38,3 +39,4 @@ apache-commons-lang = { module = "org.apache.commons:commons-lang3", version.ref
dependency-guard-plugin = { module = "com.dropbox.dependency-guard:com.dropbox.dependency-guard.gradle.plugin", version.ref = "dependency-guard"}
truth = { module = "com.google.truth:truth", version.ref = "truth" }
protobuf-plugin = { module = "com.google.protobuf:protobuf-gradle-plugin", version.ref = "protobuf" }
roborazzi-plugin = { module = "io.github.takahirom.roborazzi:roborazzi-gradle-plugin", version.ref = "roborazzi" }
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies {
implementation(libs.kotlin.serialization.plugin)
implementation(libs.room.plugin)
implementation(libs.protobuf.plugin)
implementation(libs.roborazzi.plugin)

implementation(libs.apache.commons.lang)
implementation(libs.android.tools.common)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import com.android.build.api.dsl.BuildType;
import com.android.build.api.dsl.CommonExtension;
import com.android.build.api.dsl.UnitTestOptions;
import com.android.build.gradle.BaseExtension;
import com.android.build.gradle.ProguardFiles;
import com.google.devtools.ksp.gradle.KspExtension;
import org.gradle.api.Action;
import org.gradle.api.JavaVersion;
Expand All @@ -20,7 +18,6 @@
import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension;

import java.io.File;
import java.util.Objects;

import static org.gradle.api.experimental.android.extensions.ComposeSupport.configureCompose;

Expand Down Expand Up @@ -61,6 +58,7 @@ public void apply(Project project) {
dslModel.getTesting().getTestOptions().getReturnDefaultValues().convention(false);
dslModel.getTesting().getJacoco().getEnabled().convention(false);
dslModel.getTesting().getJacoco().getVersion().convention("0.8.7");
dslModel.getTesting().getRoborazzi().getEnabled().convention(false);
}

/**
Expand Down Expand Up @@ -126,6 +124,8 @@ protected void configureHilt(Project project, AndroidSoftware dslModel, CommonEx
// Add support for Hilt
project.getPlugins().apply("dagger.hilt.android.plugin");
project.getDependencies().add("implementation", "com.google.dagger:hilt-android:2.50");

project.getDependencies().add("kspTest", "com.google.dagger:hilt-android-compiler:2.50");
}
}

Expand Down Expand Up @@ -181,6 +181,14 @@ protected void configureTesting(Project project, AndroidSoftware dslModel, Commo
ConfigurationContainer configurations = project.getConfigurations();
configurations.getByName("testImplementation").fromDependencyCollector(testDependencies.getImplementation());
configurations.getByName("androidTestImplementation").fromDependencyCollector(testDependencies.getAndroidImplementation());

configureRoborazzi(project, dslModel);
}

protected void configureRoborazzi(Project project, AndroidSoftware dslModel) {
if (dslModel.getTesting().getRoborazzi().getEnabled().get()) {
project.getPlugins().apply("io.github.takahirom.roborazzi");
}
}

@SuppressWarnings("UnstableApiUsage")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
*/
@Restricted
public interface Jacoco {
/**
* Internal property purposely not exposed to the DSL.
*/
@Restricted
Property<Boolean> getEnabled();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,26 @@
package org.gradle.api.experimental.android.extensions.testing;public interface Roborazzi {
/*
* Copyright 2024 The Android Open Source Project
*
* 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
*
* https://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 org.gradle.api.experimental.android.extensions.testing;

import org.gradle.api.provider.Property;
import org.gradle.declarative.dsl.model.annotations.Restricted;

@Restricted
public interface Roborazzi {
@Restricted
Property<Boolean> getEnabled();
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ default void jacoco(Action<? super Jacoco> action) {
jacoco.getEnabled().set(true);
}

@Nested
Roborazzi getRoborazzi();

@Configuring
default void roborazzi(Action<? super Roborazzi> action) {
Roborazzi roborazzi = getRoborazzi();
roborazzi.getEnabled().set(true);
action.execute(roborazzi);
}

@Nested
TestOptions getTestOptions();

Expand Down