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

Track Xcode target's product name as task input #808

Merged
merged 1 commit into from
Mar 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,8 @@ public static BiFunction<PBXProject, PBXShellScriptBuildPhase, PBXShellScriptBui
public static BiFunction<PBXProject, PBXShellScriptBuildPhase, PBXShellScriptBuildPhase> inputPaths(BiFunction<? super PBXProject, ? super List<String>, ? extends List<String>> action) {
return (self, buildPhase) -> buildPhase.toBuilder().inputPaths(action.apply(self, buildPhase.getInputPaths())).build();
}

public static BiFunction<PBXProject, PBXTarget, PBXTarget> productName(String value) {
return (self, target) -> target.toBuilder().productName(value).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import static dev.nokee.buildadapter.xcode.PBXProjectTestUtils.add;
import static dev.nokee.buildadapter.xcode.PBXProjectTestUtils.buildPhases;
import static dev.nokee.buildadapter.xcode.PBXProjectTestUtils.clear;
import static dev.nokee.buildadapter.xcode.PBXProjectTestUtils.productName;
import static dev.nokee.internal.testing.GradleRunnerMatchers.outOfDate;
import static org.hamcrest.MatcherAssert.assertThat;

Expand Down Expand Up @@ -59,4 +60,11 @@ void outOfDateWhenBuildPhaseRemoved() {
assertThat(targetUnderTestExecution(), outOfDate());
}
}

