Skip to content
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 @@ -82,8 +82,16 @@ class WirePlugin : Plugin<Project> {

project.afterEvaluate {
if (extension.protoLibrary) {
extension.proto { protoOutput ->
protoOutput.out = File(project.libraryProtoOutputPath()).path
val existingProtoOutput = extension.outputs.filterIsInstance<ProtoOutput>().singleOrNull()
if (existingProtoOutput != null) {
// There exists a `proto {}` target already, we only set the output path if need be.
if (existingProtoOutput.out == null) {
existingProtoOutput.out = File(project.libraryProtoOutputPath()).path
}
} else {
extension.proto { protoOutput ->
protoOutput.out = File(project.libraryProtoOutputPath()).path
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,18 @@ class WirePluginTest {
}
}

@Test
fun protoLibraryWithProtoBlock() {
val fixtureRoot = File("src/test/projects/proto-library-with-proto-block")

fixtureGradleRunner(fixtureRoot, "clean", "jar").build()

ZipFile(File(fixtureRoot, "build/libs/proto-library-with-proto-block.jar")).use {
assertThat(it.getEntry("squareup/geology/period.proto")).isNotNull()
assertThat(it.getEntry("squareup/dinosaurs/dinosaur.proto")).isNotNull()
}
}

@Test
fun sourceDirExclude() {
val fixtureRoot = File("src/test/projects/sourcedir-exclude")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
buildscript {
dependencies {
classpath "com.squareup.wire:wire-gradle-plugin:$wireVersion"
classpath libs.pluginz.kotlin
}

repositories {
maven {
url new File(rootDir, "../../../../../build/localMaven").toURI().toString()
}
mavenCentral()
google()
}
}

apply plugin: 'kotlin'
apply plugin: 'com.squareup.wire'

wire {
protoLibrary = true

proto {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include ':'

dependencyResolutionManagement {
versionCatalogs {
libs {
from(files('../../../../../gradle/libs.versions.toml'))
}
}
}
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;
}
Loading