-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow --include-imports in buf generate via plugin (#89)
- Loading branch information
1 parent
dda437a
commit 8912a0c
Showing
17 changed files
with
295 additions
and
1 deletion.
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
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
17 changes: 17 additions & 0 deletions
17
src/test/resources/GenerateTest/generate java with --include-imports/buf.gen.yaml
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,17 @@ | ||
# Copyright (c) 2022 Andrew Parmet | ||
# | ||
# 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. | ||
|
||
version: v1 | ||
plugins: | ||
- remote: buf.build/protocolbuffers/plugins/java:v3.20.0-1 | ||
out: java |
6 changes: 6 additions & 0 deletions
6
src/test/resources/GenerateTest/generate java with --include-imports/buf.lock
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,6 @@ | ||
version: v1 | ||
deps: | ||
- remote: buf.build | ||
owner: googleapis | ||
repository: googleapis | ||
commit: 62f35d8aed1149c291d606d958a7ce32 |
3 changes: 3 additions & 0 deletions
3
src/test/resources/GenerateTest/generate java with --include-imports/buf.yaml
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,3 @@ | ||
version: v1 | ||
deps: | ||
- buf.build/googleapis/googleapis |
37 changes: 37 additions & 0 deletions
37
src/test/resources/GenerateTest/generate java with --include-imports/build.gradle
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,37 @@ | ||
/* | ||
* Copyright (c) 2022 Andrew Parmet | ||
* | ||
* 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. | ||
*/ | ||
|
||
plugins { | ||
id 'java' | ||
id 'com.parmet.buf' | ||
} | ||
|
||
repositories { mavenCentral() } | ||
|
||
buf { | ||
generate { | ||
includeImports = true | ||
} | ||
} | ||
|
||
compileJava.dependsOn 'bufGenerate' | ||
|
||
sourceSets.main.java { | ||
srcDir 'build/bufbuild/generated/java' | ||
} | ||
|
||
dependencies { | ||
implementation "com.google.protobuf:protobuf-java:$protobufVersion" | ||
} |
24 changes: 24 additions & 0 deletions
24
...resources/GenerateTest/generate java with --include-imports/parmet/buf/test/v1/test.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,24 @@ | ||
// Copyright (c) 2022 Andrew Parmet | ||
// | ||
// 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 parmet.buf.test.v1; | ||
|
||
import "google/type/datetime.proto"; | ||
|
||
option java_package = "com.parmet.buf.test.v1"; | ||
|
||
message BasicMessage { | ||
google.type.DateTime date_time = 1; | ||
} |
24 changes: 24 additions & 0 deletions
24
...teTest/generate java with --include-imports/src/main/java/com/parmet/buf/test/v1/Foo.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,24 @@ | ||
/* | ||
* Copyright (c) 2022 Andrew Parmet | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.parmet.buf.test.v1; | ||
|
||
import com.google.type.DateTime; | ||
|
||
public class Foo { | ||
public static void test() { | ||
Test.BasicMessage.newBuilder().setDateTime(DateTime.newBuilder().build()).build(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...est/resources/GenerateWithWorkspaceTest/generate java with --include-imports/buf.gen.yaml
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,17 @@ | ||
# Copyright (c) 2022 Andrew Parmet | ||
# | ||
# 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. | ||
|
||
version: v1 | ||
plugins: | ||
- remote: buf.build/protocolbuffers/plugins/java:v3.20.0-1 | ||
out: java |
16 changes: 16 additions & 0 deletions
16
...st/resources/GenerateWithWorkspaceTest/generate java with --include-imports/buf.work.yaml
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,16 @@ | ||
# Copyright (c) 2022 Andrew Parmet | ||
# | ||
# 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. | ||
|
||
version: v1 | ||
directories: | ||
- workspace |
37 changes: 37 additions & 0 deletions
37
...est/resources/GenerateWithWorkspaceTest/generate java with --include-imports/build.gradle
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,37 @@ | ||
/* | ||
* Copyright (c) 2022 Andrew Parmet | ||
* | ||
* 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. | ||
*/ | ||
|
||
plugins { | ||
id 'java' | ||
id 'com.parmet.buf' | ||
} | ||
|
||
repositories { mavenCentral() } | ||
|
||
buf { | ||
generate { | ||
includeImports = true | ||
} | ||
} | ||
|
||
compileJava.dependsOn 'bufGenerate' | ||
|
||
sourceSets.main.java { | ||
srcDir 'build/bufbuild/generated/java' | ||
} | ||
|
||
dependencies { | ||
implementation "com.google.protobuf:protobuf-java:$protobufVersion" | ||
} |
24 changes: 24 additions & 0 deletions
24
...ceTest/generate java with --include-imports/src/main/java/com/parmet/buf/test/v1/Foo.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,24 @@ | ||
/* | ||
* Copyright (c) 2022 Andrew Parmet | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.parmet.buf.test.v1; | ||
|
||
import com.google.type.DateTime; | ||
|
||
public class Foo { | ||
public static void test() { | ||
Test.BasicMessage.newBuilder().setDateTime(DateTime.newBuilder().build()).build(); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...sources/GenerateWithWorkspaceTest/generate java with --include-imports/workspace/buf.lock
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,6 @@ | ||
version: v1 | ||
deps: | ||
- remote: buf.build | ||
owner: googleapis | ||
repository: googleapis | ||
commit: 62f35d8aed1149c291d606d958a7ce32 |
3 changes: 3 additions & 0 deletions
3
...sources/GenerateWithWorkspaceTest/generate java with --include-imports/workspace/buf.yaml
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,3 @@ | ||
version: v1 | ||
deps: | ||
- buf.build/googleapis/googleapis |
24 changes: 24 additions & 0 deletions
24
...orkspaceTest/generate java with --include-imports/workspace/parmet/buf/test/v1/test.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,24 @@ | ||
// Copyright (c) 2022 Andrew Parmet | ||
// | ||
// 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 parmet.buf.test.v1; | ||
|
||
import "google/type/datetime.proto"; | ||
|
||
option java_package = "com.parmet.buf.test.v1"; | ||
|
||
message BasicMessage { | ||
google.type.DateTime date_time = 1; | ||
} |