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

chore: Merge master #854

Merged
merged 19 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1b7ee1e
feat: enable self signed jwt for gapic clients (#794)
arithmetic1728 Aug 17, 2021
7691f4e
chore: release 2.1.0 (#827)
release-please[bot] Aug 17, 2021
fdcfe70
feat: REGAPIC initial implementation (#824)
vam-google Aug 26, 2021
445daf4
feat: REGAPIC Multitransport implementation (grpc+rest) (#833)
vam-google Sep 6, 2021
92f7c1c
fix: [bazel] fix rest transport handling in assembly rule (#835)
vam-google Sep 7, 2021
556e7dd
Portable String <--> bytes conversion (#841)
chanseokoh Sep 14, 2021
d335340
Fix development doc (#837)
chanseokoh Sep 14, 2021
8ca140c
Remove warnings (unused vars, dead code, missing annotations, missing…
chanseokoh Sep 14, 2021
a7d905e
Remove warnings for test code (#842)
chanseokoh Sep 17, 2021
6a9f329
Remove extraneous call (#844)
chanseokoh Sep 17, 2021
98b891f
Fix preserving sorted order of a collection (#845)
chanseokoh Sep 20, 2021
cb1b534
feat: Add REST AIP-151 LRO suport
vam-google Sep 21, 2021
f569c11
chore(deps): update dependency gradle to v7 (#713)
renovate-bot Sep 29, 2021
73e5a3e
chore(deps): update dependency bazel_skylib to v1.0.3 (#722)
renovate-bot Sep 29, 2021
108e93d
chore(deps): update dependency bazel_skylib to v1.1.1 (#849)
renovate-bot Oct 1, 2021
cd84efe
chore(deps): update dependency gradle to v7.2 (#848)
renovate-bot Oct 1, 2021
3f0bf5a
chore: rename default branch to main (#851)
Neenu1995 Oct 4, 2021
39c7b9c
Merge remote-tracking branch 'upstream/master' into diregapic-lro
vam-google Oct 6, 2021
d029941
chore: merge changes from master
vam-google Oct 6, 2021
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
2 changes: 1 addition & 1 deletion .github/release-please.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
releaseType: simple
handleGHRelease: true
primaryBranch: master
primaryBranch: main
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
on:
push:
branches:
- master
- main
pull_request:
name: ci
jobs:
build:
runs-on: ubuntu-latest
container: gcr.io/gapic-images/googleapis-bazel:20210105
# Dockerfile for this image: https://github.com/googleapis/googleapis-discovery/blob/master/Dockerfile
# Dockerfile for this image: https://github.com/googleapis/googleapis-discovery/blob/main/Dockerfile
# If you update its version, please also update it below in
# 'Cache Bazel files' - unfortunately it cannot accept variables at this
# time.
Expand Down
26 changes: 21 additions & 5 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,40 @@
## Running the Plugin

1. Clone [googleapis](https://github.com/googleapis/googleapis) and
[gapic-showcase](https://github.com/googleapis/gapic-showcase/) and install
protoc.
[gapic-showcase](https://github.com/googleapis/gapic-showcase/).

2. Copy the protos from Showcase into googleapis/google/showcase.

```sh
cp gapic-showcase/schema/google/showcase/v1beta1 googleapis/google/showcase/v1beta
mkdir googleapis/google/showcase
cp -r gapic-showcase/schema/google/showcase/v1beta1 googleapis/google/showcase/v1beta1
```

3. Add the new microgenerator rules to the protobuf directory's `BUILD.bazel`
file as follows:
3. Add the new microgenerator rules to
`googleapis/google/showcase/v1beta1/BUILD.bazel` file as follows:

```python
load(
"@com_google_googleapis_imports//:imports.bzl",
# Existing rules here.
"java_gapic_assembly_gradle_pkg",
"java_gapic_library",
"java_proto_library",
"proto_library_with_info",
)

proto_library_with_info(
name = "showcase_proto_with_info",
deps = [
":showcase_proto",
],
)

java_proto_library(
name = "showcase_java_proto",
deps = [
"showcase_proto",
],
)

# This should either replace the existing monolith target or have a unique name
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![codecov](https://codecov.io/gh/googleapis/gapic-generator-java/branch/master/graph/badge.svg?token=3RUU37GX9U)](https://codecov.io/gh/googleapis/gapic-generator-java)
[![codecov](https://codecov.io/gh/googleapis/gapic-generator-java/branch/main/graph/badge.svg?token=3RUU37GX9U)](https://codecov.io/gh/googleapis/gapic-generator-java)
# API Client Generator for Java

Generates a Java client library from protocol buffers.
Expand Down
6 changes: 3 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external")
# like protobuf will build.
http_archive(
name = "bazel_skylib",
sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44",
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public abstract class AnnotationNode implements AstNode {
public static AnnotationNode DEPRECATED =
AnnotationNode.builder().setType(annotationType(Deprecated.class)).build();

private static TypeNode annotationType(Class clazz) {
private static TypeNode annotationType(Class<?> clazz) {
return TypeNode.withReference(ConcreteReference.withClazz(clazz));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ public abstract class ArithmeticOperationExpr implements OperationExpr {

public abstract Expr rhsExpr();

@Override
public abstract OperatorKind operatorKind();

@Override
public abstract TypeNode type();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public abstract class AssignmentOperationExpr implements OperationExpr {

public abstract Expr valueExpr();

@Override
public abstract OperatorKind operatorKind();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

@AutoValue
public abstract class BlockComment implements Comment {
@Override
public abstract String comment();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public abstract class ConcreteReference implements Reference {
private static final String RIGHT_ANGLE = ">";
private static final String QUESTION_MARK = "?";

private static final Class WILDCARD_CLAZZ = ReferenceWildcard.class;
private static final Class<?> WILDCARD_CLAZZ = ReferenceWildcard.class;

// Private.
abstract Class clazz();
abstract Class<?> clazz();

@Override
public void accept(AstNodeVisitor visitor) {
Expand Down Expand Up @@ -105,7 +105,7 @@ public ImmutableList<String> enclosingClassNames() {
}
// The innermost type will be the last element in the list.
ImmutableList.Builder<String> listBuilder = new ImmutableList.Builder<>();
Class currentClz = clazz();
Class<?> currentClz = clazz();
while (currentClz.getEnclosingClass() != null) {
listBuilder.add(currentClz.getEnclosingClass().getSimpleName());
currentClz = currentClz.getEnclosingClass();
Expand Down Expand Up @@ -198,7 +198,7 @@ public Reference copyAndSetGenerics(List<Reference> generics) {
return toBuilder().setGenerics(generics).build();
}

public static ConcreteReference withClazz(Class clazz) {
public static ConcreteReference withClazz(Class<?> clazz) {
return builder().setClazz(clazz).build();
}

Expand All @@ -222,7 +222,7 @@ public static Builder builder() {

@AutoValue.Builder
public abstract static class Builder {
public abstract Builder setClazz(Class clazz);
public abstract Builder setClazz(Class<?> clazz);

public abstract Builder setUseFullName(boolean useFullName);

Expand All @@ -239,7 +239,7 @@ public Builder setGenerics(Reference... references) {
public abstract ConcreteReference autoBuild();

// Private.
abstract Class clazz();
abstract Class<?> clazz();

abstract ImmutableList<Reference> generics();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
public abstract class EnumRefExpr implements Expr {
public abstract IdentifierNode identifier();

@Override
public abstract TypeNode type();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
public interface Expr extends AstNode {
TypeNode type();

@Override
void accept(AstNodeVisitor visitor);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public abstract class LogicalOperationExpr implements OperationExpr {

public abstract Expr rhsExpr();

@Override
public abstract OperatorKind operatorKind();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,20 +244,18 @@ public MethodDefinition build() {
"Abstract methods cannot be static, final, or private");
}

// If this method overrides another, ensure that the Override annotaiton is the last one.
// If this method overrides another, ensure that the Override annotation is the last one.
ImmutableList<AnnotationNode> processedAnnotations = annotations();
if (isOverride()) {
processedAnnotations =
annotations()
.<AnnotationNode>builder()
ImmutableList.<AnnotationNode>builder()
.addAll(annotations())
.add(AnnotationNode.OVERRIDE)
.build();
}
// Remove duplicates while maintaining insertion order.
setAnnotations(
new LinkedHashSet<AnnotationNode>(processedAnnotations)
.stream().collect(Collectors.toList()));
new LinkedHashSet<>(processedAnnotations).stream().collect(Collectors.toList()));

MethodDefinition method = autoBuild();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

@AutoValue
public abstract class NewObjectExpr implements Expr {
@Override
public abstract TypeNode type();

public abstract ImmutableList<Expr> arguments();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
package com.google.api.generator.engine.ast;

public interface ObjectValue extends Value {
@Override
TypeNode type();

@Override
String value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public interface OperationExpr extends Expr {

OperatorKind operatorKind();

@Override
TypeNode type();

@Override
void accept(AstNodeVisitor visitor);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import javax.annotation.Nullable;

public interface Reference extends AstNode {
@Override
void accept(AstNodeVisitor visitor);

ImmutableList<Reference> generics();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public enum KeywordKind {
SUPER
}

@Override
public abstract TypeNode type();

public abstract KeywordKind keywordKind();
Expand Down Expand Up @@ -73,7 +74,7 @@ public Builder setArguments(Expr... arguments) {
public ReferenceConstructorExpr build() {
ReferenceConstructorExpr referenceConstructorExpr = autoBuild();
Preconditions.checkState(
referenceConstructorExpr.type().isReferenceType(referenceConstructorExpr.type()),
TypeNode.isReferenceType(referenceConstructorExpr.type()),
"A this/super constructor must have a reference type.");

NodeValidator.checkNoNullElements(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public abstract class RelationalOperationExpr implements OperationExpr {

public abstract Expr rhsExpr();

@Override
public abstract OperatorKind operatorKind();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
package com.google.api.generator.engine.ast;

public interface Statement extends AstNode {
@Override
void accept(AstNodeVisitor visitor);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

@AutoValue
public abstract class StringObjectValue implements ObjectValue {
@Override
public abstract String value();

@Override
Expand Down
22 changes: 4 additions & 18 deletions src/main/java/com/google/api/generator/engine/ast/TypeNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public int compareTo(TypeNode other) {
return -1;
}

if (this.equals(TypeNode.NULL)) {
if (equals(TypeNode.NULL)) {
// Can't self-compare, so we don't need to check whether the other one is TypeNode.NULL.
return other.isPrimitiveType() ? 1 : -1;
}
Expand Down Expand Up @@ -161,7 +161,7 @@ public static TypeNode withReference(Reference reference) {
return TypeNode.builder().setTypeKind(TypeKind.OBJECT).setReference(reference).build();
}

public static TypeNode withExceptionClazz(Class clazz) {
public static TypeNode withExceptionClazz(Class<?> clazz) {
Preconditions.checkState(Exception.class.isAssignableFrom(clazz));
return withReference(ConcreteReference.withClazz(clazz));
}
Expand Down Expand Up @@ -200,11 +200,11 @@ public boolean isPrimitiveType() {
}

public boolean isProtoPrimitiveType() {
return isPrimitiveType() || this.equals(TypeNode.STRING) || this.equals(TypeNode.BYTESTRING);
return isPrimitiveType() || equals(TypeNode.STRING) || equals(TypeNode.BYTESTRING);
}

public boolean isSupertypeOrEquals(TypeNode other) {
boolean oneTypeIsNull = this.equals(TypeNode.NULL) ^ other.equals(TypeNode.NULL);
boolean oneTypeIsNull = equals(TypeNode.NULL) ^ other.equals(TypeNode.NULL);
return !isPrimitiveType()
&& !other.isPrimitiveType()
&& isArray() == other.isArray()
Expand Down Expand Up @@ -256,20 +256,6 @@ boolean isBoxedTypeEquals(TypeNode other) {
return Objects.equals(other, BOXED_TYPE_MAP.get(this));
}

private static TypeNode createPrimitiveType(TypeKind typeKind) {
if (!isPrimitiveType(typeKind)) {
throw new IllegalArgumentException("Object is not a primitive type.");
}
return TypeNode.builder().setTypeKind(typeKind).build();
}

private static TypeNode createPrimitiveArrayType(TypeKind typeKind) {
if (typeKind.equals(TypeKind.OBJECT)) {
throw new IllegalArgumentException("Object is not a primitive type.");
}
return TypeNode.builder().setTypeKind(typeKind).setIsArray(true).build();
}

private static boolean isPrimitiveType(TypeKind typeKind) {
return !typeKind.equals(TypeKind.OBJECT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ public abstract class UnaryOperationExpr implements OperationExpr {

public abstract Expr expr();

@Override
public abstract OperatorKind operatorKind();

@Override
public abstract TypeNode type();

@Override
public void accept(AstNodeVisitor visitor) {
visitor.visit(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@

public class ImportWriterVisitor implements AstNodeVisitor {
private static final String DOT = ".";
private static final String NEWLINE = "\n";
private static final String PKG_JAVA_LANG = "java.lang";

private final Set<String> staticImports = new TreeSet<>();
Expand All @@ -94,7 +93,7 @@ public void clear() {

public void initialize(@Nonnull String currentPackage) {
this.currentPackage = currentPackage;
this.currentClassName = null;
currentClassName = null;
}

public void initialize(@Nonnull String currentPackage, @Nonnull String currentClassName) {
Expand Down
Loading