@Test
void outOfDateWhenProductNameChanged() {
xcodeproj(targetUnderTest(productName("NewApp")));

assertThat(targetUnderTestExecution(), outOfDate());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import static dev.nokee.buildadapter.xcode.PBXProjectTestUtils.asLegacyTarget;
import static dev.nokee.buildadapter.xcode.PBXProjectTestUtils.buildArgumentsString;
import static dev.nokee.buildadapter.xcode.PBXProjectTestUtils.buildToolPath;
import static dev.nokee.buildadapter.xcode.PBXProjectTestUtils.productName;
import static dev.nokee.internal.testing.GradleRunnerMatchers.outOfDate;
import static java.nio.file.attribute.PosixFilePermissions.fromString;
import static org.hamcrest.MatcherAssert.assertThat;
Expand Down Expand Up @@ -58,4 +59,11 @@ void outOfDateWhenBuildArgumentsChanged() {

assertThat(targetUnderTestExecution(), outOfDate());
}

@Test
void outOfDateWhenProductNameChanged() {
xcodeproj(targetUnderTest(productName("NewApp")));

assertThat(targetUnderTestExecution(), outOfDate());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import static dev.nokee.buildadapter.xcode.PBXProjectTestUtils.add;
import static dev.nokee.buildadapter.xcode.PBXProjectTestUtils.buildPhases;
import static dev.nokee.buildadapter.xcode.PBXProjectTestUtils.productName;
import static dev.nokee.buildadapter.xcode.PBXProjectTestUtils.removeLast;
import static dev.nokee.internal.testing.GradleRunnerMatchers.outOfDate;
import static org.hamcrest.MatcherAssert.assertThat;
Expand Down Expand Up @@ -57,4 +58,11 @@ void outOfDateWhenBuildPhaseRemoved() {
assertThat(targetUnderTestExecution(), outOfDate());
}
}

@Test
void outOfDateWhenProductNameChanged() {
xcodeproj(targetUnderTest(productName("NewApp")));

assertThat(targetUnderTestExecution(), outOfDate());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public final class XCBuildSpecCodingKeyCoders implements CodingKeyCoders {

// PBXAggregateTarget
put(CodeablePBXAggregateTarget.CodingKeys.name, null);
put(CodeablePBXAggregateTarget.CodingKeys.productName, null);
put(CodeablePBXAggregateTarget.CodingKeys.productName, forKey("productName", atInput(ofString())));
put(CodeablePBXAggregateTarget.CodingKeys.productType, null);
put(CodeablePBXAggregateTarget.CodingKeys.productReference, null);
put(CodeablePBXAggregateTarget.CodingKeys.buildPhases, forKey("buildPhases", list(of(PBXBuildPhase.class))));
Expand Down Expand Up @@ -106,7 +106,7 @@ public final class XCBuildSpecCodingKeyCoders implements CodingKeyCoders {

// PBXLegacyTarget
put(CodeablePBXLegacyTarget.CodingKeys.name, null);
put(CodeablePBXLegacyTarget.CodingKeys.productName, null);
put(CodeablePBXLegacyTarget.CodingKeys.productName, forKey("productName", atInput(ofString())));
put(CodeablePBXLegacyTarget.CodingKeys.productType, null);
put(CodeablePBXLegacyTarget.CodingKeys.productReference, null);
put(CodeablePBXLegacyTarget.CodingKeys.dependencies, null);
Expand All @@ -119,7 +119,7 @@ public final class XCBuildSpecCodingKeyCoders implements CodingKeyCoders {

// PBXNativeTarget
put(CodeablePBXNativeTarget.CodingKeys.name, null);
put(CodeablePBXNativeTarget.CodingKeys.productName, null);
put(CodeablePBXNativeTarget.CodingKeys.productName, forKey("productName", atInput(ofString())));
put(CodeablePBXNativeTarget.CodingKeys.productType, null);
put(CodeablePBXNativeTarget.CodingKeys.productReference, null);
put(CodeablePBXNativeTarget.CodingKeys.dependencies, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private static final class CodingKeysProvider implements ArgumentsProvider {
add(arguments(KeyedCoders.ISA, keyOf("isa", inputOf(string()))));

add(arguments(CodeablePBXAggregateTarget.CodingKeys.name, ignore()));
add(arguments(CodeablePBXAggregateTarget.CodingKeys.productName, ignore()));
add(arguments(CodeablePBXAggregateTarget.CodingKeys.productName, keyOf("productName", inputOf(string()))));
add(arguments(CodeablePBXAggregateTarget.CodingKeys.productType, ignore()));
add(arguments(CodeablePBXAggregateTarget.CodingKeys.productReference, ignore()));
add(arguments(CodeablePBXAggregateTarget.CodingKeys.dependencies, ignore())); // not required (2)
Expand Down Expand Up @@ -125,7 +125,7 @@ private static final class CodingKeysProvider implements ArgumentsProvider {
add(arguments(CodeablePBXHeadersBuildPhase.CodingKeys.files, keyOf("files", listOf(object(/*PBXBuildFile*/)))));

add(arguments(CodeablePBXLegacyTarget.CodingKeys.name, ignore()));
add(arguments(CodeablePBXLegacyTarget.CodingKeys.productName, ignore()));
add(arguments(CodeablePBXLegacyTarget.CodingKeys.productName, keyOf("productName", inputOf(string()))));
add(arguments(CodeablePBXLegacyTarget.CodingKeys.productType, ignore()));
add(arguments(CodeablePBXLegacyTarget.CodingKeys.productReference, ignore()));
add(arguments(CodeablePBXLegacyTarget.CodingKeys.dependencies, ignore())); // not required (2)
Expand All @@ -137,7 +137,7 @@ private static final class CodingKeysProvider implements ArgumentsProvider {
add(arguments(CodeablePBXLegacyTarget.CodingKeys.passBuildSettingsInEnvironment, ignore()));

add(arguments(CodeablePBXNativeTarget.CodingKeys.name, ignore()));
add(arguments(CodeablePBXNativeTarget.CodingKeys.productName, ignore()));
add(arguments(CodeablePBXNativeTarget.CodingKeys.productName, keyOf("productName", inputOf(string()))));
add(arguments(CodeablePBXNativeTarget.CodingKeys.productType, ignore()));
add(arguments(CodeablePBXNativeTarget.CodingKeys.productReference, ignore()));
add(arguments(CodeablePBXNativeTarget.CodingKeys.dependencies, ignore())); // not required (2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public Builder name(String name) {
return this;
}

@Override
public PBXTarget.Builder productName(String productName) {
builder.put(CodeablePBXAggregateTarget.CodingKeys.productName, productName);
return this;
}

@Override
public Builder buildConfigurations(XCConfigurationList buildConfigurations) {
builder.put(CodeablePBXAggregateTarget.CodingKeys.buildConfigurationList, buildConfigurations);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public Builder dependencies(Iterable<? extends PBXTargetDependency> dependencies
return this;
}

@Override
public Builder productName(String productName) {
builder.put(CodeablePBXLegacyTarget.CodingKeys.productName, productName);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public Builder buildConfigurations(XCConfigurationList buildConfigurationList) {
return this;
}

@Override
public Builder productName(String productName) {
builder.put(CodeablePBXNativeTarget.CodingKeys.productName, productName);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public interface PBXTarget extends PBXProjectItem {
Builder toBuilder();

interface Builder {
Builder productName(String productName);

PBXTarget build();
}
}