Skip to content

Commit

Permalink
fix: add license to generated files (#127)
Browse files Browse the repository at this point in the history
* fix: add license to generated files

* fix license

* fix license format

* remove unneed dep
  • Loading branch information
averikitsch committed Jan 25, 2023
1 parent 2f5635e commit 9b37aa7
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 91 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test_generation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
DATA_SOURCE_PATH: ${{ github.workspace }}/${{ env.DATA_SOURCE_CHECKOUT_PATH }}

- name: View generator output
if: ${{ always() }}
working-directory: ${{ env.LIBRARY_CHECKOUT_PATH }}
run: |
git add -N . # Needed if files are untracked
Expand Down
13 changes: 2 additions & 11 deletions google-cloudevent-types/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-common-protos</artifactId>
<version>2.10.0</version>
<version>2.13.0</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>2.0.1</version>
<version>2.1.3</version>
</dependency>

<!-- Test dependencies -->
Expand All @@ -57,13 +57,4 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
</plugin>
</plugins>
</build>
</project>
51 changes: 10 additions & 41 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
<name>Google CloudEvents Types for Java Parent</name>
<url>https://github.com/googleapis/google-cloudevents-java</url>

<parent>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-shared-config</artifactId>
<version>1.2.4</version>
</parent>

<developers>
<developer>
<name>Averi Kitsch</name>
Expand Down Expand Up @@ -42,8 +48,9 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<github.global.server>github</github.global.server>
<site.installationModule>google-cloudevent-types-parent</site.installationModule>
<!-- Skip strict library tests -->
<enforcer.skip>true</enforcer.skip>
<clirr.skip>true</clirr.skip>
</properties>

<dependencyManagement>
Expand All @@ -68,7 +75,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.0</version>
<version>2.10.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -108,44 +115,6 @@
<packaging>jar</packaging>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.1</version>
<reportSets>
<reportSet>
<id>html</id>
<reports>
<report>aggregate</report>
<report>javadoc</report>
</reports>
</reportSet>
</reportSets>
<configuration>
<doclint>none</doclint>
<show>protected</show>
<nohelp>true</nohelp>
<outputDirectory>${project.build.directory}/javadoc</outputDirectory>
<groups>
<group>
<title>Test helpers packages</title>
<packages>com.google.cloud.testing</packages>
</group>
<group>
<title>SPI packages</title>
<packages>com.google.cloud.spi*</packages>
</group>
</groups>

<links>
<link>https://grpc.io/grpc-java/javadoc/</link>
<link>https://developers.google.com/protocol-buffers/docs/reference/java/</link>
<link>https://googleapis.dev/java/google-auth-library/latest/</link>
<link>https://googleapis.dev/java/gax/latest/</link>
<link>https://googleapis.github.io/api-common-java/</link>
</links>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
4 changes: 2 additions & 2 deletions protoc-gen-java-snowpea/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.5</version>
<version>2.0.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.5</version>
<version>2.0.6</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
* Copyright 2023 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
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://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.
* 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.google.events;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
* Copyright 2023 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
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://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.
* 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.google.events;
Expand Down
16 changes: 8 additions & 8 deletions protoc-gen-java-snowpea/src/main/resources/classTemplate.vm
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
* Copyright ${year} 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
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://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.
* 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.
*/

// Code generated by protoc-gen-java-snowpea. DO NOT EDIT.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
* Copyright 2023 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
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://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.
* 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.google.events;
Expand Down
19 changes: 14 additions & 5 deletions tools/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ mkdir -p $TEST_GEN_OUT
# Ensure clean source for local builds
BUILD_LOCALLY="${BUILD_LOCALLY:-false}"
if [[ "$BUILD_LOCALLY" == "true" ]]; then
MACOS='.bak'
current=$(pwd)
cd $DATA_SOURCE_PATH
git restore --staged $PROTOBUF_SRC $THIRDPARTY
Expand All @@ -70,13 +71,13 @@ _generate() {
echo "# Generating from $proto_src"

# Comment out preset Java options
sed -i 's/option java/\/\/option java/' $proto_src
sed -i $MACOS 's/option java/\/\/option java/' $proto_src
# Set Java option: multiple files
echo -en "\noption java_multiple_files = true;" >> $proto_src
# Set Java option: package name
awk '/^package/,/;/' $proto_src > PROTO_PACKAGE; # Ex. package google.events.cloud.pubsub.v1; => google.events.cloud.pubsub.v1
sed -i 's/package /option java_package = \"com./' PROTO_PACKAGE
sed -i 's/;/"/' PROTO_PACKAGE
sed -i $MACOS 's/package /option java_package = \"com./' PROTO_PACKAGE
sed -i $MACOS 's/;/"/' PROTO_PACKAGE
echo -en "\n$(cat PROTO_PACKAGE);" >> $proto_src

echo "# - proto bindings"
Expand All @@ -102,8 +103,16 @@ for i in $(find "${PROTOBUF_SRC}" -type f -name data.proto); do
_generate $i
done

# Clean up tmp files
rm PROTO_PACKAGE*
YEAR=$(date +'%Y')
LICENSE="/\*\n \* Copyright $YEAR Google LLC\n \*\n \* Licensed under the Apache License, Version 2.0 (the \"License\");\n \* you may not use this file except in compliance with the License.\n \* You may obtain a copy of the License at\n \*\n \* https://www.apache.org/licenses/LICENSE-2.0\n \*\n \* Unless required by applicable law or agreed to in writing, software\n \* distributed under the License is distributed on an \"AS IS\" BASIS,\n \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n \* See the License for the specific language governing permissions and\n \* limitations under the License.\n \*/"
FILE_HEAD="// Generated by the protocol buffer compiler."

for i in $(find "${PROTOC_OUT}" -type f -name "*.java"); do
echo
echo "########################################################"
echo "# Generating license header $i"
sed -i $MACOS "s|$FILE_HEAD|$LICENSE\n$FILE_HEAD|" $i
done

echo
echo "########################################################"
Expand Down

0 comments on commit 9b37aa7

Please sign in to comment.