Skip to content
Draft
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 @@ -120,9 +120,6 @@ class WirePlugin : Plugin<Project> {
val projectDependenciesJvmConfiguration = project.configurations.getByName("protoProjectDependenciesJvm")

val outputs = extension.outputs
check(outputs.isNotEmpty()) {
"At least one target must be provided for project '${project.path}\n" + "See our documentation for details: https://square.github.io/wire/wire_compiler/#customizing-output"
}
val hasJavaOutput = outputs.any { it is JavaOutput }
val hasKotlinOutput = outputs.any { it is KotlinOutput }
check(!hasKotlinOutput || kotlin.get()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ class WirePluginTest {
assertThat(result.output).contains("Wire Gradle plugin applied in project ':' but unable to find either the Java, Kotlin, or Android plugin")
}

@Test
fun noSourceNoTargetNoError() {
val fixtureRoot = File("src/test/projects/no-source-no-target-project")

gradleRunner.runFixture(fixtureRoot) { build() }
}

@Test
fun sourceWithNoTargetDoesError() {
val fixtureRoot = File("src/test/projects/source-but-no-target-project")

gradleRunner.runFixture(fixtureRoot) { build() }
}

@Test
fun sourcePathDirDoesNotExistButProtoPathDoes() {
val fixtureRoot = File("src/test/projects/sourcepath-nonexistent-srcdir-with-protopath")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
plugins {
id 'kotlin'
id 'com.squareup.wire'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
plugins {
id 'kotlin'
id 'com.squareup.wire'
}

wire {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
syntax = "proto2";

package squareup.dinosaurs;

option java_package = "com.squareup.dinosaurs";

import "squareup/geology/period.proto";

message Dinosaur {
/** Common name of this dinosaur, like "Stegosaurus". */
optional string name = 1;

/** URLs with images of this dinosaur. */
repeated string picture_urls = 2;

optional double length_meters = 3;
optional double mass_kilograms = 4;
optional squareup.geology.Period period = 5;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto2";

package squareup.geology;

option java_package = "com.squareup.geology";

enum Period {
/** 145.5 million years ago — 66.0 million years ago. */
CRETACEOUS = 1;

/** 201.3 million years ago — 145.0 million years ago. */
JURASSIC = 2;

/** 252.17 million years ago — 201.3 million years ago. */
TRIASSIC = 3;
}
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,13 @@ class WireRun(
val fullSchema = schemaLoader.loadSchema()
eventListeners.forEach { it.loadSchemaSuccess(fullSchema) }

if (targets.isEmpty() && fullSchema.protoFiles.all { isWireRuntimeProto(it.location) }) {
// We have sources but no target to handle them.
IllegalStateException("Sources have been found but no target are set. " +
"At least one target must be provided for this project\n" +
"See our documentation for details: https://square.github.io/wire/wire_compiler/#customizing-output")
}
Comment on lines +258 to +263
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like this code is executed on neither of the tests


// Refactor the schema.
val schema = refactorSchema(
schema = fullSchema,
Expand Down
Loading