-
Notifications
You must be signed in to change notification settings - Fork 275
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 explicit DuplicatesStrategy as required by gradle 7+ (#470) #487
Merged
voidzcy
merged 7 commits into
google:master
from
tom-haines:470-duplicate-strategy-grd7
Apr 16, 2021
+170
−0
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
de7190b
Add default DuplicatesStrategy as required by gradle 7+ (#470)
tom-haines b58604f
Include CopySpecTest in travis build (#470)
tom-haines 0f6cb57
Revert syntax refresh of build_base; remove version; and move depende…
tom-haines 9ed07a1
Allow travis to confirm test failure (#470)
tom-haines ac2ae3e
Apply fix to confirm travis build succeeds (#470)
tom-haines 78c6183
Use conflicting path to build-in proto3 type
tom-haines cf0419b
Address nit and apply fix to confirm travis success
tom-haines File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/test/groovy/com/google/protobuf/gradle/ProtobufKotlinDslCopySpecTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.google.protobuf.gradle | ||
|
||
import groovy.transform.CompileDynamic | ||
import org.gradle.testkit.runner.BuildResult | ||
import org.gradle.testkit.runner.GradleRunner | ||
import org.gradle.testkit.runner.TaskOutcome | ||
import spock.lang.Specification | ||
import spock.lang.Unroll | ||
|
||
/** | ||
* Unit test confirming copy spec is explicitly defined for gradle7+ compliance. | ||
*/ | ||
@CompileDynamic | ||
class ProtobufKotlinDslCopySpecTest extends Specification { | ||
private static final List<String> GRADLE_VERSIONS = ["5.6", "6.0", "6.7.1", "7.0"] | ||
|
||
@Unroll | ||
void "testProjectKotlinDslCopySpec should declare explicit copy spec [gradle #gradleVersion]"() { | ||
given: "project from testProjectKotlinDslCopySpec" | ||
File projectDir = ProtobufPluginTestHelper.projectBuilder('testProjectKotlinDslCopySpec') | ||
.copyDirs('testProjectKotlinDslCopySpec') | ||
.build() | ||
|
||
when: "build is invoked" | ||
BuildResult result = GradleRunner.create() | ||
.withProjectDir(projectDir) | ||
.withArguments('test', 'build', '--stacktrace') | ||
.withPluginClasspath() | ||
.withGradleVersion(gradleVersion) | ||
.forwardStdOutput(new OutputStreamWriter(System.out)) | ||
.forwardStdError(new OutputStreamWriter(System.err)) | ||
.build() | ||
|
||
then: "it succeed" | ||
|
||
result.task(":test").outcome == TaskOutcome.SUCCESS | ||
|
||
verifyProjectDir(projectDir) | ||
|
||
where: | ||
gradleVersion << GRADLE_VERSIONS | ||
} | ||
|
||
private static void verifyProjectDir(File projectDir) { | ||
File generatedSrcDir = new File(projectDir.path, "build/generated/source/proto/main/java") | ||
List<File> fileList = [] | ||
generatedSrcDir.eachFileRecurse { file -> | ||
if (file.path.endsWith('.java')) { | ||
fileList.add (file) | ||
} | ||
} | ||
assert fileList.size > 0 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import com.google.protobuf.gradle.generateProtoTasks | ||
import com.google.protobuf.gradle.id | ||
import com.google.protobuf.gradle.ofSourceSet | ||
import com.google.protobuf.gradle.plugins | ||
import com.google.protobuf.gradle.protobuf | ||
import com.google.protobuf.gradle.protoc | ||
|
||
buildscript { | ||
repositories { | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
plugins { | ||
java | ||
id("java-library") | ||
id("com.google.protobuf") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
val protobufDepVersion = "3.0.0" | ||
val grpcVersion = "1.37.0" | ||
|
||
dependencies { | ||
implementation("io.grpc:grpc-protobuf:$grpcVersion") | ||
implementation("io.grpc:grpc-stub:$grpcVersion") | ||
implementation("com.google.protobuf:protobuf-java:$protobufDepVersion") | ||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.1") | ||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.1") | ||
} | ||
|
||
protobuf { | ||
protoc { | ||
artifact = "com.google.protobuf:protoc:$protobufDepVersion" | ||
} | ||
plugins { | ||
id("grpc") { | ||
artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion" | ||
} | ||
} | ||
} | ||
|
||
tasks { | ||
test { | ||
useJUnitPlatform { | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name="testProjectKotlinDslCopySpec" |
42 changes: 42 additions & 0 deletions
42
testProjectKotlinDslCopySpec/src/main/proto/google/type/money.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2020 Google LLC | ||
// | ||
// 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 | ||
// | ||
// http://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. | ||
|
||
syntax = "proto3"; | ||
|
||
package google.type; | ||
|
||
option cc_enable_arenas = true; | ||
option go_package = "google.golang.org/genproto/googleapis/type/money;money"; | ||
option java_multiple_files = true; | ||
option java_outer_classname = "MoneyProto"; | ||
option java_package = "com.google.type"; | ||
option objc_class_prefix = "GTP"; | ||
|
||
// Represents an amount of money with its currency type. | ||
message Money { | ||
// The three-letter currency code defined in ISO 4217. | ||
string currency_code = 1; | ||
|
||
// The whole units of the amount. | ||
// For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar. | ||
int64 units = 2; | ||
|
||
// Number of nano (10^-9) units of the amount. | ||
// The value must be between -999,999,999 and +999,999,999 inclusive. | ||
// If `units` is positive, `nanos` must be positive or zero. | ||
// If `units` is zero, `nanos` can be positive, zero, or negative. | ||
// If `units` is negative, `nanos` must be negative or zero. | ||
// For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000. | ||
int32 nanos = 3; | ||
} |
12 changes: 12 additions & 0 deletions
12
testProjectKotlinDslCopySpec/src/test/java/com/myapp/ExampleUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.myapp; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class ExampleUnitTest { | ||
|
||
@Test | ||
public void addition_isCorrect() { | ||
Assertions.assertEquals(4, 2 + 2); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added tests against full gradle suite