Repository: xolstice/protobuf-maven-plugin
Branch: master
Commit: d36a396eaf54
Files: 248
Total size: 553.1 KB
Directory structure:
gitextract_d2avz9m1/
├── .appveyor/
│ └── toolchains.xml
├── .appveyor.yml
├── .editorconfig
├── .gitattributes
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.md
│ │ └── feature_request.md
│ └── pull_request_template.md
├── .gitignore
├── .mvn/
│ └── wrapper/
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── .travis/
│ └── toolchains.xml
├── .travis.yml
├── AUTHORS
├── CONTRIBUTORS
├── LICENSE
├── NOTICE
├── README.md
├── docs/
│ ├── CODE_OF_CONDUCT.md
│ └── CONTRIBUTING.md
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src/
├── changes/
│ └── changes.xml
├── it/
│ ├── TEST-1/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── test.proto
│ │ └── verify.groovy
│ ├── TEST-10/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── project1/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── test1.proto
│ │ ├── project2/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── test2.proto
│ │ └── verify.groovy
│ ├── TEST-11/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── project1/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── it/
│ │ │ └── project1/
│ │ │ └── test1.proto
│ │ ├── project2/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── it/
│ │ │ └── project2/
│ │ │ └── test2.proto
│ │ └── verify.groovy
│ ├── TEST-12/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── project1/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── test1.proto
│ │ ├── project2/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── test2.proto
│ │ └── verify.groovy
│ ├── TEST-13/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ ├── main/
│ │ │ │ └── proto/
│ │ │ │ └── it/
│ │ │ │ └── project1/
│ │ │ │ └── test1.proto
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── it/
│ │ │ └── project1/
│ │ │ └── test2.proto
│ │ └── verify.groovy
│ ├── TEST-14/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ ├── main/
│ │ │ │ └── proto/
│ │ │ │ └── test1.proto
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── test2.proto
│ │ └── verify.groovy
│ ├── TEST-15/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── test.proto
│ │ └── verify.groovy
│ ├── TEST-16/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ ├── test1.proto
│ │ │ └── test2.proto
│ │ └── verify.groovy
│ ├── TEST-17/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ └── proto/
│ │ └── test.proto
│ ├── TEST-18/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── test.proto
│ │ └── verify.groovy
│ ├── TEST-19/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── test.proto
│ │ └── verify.groovy
│ ├── TEST-2/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ └── verify.groovy
│ ├── TEST-20/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── test.proto
│ │ └── verify.groovy
│ ├── TEST-21/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── test.proto
│ │ └── verify.groovy
│ ├── TEST-22/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ ├── main/
│ │ │ │ └── proto/
│ │ │ │ └── a/
│ │ │ │ └── aaa.proto
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── b/
│ │ │ └── bbb.proto
│ │ └── verify.groovy
│ ├── TEST-23/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ ├── main/
│ │ │ │ └── proto/
│ │ │ │ └── a/
│ │ │ │ └── aaa.proto
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── b/
│ │ │ └── bbb.proto
│ │ └── verify.groovy
│ ├── TEST-24/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── project1/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── it/
│ │ │ └── project1/
│ │ │ └── test1.proto
│ │ ├── project2/
│ │ │ └── pom.xml
│ │ └── verify.groovy
│ ├── TEST-25/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── test.proto
│ │ └── verify.groovy
│ ├── TEST-26/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── test.proto
│ │ └── verify.groovy
│ ├── TEST-27/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── project1/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── it/
│ │ │ └── project1/
│ │ │ └── test1.proto
│ │ ├── project2/
│ │ │ └── pom.xml
│ │ └── verify.groovy
│ ├── TEST-28/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── test.proto
│ │ └── verify.groovy
│ ├── TEST-29/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ ├── test.proto
│ │ │ ├── тест.proto
│ │ │ └── テスト.proto
│ │ └── verify.groovy
│ ├── TEST-3/
│ │ ├── invoker.properties
│ │ └── pom.xml
│ ├── TEST-30/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── test.proto
│ │ └── verify.groovy
│ ├── TEST-31/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── test.proto
│ │ └── verify.groovy
│ ├── TEST-32/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── test.proto
│ │ └── verify.groovy
│ ├── TEST-33/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── test.proto
│ │ └── verify.groovy
│ ├── TEST-34/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── test.proto
│ │ └── verify.groovy
│ ├── TEST-35/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── test.proto
│ │ └── verify.groovy
│ ├── TEST-36/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── test.proto
│ │ └── verify.groovy
│ ├── TEST-37/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── test.proto
│ │ └── verify.groovy
│ ├── TEST-4/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── test.proto
│ │ └── verify.groovy
│ ├── TEST-5/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── project1/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── it/
│ │ │ └── project1/
│ │ │ └── test1.proto
│ │ ├── project2/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── it/
│ │ │ └── project2/
│ │ │ └── test2.proto
│ │ └── verify.groovy
│ ├── TEST-6/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── project1/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── test1.proto
│ │ ├── project2/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── test2.proto
│ │ └── verify.groovy
│ ├── TEST-7/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── project1/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── it/
│ │ │ └── project1/
│ │ │ └── test1.proto
│ │ ├── project2/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── it/
│ │ │ └── project2/
│ │ │ └── test2.proto
│ │ └── verify.groovy
│ ├── TEST-8/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── project1/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── test1.proto
│ │ ├── project2/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── test/
│ │ │ └── proto/
│ │ │ └── test2.proto
│ │ └── verify.groovy
│ ├── TEST-9/
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── project1/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── it/
│ │ │ └── project1/
│ │ │ └── test1.proto3
│ │ ├── project2/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── proto/
│ │ │ └── it/
│ │ │ └── project2/
│ │ │ └── test2.proto3
│ │ └── verify.groovy
│ ├── dependencies/
│ │ └── pom.xml
│ ├── settings.xml
│ ├── setup-it-parent/
│ │ ├── invoker.properties
│ │ └── pom.xml
│ └── setup-protoc-plugin/
│ ├── invoker.properties
│ ├── pom.xml
│ └── src/
│ └── main/
│ └── java/
│ └── org/
│ └── xolstice/
│ └── protobuf/
│ └── plugin/
│ └── minimal/
│ └── MinimalPlugin.java
├── main/
│ ├── java/
│ │ └── org/
│ │ └── xolstice/
│ │ └── maven/
│ │ ├── plugin/
│ │ │ └── protobuf/
│ │ │ ├── AbstractProtocCompileMojo.java
│ │ │ ├── AbstractProtocMojo.java
│ │ │ ├── AbstractProtocTestCompileMojo.java
│ │ │ ├── MojoConfigurationException.java
│ │ │ ├── MojoInitializationException.java
│ │ │ ├── Protoc.java
│ │ │ ├── ProtocCompileCppMojo.java
│ │ │ ├── ProtocCompileCsharpMojo.java
│ │ │ ├── ProtocCompileCustomMojo.java
│ │ │ ├── ProtocCompileDescriptorSetMojo.java
│ │ │ ├── ProtocCompileJavaScriptMojo.java
│ │ │ ├── ProtocCompileMojo.java
│ │ │ ├── ProtocCompilePythonMojo.java
│ │ │ ├── ProtocPlugin.java
│ │ │ ├── ProtocPluginAssembler.java
│ │ │ ├── ProtocTestCompileCppMojo.java
│ │ │ ├── ProtocTestCompileCsharpMojo.java
│ │ │ ├── ProtocTestCompileCustomMojo.java
│ │ │ ├── ProtocTestCompileDescriptorSetMojo.java
│ │ │ ├── ProtocTestCompileJavaScriptMojo.java
│ │ │ ├── ProtocTestCompileMojo.java
│ │ │ └── ProtocTestCompilePythonMojo.java
│ │ └── toolchain/
│ │ └── protobuf/
│ │ ├── DefaultProtobufToolchain.java
│ │ ├── DefaultProtobufToolchainFactory.java
│ │ └── ProtobufToolchain.java
│ └── resources/
│ ├── META-INF/
│ │ ├── m2e/
│ │ │ └── lifecycle-mapping-metadata.xml
│ │ └── plexus/
│ │ └── components.xml
│ └── winrun4j/
│ ├── README.txt
│ ├── WinRun4J.md5
│ ├── WinRun4J.sha
│ └── WinRun4J.sha.asc
└── site/
├── apt/
│ ├── examples/
│ │ ├── protobuf-dependencies.apt.vm
│ │ ├── protobuf-toolchain.apt.vm
│ │ ├── protoc-artifact.apt.vm
│ │ └── protoc-plugin.apt.vm
│ ├── index.apt.vm
│ └── usage.apt.vm
├── fml/
│ └── faq.fml
└── site.xml
================================================
FILE CONTENTS
================================================
================================================
FILE: .appveyor/toolchains.xml
================================================
jdk1.8OpenJDKopenjdk8C:/Program Files/Java/jdk1.8.0protobuf3.4.0
C:/Users/appveyor/.m2/repository/com/google/protobuf/protoc/3.4.0/protoc-3.4.0-windows-x86_64.exe
protobuf3.11.1
C:/Users/appveyor/.m2/repository/com/google/protobuf/protoc/3.11.1/protoc-3.11.1-windows-x86_64.exe
================================================
FILE: .appveyor.yml
================================================
version: '{build}'
skip_tags: true
environment:
JAVA_HOME: 'C:\Program Files\Java\jdk1.8.0'
install:
# Prepend Java entry to PATH
- cmd: SET PATH=%JAVA_HOME%\bin;%PATH%
- cmd: SET MAVEN_OPTS=-Xmx2g
- cmd: SET JAVA_OPTS=-Xmx2g
- cmd: java -version
# Set up toolchains for java and protoc
- cmd: if not exist %USERPROFILE%\.m2 mkdir %USERPROFILE%\.m2
- cmd: copy .appveyor\toolchains.xml %USERPROFILE%\.m2\
# Download all dependencies that integration tests might need later
# These include protoc and grpc plugin executables being referenced in toolchains.xml
- cmd: mvnw.cmd -B -V -Dstyle.color=always -Djansi.passthrough=true dependency:go-offline -f src/it/dependencies/pom.xml -P protoc-3.4.0
- cmd: mvnw.cmd -B -V -Dstyle.color=always -Djansi.passthrough=true dependency:go-offline -f src/it/dependencies/pom.xml -P protoc-3.11.1
- cmd: mvnw.cmd -B -V -Dstyle.color=always -Djansi.passthrough=true dependency:go-offline -P run-its
build_script:
- cmd: mvnw.cmd -B -V -Dstyle.color=always -Djansi.passthrough=true clean package -Dmaven.test.skip=true
test_script:
- cmd: mvnw.cmd -B -V -Dstyle.color=always -Djansi.passthrough=true verify -P run-its -Dinvoker.streamLogs=true
cache:
- '%USERPROFILE%\.m2\'
================================================
FILE: .editorconfig
================================================
# http://editorconfig.org
# A special property that should be specified at the top of the file outside of any sections.
# Set to true to stop .editorconfig file search on the current file.
root = true
[*]
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
continuation_indent_size = 8
max_line_length = 120
[*.{yml,yaml,json}]
indent_size = 2
================================================
FILE: .gitattributes
================================================
# Set the default behaviour, in case users don't have core.autocrlf set
* text=auto
# Explicitly declare text files we want to always be normalized and converted to native line endings on checkout
*.md text
*.java text
*.properties text
*.proto text
# Declare files that will always have LF line endings on checkout.
*.pom text eol=lf
pom.xml text eol=lf
================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: Bug report
about: Create a report to help us improve
---
**Before submitting a bug report**
- [ ] Check the existing issues, please avoid submitting duplicates
- [ ] Check the [FAQ](https://www.xolstice.org/protobuf-maven-plugin/faq.html) for known problems
- [ ] Try asking on [Gitter](https://gitter.im/xolstice/protobuf-maven-plugin)
**Describe the bug**
**Environment**
```
...
```
**Standalone or IDE**
Are you are running Maven inside an IDE, and in that case, which IDE?
**Plugin configuration**
```
...
```
**To Reproduce**
Steps to reproduce the behavior:
1. ...
2. ...
**Log output**
```
...
```
**Expected behavior**
**Additional context**
================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.md
================================================
---
name: Feature request
about: Suggest an idea for this project
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is.
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context about the feature request here.
================================================
FILE: .github/pull_request_template.md
================================================
**Applicable Issues**
Fixes #...
**Description**
================================================
FILE: .gitignore
================================================
# IDEA project files
.idea*
*.ipr
*.iws
*.iml
# Eclipse project files
.classpath
.project
.settings
# Maven output
target
*.releaseBackup
pom.xml.versionsBackup
release.properties
.mvn/timing.properties
================================================
FILE: .mvn/wrapper/maven-wrapper.properties
================================================
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip
================================================
FILE: .travis/toolchains.xml
================================================
jdk1.8OpenJDKopenjdk8/usr/lib/jvm/java-8-openjdk-amd64protobuf3.4.0
/home/travis/.m2/repository/com/google/protobuf/protoc/3.4.0/protoc-3.4.0-linux-x86_64.exe
protobuf3.11.1
/home/travis/.m2/repository/com/google/protobuf/protoc/3.11.1/protoc-3.11.1-linux-x86_64.exe
================================================
FILE: .travis.yml
================================================
dist: trusty
sudo: false
language: java
jdk: openjdk8
before_install:
# Set up toolchains for java and protoc
# Protoc executables will be downloaded in the next phase
- mkdir -p $HOME/.m2
- cp .travis/toolchains.xml $HOME/.m2/
install:
# Download all dependencies that integration tests might need later
- ./mvnw -B -V -Dstyle.color=always dependency:go-offline -f src/it/dependencies/pom.xml -P protoc-3.4.0
- ./mvnw -B -V -Dstyle.color=always dependency:go-offline -f src/it/dependencies/pom.xml -P protoc-3.11.1
- ./mvnw -B -V -Dstyle.color=always dependency:go-offline -P run-its
before_script:
# These protoc executables were downloaded in the previous phase and are being referenced in toolchains.xml
- chmod +x $HOME/.m2/repository/com/google/protobuf/protoc/3.4.0/protoc-3.4.0-linux-x86_64.exe
- chmod +x $HOME/.m2/repository/com/google/protobuf/protoc/3.11.1/protoc-3.11.1-linux-x86_64.exe
script:
# Finally, run the build with integration tests
- ./mvnw -B -V -Dstyle.color=always clean verify -P run-its -Dinvoker.streamLogs=true
cache:
directories:
- $HOME/.m2
================================================
FILE: AUTHORS
================================================
# This is the official list of Maven Protocol Buffers Plugin authors for copyright purposes.
# This file is distinct from the CONTRIBUTORS files.
# See the latter for an explanation.
#
# Names should be added to this file as one of
# Organization's name
# Individual's name
# Individual's name
# See CONTRIBUTORS for the meaning of multiple email addresses.
#
# Please keep the list sorted.
Google, Inc.
Sergei Ivanov
Xolstice Ltd.
================================================
FILE: CONTRIBUTORS
================================================
# This is the official list of people who have contributed
# code to the Maven Protocol Buffers Plugin repository.
# The AUTHORS file lists the copyright holders; this file
# lists people.
#
# Names should be added to this file like so:
# Individual's name
# Individual's name
#
# Where applicable, GitHub user name may be added in parentheses
# after the Individual's name.
#
# Please keep the list sorted.
Alexander Torstling (atorstling)
Andrey Batalev
Brice Figureau (masterzen)
Chris Heisterkamp (cheister)
Cosmin Lehene (clehene)
Daniel Evans (devans)
David Reichert (davidmreichert)
David Trott (dtrott)
Gregory Kick
Julien Henry (henryju)
Laurent Goujon (laurentgo)
Marek Kedzierski (kedzie)
Rob Wicke (rwicke)
Sergei Ivanov (sergei-ivanov)
================================================
FILE: LICENSE
================================================
This license applies to all parts of Maven Protocol Buffers Plugin except the following:
- WinRun4J Java launcher binaries, located in
src/main/resources/winrun4j/*.exe
These files are copyrighted by WinRun4J Authors,
please see the NOTICE file for licensing details.
Maven Protocol Buffers Plugin
Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
================================================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.
================================================
FILE: NOTICE
================================================
Maven Protocol Buffers Plugin
Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
================================================================================
This software includes a binary distribution of WinRun4J,
which is used to execute protoc plugins written in Java
under 32-bit and 64-bit Windows operating systems.
WinRun4J is licensed under the Common Public License (CPL).
http://www.eclipse.org/legal/cpl-v10.html
Additional information about WinRun4J is available on
the project's home page:
http://winrun4j.sourceforge.net/
For information about the bundled versions of the binaries
please read src/main/resources/winrun4j/README.txt
inside this git repository.
================================================
FILE: README.md
================================================
[](http://unmaintained.tech/)
[](https://raw.githubusercontent.com/xolstice/protobuf-maven-plugin/master/LICENSE)
[](https://repo1.maven.org/maven2/org/xolstice/maven/plugins/protobuf-maven-plugin/)
> [!IMPORTANT]
> This project is no longer being maintained, and no further contributions will be considered.
>
> Please consider switching to alternatives, such as: \
> https://github.com/ascopes/protobuf-maven-plugin
# Maven Protocol Buffers Plugin
A plugin that integrates protocol buffers compiler (`protoc`) into Maven lifecycle.
This is a continuation of `maven-protoc-plugin` that was started at Google
and later developed by GitHub community.
[Release notes](https://www.xolstice.org/protobuf-maven-plugin/changes-report.html) and detailed documentation
are available on the [web site](https://www.xolstice.org/protobuf-maven-plugin/).
================================================
FILE: docs/CODE_OF_CONDUCT.md
================================================
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
education, socio-economic status, nationality, personal appearance, race,
religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [code-of-conduct@xolstice.org][email]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct.html][version]
[homepage]: https://www.contributor-covenant.org
[version]: https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[email]: mailto:code-of-conduct@xolstice.org
================================================
FILE: docs/CONTRIBUTING.md
================================================
# Contributor's Guide
## Code of Conduct
This project and everyone participating in it is governed by the [Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
## I don't want to read this whole thing I just have a question!!!
> **Note:** Please don't file an issue to ask a question.
> You'll usually get faster feedback on Gitter.
Join the chat on [Gitter](https://gitter.im/xolstice/protobuf-maven-plugin) and post your question there.
## How you can help
As with any open source project, there are several ways you can help:
* Submit [bug reports](#reporting-bugs) and feature requests into the issue tracker
* Submit [patches](#patches) to reported issues (both those you find, or that others have filed)
* Help with the documentation
## Reporting bugs
Please provide detailed information about your environment and steps to reproduce the problem.
Specifically, please include the following:
* Output of `mvn --version` command:
* Operating system
* Maven version
* Java version
* Whether you are running Maven inside an IDE, and in that case, which IDE
* Plugin configuration
* Any relevant information from the log files
## Patches
Patches and pull requests are very welcome as long as they adhere to the following simple rules:
* the existing coding style is preserved;
* the patch does not needlessly introduce major code refactorings;
* the patch preserves backwards compatibility;
* no existing integration tests are broken by the patch;
* code and site documentation is updated, all new goals and parameters are marked with `@since ` tag;
* javadocs are kept compliant with doclint;
* ideally, integration tests are provided to cover the changes introduced in the patch.
================================================
FILE: mvnw
================================================
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven2 Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
# TODO classpath?
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`which java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
wget "$jarUrl" -O "$wrapperJarPath"
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
curl -o "$wrapperJarPath" "$jarUrl"
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
================================================
FILE: mvnw.cmd
================================================
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven2 Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
echo Found %WRAPPER_JAR%
) else (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
echo Finished downloading %WRAPPER_JAR%
)
@REM End of extension
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%
================================================
FILE: pom.xml
================================================
4.0.0org.xolstice.maven.pluginsprotobuf-maven-pluginmaven-pluginMaven Protocol Buffers Plugin0.7.0-SNAPSHOThttps://www.xolstice.org/protobuf-maven-pluginMaven Plugin that executes the Protocol Buffers (protoc) compiler2016UTF-81.8${java.sdk.version}${java.sdk.version}${java.sdk.version}3.3.92.1.03.3.03.6.0protobuf${mavenVersion}Maven Protocol Buffers Plugin Authorshttps://github.com/xolstice/protobuf-maven-plugin/blob/master/AUTHORSApache License, Version 2.0http://www.apache.org/licenses/LICENSE-2.0.txtreposergei-ivanovSergei Ivanovsergei@xolstice.orghttps://github.com/sergei-ivanovXolstice Ltd.https://www.xolstice.org0https://github.com/xolstice/protobuf-maven-pluginscm:git:git://github.com/xolstice/protobuf-maven-plugin.gitscm:git:ssh://git@github.com/xolstice/protobuf-maven-plugin.gitHEADhttps://bintray.com/xolstice/maven/protobuf-maven-plugin/viewgh-pageshttps://github.com/xolstice/protobuf-maven-plugin/tree/gh-pagesbintrayReleases on Bintrayhttps://api.bintray.com/maven/xolstice/maven/protobuf-maven-pluginGithubhttps://github.com/xolstice/protobuf-maven-plugin/issues/org.apache.maven.pluginsmaven-clean-plugin3.1.0org.apache.maven.pluginsmaven-enforcer-plugin3.0.0-M3org.apache.maven.pluginsmaven-toolchains-plugin3.0.0org.apache.maven.pluginsmaven-plugin-plugin3.6.0org.codehaus.plexusplexus-component-metadata${plexusComponentVersion}org.apache.maven.pluginsmaven-resources-plugin3.1.0org.apache.maven.pluginsmaven-compiler-plugin3.8.1org.apache.maven.pluginsmaven-surefire-plugin3.0.0-M4org.apache.maven.pluginsmaven-dependency-plugin3.1.1org.codehaus.mojoversions-maven-plugin2.7org.apache.maven.pluginsmaven-jar-plugin3.2.0org.apache.maven.pluginsmaven-source-plugin3.2.1org.apache.maven.pluginsmaven-javadoc-plugin3.1.1128m512mtruepackagetrueorg.apache.maven.pluginsmaven-site-plugin3.8.2com.github.githubsite-maven-plugin0.12org.apache.maven.pluginsmaven-install-plugin3.0.0-M1org.apache.maven.pluginsmaven-release-plugin3.0.0-M1org.apache.maven.pluginsmaven-deploy-plugin3.0.0-M1org.apache.maven.pluginsmaven-enforcer-pluginenforce-build-environmentenforce[${mavenVersion},)[${java.sdk.version},)trueenforce-dependency-convergenceverifyenforcefalseenforce-latest-dependency-versionsverifyenforcefalseorg.apache.maven.pluginsmaven-toolchains-plugintruedefault-toolchainvalidatetoolchain[${java.sdk.version},)org.apache.maven.pluginsmaven-plugin-plugin${goalPrefix}default-descriptorprocess-classesdescriptorgenerate-helpmojohelpmojoorg.xolstice.maven.plugin.protobuforg.codehaus.plexusplexus-component-metadatagenerate-metadatagenerate-test-metadataorg.apache.maven.pluginsmaven-compiler-plugintrue${java.compiler.compilerVersion}${java.compiler.source}${java.compiler.target}truetrue-Xlint:all-Xlint:allorg.apache.maven.pluginsmaven-release-pluginfalserelease-P run-itstrueorg.codehaus.mojoversions-maven-pluginverifydisplay-dependency-updatesdisplay-plugin-updatesdisplay-property-updatesorg.apache.maven.pluginsmaven-dependency-plugindisplay-dependency-treeverifytreeorg.apache.maven.pluginsmaven-site-plugintruecom.github.githubsite-maven-plugingithub-sitesitesite-deployCreate website for ${project.artifactId}-${project.version}falsetruegithuborg.apache.maven.pluginsmaven-project-info-reports-plugin3.0.0falseorg.apache.maven.pluginsmaven-plugin-plugin3.6.0${goalPrefix}org.apache.maven.pluginsmaven-javadoc-plugin3.1.1128m512mtruepackagetruejavadoc-no-forkorg.codehaus.mojoversions-maven-plugin2.7dependency-updates-reportplugin-updates-reportproperty-updates-reportorg.apache.maven.pluginsmaven-changes-plugin2.12.1changes-reportrun-itsorg.apache.maven.pluginsmaven-invoker-plugin3.2.1falsesrc/it*/pom.xmldependencies/pom.xmlsetup*/pom.xmlverify${project.build.directory}/local-reposrc/it/settings.xml${project.build.directory}/itfromExecPropsintegration-testinstallrunorg.apache.maven.pluginsmaven-invoker-plugin3.2.1releaseorg.apache.maven.pluginsmaven-source-pluginattach-sourcesjar-no-forkorg.apache.maven.pluginsmaven-javadoc-pluginattach-javadocsjarorg.apache.mavenmaven-plugin-api${mavenVersion}org.codehaus.plexusplexus-component-annotationsorg.codehaus.plexusplexus-utilsorg.apache.maven.plugin-toolsmaven-plugin-annotations${pluginToolsVersion}org.apache.mavenmaven-artifactorg.codehaus.plexusplexus-utils${plexusUtilsVersion}org.codehaus.plexusplexus-component-annotations${plexusComponentVersion}org.sonatype.plexusplexus-build-api0.0.7org.codehaus.plexusplexus-utilsorg.apache.mavenmaven-core${mavenVersion}org.codehaus.plexusplexus-component-annotationsorg.codehaus.plexusplexus-utilscom.google.guavaguavaorg.apache.mavenmaven-artifact${mavenVersion}org.codehaus.plexusplexus-utilsorg.apache.mavenmaven-compat${mavenVersion}org.codehaus.plexusplexus-component-annotationsorg.codehaus.plexusplexus-utilscom.google.guavaguava
================================================
FILE: src/changes/changes.xml
================================================
Fix file descriptor leak.
Support passing options to the Java compiler.
Allowed more flexibility in specifying input proto files.
Versioned file extensions (e.g. .proto2, .proto3) can be used.
Removed common goal properties and logic for generating descriptor sets.
Instead, two additional goals were introduced for descriptor set generation.
Removed support for JavaNano generator.
Provided origin information for WinRun4J binaries.
Use pb instead of protobin as file extension for binary descriptors.
Set clearOutputDirectory parameter to false by default.
Java 1.8 and Maven 3.3.9 are now minimum required versions for running the plugin.
More detailed error message.
Address vulnerabilities reported by Snyk.
Add useArgumentFile option to help with "Command line is too long" error.
Added CI configurations.
Added new goals to generate C# sources from protobuf definitions.
Added new goals to generate JavaScript sources from protobuf definitions.
Added licence and copyright information and prepared for the first release into Maven Central.
Renamed project coordinates and java packages.
Obsolete goal 'testCompile' has been removed.
Added support for including source info in descriptor sets.
Added support for JavaNano generator (requires protobuf compiler version 3 or above).
Made the order of imports predictable and matching the order of dependencies.
Fixed release configuration.
Added an option to download protoc binary artifact from Maven repo.
Generated descriptor set can be attached to the build.
Added new goals to use custom native protoc plugins.
Added new parameter 'attachProtoSources', which controls whether the source protobuf files
are attached to the build and included into the final artifact.
Fixed toolchain support that was broken by incompatible changes in Maven 3.2.5.
Maven 3.0 is now a minimum required version for running the plugin.
Java 1.6 is now a minimum required version for running the plugin.
A new option to suppress clearing of the output directory.
Added new goals to generate C++ and Python sources from protobuf definitions.
Goal 'testCompile' has been renamed into 'test-compile'
(the old goal still remains for backward compatibility).
Removed direct dependency on Aether library, and used injected Maven components for artifact resolution.
Allowed to specify classifier in java protoc plugin definition.
Allowed to use version range specifications in java protoc plugin definition.
Removed 'scope' parameter from java protoc plugin definition.
It has never been used, and any scope other than "runtime" is unlikely to work correctly.
Integration tests for java protoc plugins.
Support for running java protoc plugins on 64-bit Windows platform.
Fixed integration into Eclipse lifecycle (library version conflict)
Support for java-based plugins for protoc compiler.
Generation of binary descriptor sets.
Upgraded required Maven version to 2.2.1.
Updated to the latest versions of Maven plugins.
Switched to using Java 5 Mojo annotations for plugin metadata.
Integration into Eclipse lifecycle (supported by M2E 1.1 and later)
Added protobuf toolchain extension for use by maven-toolchains-plugin.
Integrated protobuf toolchain into plugin execution.
Additional debug logging is produced when Maven runs in verbose mode.
Added a suite of integration tests.
Created content for the Maven-generated web site.
Updated documentation in source code.
Updated Mojo documentation.
Updated Mojo annotations for Maven3 (marked plugin as thread-safe for parallel module builds).
Allowed protoc executable to be specified when invoking plugin from command line.
Added options to suppress plugin execution.
Enabled test protobuf definitions to import production definitions from the same module.
Fixed importing protobuf definitions from other projects or modules when namespaces are used.
================================================
FILE: src/it/TEST-1/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that protoc location is picked up from 'protobuf' tool chain, \
and proto compilation completes successfully.
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean compile
================================================
FILE: src/it/TEST-1/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-11.0.0Integration Test 1[3.4.0,3.5.0)org.apache.maven.pluginsmaven-toolchains-pluginprotobuf-toolchainvalidatetoolchain${protobufVersion}org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@truecompile
================================================
FILE: src/it/TEST-1/src/main/proto/test.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "test";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage {
message NestedMessage {
int32 bb = 1;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}
// Singular
int32 optional_int32 = 1;
}
================================================
FILE: src/it/TEST-1/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'test/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package test');
assert content.contains('class Test');
assert content.contains('class TestMessage');
return true;
================================================
FILE: src/it/TEST-10/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that protobuf definitions can be imported from other modules in the reactor. \
In this test, imports are scoped to the default package.
invoker.goals = clean compile
================================================
FILE: src/it/TEST-10/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-10-parent1.0.0pomIntegration Test 10 (Parent)project1project2org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-10/project1/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-10-parent1.0.0test-10-project1Integration Test 10 (1)org.xolstice.maven.pluginsprotobuf-maven-plugincompile
================================================
FILE: src/it/TEST-10/project1/src/main/proto/test1.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "it.project1.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage1 {
}
================================================
FILE: src/it/TEST-10/project2/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-10-parent1.0.0test-10-project2Integration Test 10 (2)org.xolstice.maven.pluginsprotobuf-maven-plugincompile${project.groupId}test-10-project11.0.0
================================================
FILE: src/it/TEST-10/project2/src/main/proto/test2.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
import "test1.proto";
option java_package = "it.project2.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage2 {
TestMessage1 included = 1;
}
================================================
FILE: src/it/TEST-10/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'project1/target/generated-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project1/messages/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project1.messages');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage1');
outputDirectory = new File(basedir, 'project2/target/generated-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project2/messages/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project2.messages');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage2');
return true;
================================================
FILE: src/it/TEST-11/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that protobuf definitions can be imported from other modules in the reactor. \
The dependency has type of 'test-jar' (test protobuf files import \
test protobuf files from another module). \
In this test, imports are scoped to packages. \
We need to make sure that package structure for protobuf definitions \
is preserved in packaged jars, and correctly restored for importing.
invoker.goals = clean test-compile
================================================
FILE: src/it/TEST-11/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-11-parent1.0.0pomIntegration Test 11 (Parent)project1project2org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-11/project1/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-11-parent1.0.0test-11-project1Integration Test 11 (1)org.xolstice.maven.pluginsprotobuf-maven-plugintest-compileorg.apache.maven.pluginsmaven-jar-plugintest-jar
================================================
FILE: src/it/TEST-11/project1/src/test/proto/it/project1/test1.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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 it.project1;
option java_package = "it.project1.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage1 {
}
================================================
FILE: src/it/TEST-11/project2/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-11-parent1.0.0test-11-project2Integration Test 11 (2)org.xolstice.maven.pluginsprotobuf-maven-plugintest-compile${project.groupId}test-11-project11.0.0test-jartest
================================================
FILE: src/it/TEST-11/project2/src/test/proto/it/project2/test2.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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 it.project2;
import "it/project1/test1.proto";
option java_package = "it.project2.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage2 {
it.project1.TestMessage1 included = 1;
}
================================================
FILE: src/it/TEST-11/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'project1/target/generated-test-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project1/messages/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project1.messages');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage1');
outputDirectory = new File(basedir, 'project2/target/generated-test-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project2/messages/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project2.messages');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage2');
return true;
================================================
FILE: src/it/TEST-12/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that protobuf definitions can be imported from other modules in the reactor. \
In this test, imports are scoped to the default package.
invoker.goals = clean test-compile
================================================
FILE: src/it/TEST-12/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-12-parent1.0.0pomIntegration Test 12 (Parent)project1project2org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-12/project1/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-12-parent1.0.0test-12-project1Integration Test 12 (1)org.xolstice.maven.pluginsprotobuf-maven-plugintest-compileorg.apache.maven.pluginsmaven-jar-plugintest-jar
================================================
FILE: src/it/TEST-12/project1/src/test/proto/test1.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "it.project1.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage1 {
}
================================================
FILE: src/it/TEST-12/project2/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-12-parent1.0.0test-12-project2Integration Test 12 (2)org.xolstice.maven.pluginsprotobuf-maven-plugintest-compile${project.groupId}test-12-project11.0.0test-jartest
================================================
FILE: src/it/TEST-12/project2/src/test/proto/test2.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
import "test1.proto";
option java_package = "it.project2.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage2 {
TestMessage1 included = 1;
}
================================================
FILE: src/it/TEST-12/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'project1/target/generated-test-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project1/messages/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project1.messages');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage1');
outputDirectory = new File(basedir, 'project2/target/generated-test-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project2/messages/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project2.messages');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage2');
return true;
================================================
FILE: src/it/TEST-13/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that production protobuf definitions can be imported into test protobuf definitions \
within the same module. \
In this test, imports are scoped to packages. \
We need to make sure that package structure for protobuf definitions \
is correctly handled by the plugin.
invoker.goals = clean test-compile
================================================
FILE: src/it/TEST-13/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-131.0.0Integration Test 13org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@compiletest-compile
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-13/src/main/proto/it/project1/test1.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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 it.project1;
option java_package = "it.project1.messages";
option java_outer_classname = "TestProtos1";
option optimize_for = SPEED;
message TestMessage1 {
}
================================================
FILE: src/it/TEST-13/src/test/proto/it/project1/test2.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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 it.project1;
import "it/project1/test1.proto";
option java_package = "it.project1.messages";
option java_outer_classname = "TestProtos2";
option optimize_for = SPEED;
message TestMessage2 {
it.project1.TestMessage1 included = 1;
}
================================================
FILE: src/it/TEST-13/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project1/messages/TestProtos1.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project1.messages');
assert content.contains('class TestProtos1');
assert content.contains('class TestMessage1');
outputDirectory = new File(basedir, 'target/generated-test-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project1/messages/TestProtos2.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project1.messages');
assert content.contains('class TestProtos2');
assert content.contains('class TestMessage2');
return true;
================================================
FILE: src/it/TEST-14/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that production protobuf definitions can be imported into test protobuf definitions \
within the same module. \
In this test, imports are scoped to the default package.
invoker.goals = clean test-compile
================================================
FILE: src/it/TEST-14/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-141.0.0Integration Test 14org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@compiletest-compile
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-14/src/main/proto/test1.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "it.project1.messages";
option java_outer_classname = "TestProtos1";
option optimize_for = SPEED;
message TestMessage1 {
}
================================================
FILE: src/it/TEST-14/src/test/proto/test2.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
import "test1.proto";
option java_package = "it.project1.messages";
option java_outer_classname = "TestProtos2";
option optimize_for = SPEED;
message TestMessage2 {
TestMessage1 included = 1;
}
================================================
FILE: src/it/TEST-14/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project1/messages/TestProtos1.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project1.messages');
assert content.contains('class TestProtos1');
assert content.contains('class TestMessage1');
outputDirectory = new File(basedir, 'target/generated-test-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project1/messages/TestProtos2.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project1.messages');
assert content.contains('class TestProtos2');
assert content.contains('class TestMessage2');
return true;
================================================
FILE: src/it/TEST-15/invoker.properties
================================================
#
# Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that a protobuf file descriptor set is written in the expected location.
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean generate-resources
================================================
FILE: src/it/TEST-15/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-151.0.0Integration Test 15org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@compile-descriptor-set
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-15/src/main/proto/test.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "test";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage {
message NestedMessage {
int32 bb = 1;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}
// Singular
int32 optional_int32 = 1;
}
================================================
FILE: src/it/TEST-15/verify.groovy
================================================
/*
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-resources/protobuf/descriptor-sets')
assert outputDirectory.exists()
assert outputDirectory.isDirectory()
generatedDescriptorFile = new File(outputDirectory, 'test-15-1.0.0.pb')
assert generatedDescriptorFile.exists()
assert generatedDescriptorFile.isFile()
return true
================================================
FILE: src/it/TEST-16/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that a custom protoc plugin is invoked
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean compile
#invoker.mavenOpts = -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
================================================
FILE: src/it/TEST-16/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-161.0.0Integration Test 163.4.0org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@custom-protoc-generatecompileminimalorg.xolstice.maven.plugins.protobuf.itstest-protoc-plugin1.0.5org.xolstice.protobuf.plugin.minimal.MinimalPluginprefixorg.xolstice.maven.plugins.protobuf.itstest-protoc-plugin[1.0.0,1.1.0)org.xolstice.protobuf.plugin.minimal.MinimalPluginprefix-
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-16/src/main/proto/test1.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "test1";
option java_outer_classname = "Test1Protos";
option optimize_for = SPEED;
message TestMessage1 {
message NestedMessage {
int32 bb = 1;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}
// Singular
int32 optional_int32 = 1;
}
================================================
FILE: src/it/TEST-16/src/main/proto/test2.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "test2";
option java_outer_classname = "Test2Protos";
option optimize_for = SPEED;
message TestMessage2 {
message NestedMessage {
int32 bb = 1;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}
// Singular
int32 optional_int32 = 1;
}
================================================
FILE: src/it/TEST-16/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
def assertGeneratedFile(outputDirectory, fname, content) {
genFile = new File(outputDirectory, fname)
assert genFile.exists()
assert genFile.isFile()
assert genFile.text == content
}
outputDirectory = new File(basedir, 'target/generated-sources/protobuf/java')
assert outputDirectory.exists()
assert outputDirectory.isDirectory()
assertGeneratedFile(outputDirectory, 'test1.txt', 'test1.proto')
assertGeneratedFile(outputDirectory, 'prefix-test1.txt', 'test1.proto')
assertGeneratedFile(outputDirectory, 'test2.txt', 'test2.proto')
assertGeneratedFile(outputDirectory, 'prefix-test2.txt', 'test2.proto')
return true
================================================
FILE: src/it/TEST-17/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that the execution fails if the artifact for java protoc plugin cannot be resolved.
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean compile
# The expected result of the build, possible values are "success" (default) and "failure"
invoker.buildResult = failure
================================================
FILE: src/it/TEST-17/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-171.0.0Integration Test 173.4.0org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@custom-protoc-generatecompilemissingorg.xolstice.maven.plugins.protobuf.itstest-protoc-plugin2.0.0org.xolstice.protobuf.plugin.minimal.MinimalPlugin
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-17/src/main/proto/test.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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.
//
option java_package = "test";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage {
message NestedMessage {
int32 bb = 1;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}
// Singular
int32 optional_int32 = 1;
}
================================================
FILE: src/it/TEST-18/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that protoc location is picked up from 'protobuf' tool chain, \
and proto compilation into Python completes successfully.
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean compile
================================================
FILE: src/it/TEST-18/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-181.0.0Integration Test 18org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@compile-python
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-18/src/main/proto/test.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "test";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage {
message NestedMessage {
int32 bb = 1;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}
// Singular
int32 optional_int32 = 1;
}
================================================
FILE: src/it/TEST-18/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-sources/protobuf/python');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedPythonFile = new File(outputDirectory, 'test_pb2.py');
assert generatedPythonFile.exists();
assert generatedPythonFile.isFile();
content = generatedPythonFile.text;
assert content.contains('TestMessage');
assert content.contains('NestedMessage');
return true;
================================================
FILE: src/it/TEST-19/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that protoc location is picked up from 'protobuf' tool chain, \
and test proto compilation into Python completes successfully.
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean test-compile
================================================
FILE: src/it/TEST-19/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-191.0.0Integration Test 19org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@test-compile-python
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-19/src/test/proto/test.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "test";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage {
message NestedMessage {
int32 bb = 1;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}
// Singular
int32 optional_int32 = 1;
}
================================================
FILE: src/it/TEST-19/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-test-sources/protobuf/python');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedPythonFile = new File(outputDirectory, 'test_pb2.py');
assert generatedPythonFile.exists();
assert generatedPythonFile.isFile();
content = generatedPythonFile.text;
assert content.contains('TestMessage');
assert content.contains('NestedMessage');
return true;
================================================
FILE: src/it/TEST-2/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that the custom 'protobuf' tool chain is picked up by maven-toolchains-plugin \
as long as protobuf-maven-plugin registers its extensions with maven build. \
No executions for protobuf-maven-plugin itself are defined in the test pom.
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean validate
================================================
FILE: src/it/TEST-2/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-21.0.0Integration Test 2[3.4.0,3.5.0)org.apache.maven.pluginsmaven-toolchains-pluginprotobuf-toolchainvalidatetoolchain${protobufVersion}org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@true
================================================
FILE: src/it/TEST-2/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
buildLogFile = new File(basedir, 'build.log');
assert buildLogFile.exists();
assert buildLogFile.isFile();
content = buildLogFile.text;
assert content.contains('Found matching toolchain for type protobuf: PROTOC');
return true;
================================================
FILE: src/it/TEST-20/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that protoc location is picked up from 'protobuf' tool chain, \
and proto compilation into C++ completes successfully.
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean compile
================================================
FILE: src/it/TEST-20/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-201.0.0Integration Test 20org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@compile-cpp
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-20/src/main/proto/test.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "test";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage {
message NestedMessage {
int32 bb = 1;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}
// Singular
int32 optional_int32 = 1;
}
================================================
FILE: src/it/TEST-20/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-sources/protobuf/cpp');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedHeaderFile = new File(outputDirectory, 'test.pb.h');
assert generatedHeaderFile.exists();
assert generatedHeaderFile.isFile();
content = generatedHeaderFile.text;
assert content.contains('class TestMessage');
assert content.contains('class TestMessage_NestedMessage');
assert content.contains('enum TestMessage_NestedEnum');
generatedClassFile = new File(outputDirectory, 'test.pb.cc');
assert generatedClassFile.exists();
assert generatedClassFile.isFile();
content = generatedClassFile.text;
assert content.contains('TestMessage::TestMessage()');
assert content.contains('TestMessage_NestedMessage::TestMessage_NestedMessage()');
return true;
================================================
FILE: src/it/TEST-21/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that protoc location is picked up from 'protobuf' tool chain, \
and test proto compilation into C++ completes successfully.
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean test-compile
================================================
FILE: src/it/TEST-21/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-211.0.0Integration Test 21org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@test-compile-cpp
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-21/src/test/proto/test.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "test";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage {
message NestedMessage {
int32 bb = 1;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}
// Singular
int32 optional_int32 = 1;
}
================================================
FILE: src/it/TEST-21/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-test-sources/protobuf/cpp');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedHeaderFile = new File(outputDirectory, 'test.pb.h');
assert generatedHeaderFile.exists();
assert generatedHeaderFile.isFile();
content = generatedHeaderFile.text;
assert content.contains('class TestMessage');
assert content.contains('class TestMessage_NestedMessage');
assert content.contains('enum TestMessage_NestedEnum');
generatedClassFile = new File(outputDirectory, 'test.pb.cc');
assert generatedClassFile.exists();
assert generatedClassFile.isFile();
content = generatedClassFile.text;
assert content.contains('TestMessage::TestMessage()');
assert content.contains('TestMessage_NestedMessage::TestMessage_NestedMessage()');
return true;
================================================
FILE: src/it/TEST-22/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that protoc location is picked up from 'protobuf' tool chain, \
proto compilation into java completes successfully \
and protobuf sources are attached to the build.
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean package
================================================
FILE: src/it/TEST-22/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-221.0.0Integration Test 22org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@compiletest-compile
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-22/src/main/proto/a/aaa.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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 a;
option java_package = "a";
option java_outer_classname = "AaaProtos";
option optimize_for = SPEED;
message Aaa {
int32 a = 1;
}
================================================
FILE: src/it/TEST-22/src/test/proto/b/bbb.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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 b;
option java_package = "b";
option java_outer_classname = "BbbProtos";
option optimize_for = SPEED;
message Bbb {
int32 b = 1;
}
================================================
FILE: src/it/TEST-22/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
generatedJavaFile = new File(basedir, 'target/classes/a/AaaProtos.class');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
attachedResource = new File(basedir, 'target/classes/a/aaa.proto');
assert attachedResource.exists();
assert attachedResource.isFile();
generatedJavaTestFile = new File(basedir, 'target/test-classes/b/BbbProtos.class');
assert generatedJavaTestFile.exists();
assert generatedJavaTestFile.isFile();
attachedTestResource = new File(basedir, 'target/test-classes/b/bbb.proto');
assert attachedTestResource.exists();
assert attachedTestResource.isFile();
return true;
================================================
FILE: src/it/TEST-23/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that protoc location is picked up from 'protobuf' tool chain, \
proto compilation into java completes successfully \
and protobuf sources are NOT attached to the build.
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean package
================================================
FILE: src/it/TEST-23/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-231.0.0Integration Test 23org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@compiletest-compilefalse
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-23/src/main/proto/a/aaa.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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 a;
option java_package = "a";
option java_outer_classname = "AaaProtos";
option optimize_for = SPEED;
message Aaa {
int32 a = 1;
}
================================================
FILE: src/it/TEST-23/src/test/proto/b/bbb.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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 b;
option java_package = "b";
option java_outer_classname = "BbbProtos";
option optimize_for = SPEED;
message Bbb {
int32 b = 1;
}
================================================
FILE: src/it/TEST-23/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
generatedJavaFile = new File(basedir, 'target/classes/a/AaaProtos.class');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
attachedResource = new File(basedir, 'target/classes/a/aaa.proto');
assert !attachedResource.exists();
generatedJavaTestFile = new File(basedir, 'target/test-classes/b/BbbProtos.class');
assert generatedJavaTestFile.exists();
assert generatedJavaTestFile.isFile();
attachedTestResource = new File(basedir, 'target/test-classes/b/bbb.proto');
assert !attachedTestResource.exists();
return true;
================================================
FILE: src/it/TEST-24/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that protobuf descriptor set can be attached to the build and resolved in other modules in the reactor.
invoker.goals = clean install
================================================
FILE: src/it/TEST-24/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-24-parent1.0.0pomIntegration Test 24 (Parent)project1project2org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-24/project1/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-24-parent1.0.0test-24-project1Integration Test 24 (1)org.xolstice.maven.pluginsprotobuf-maven-plugincompile-descriptor-settrue
================================================
FILE: src/it/TEST-24/project1/src/main/proto/it/project1/test1.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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 it.project1;
option java_package = "it.project1.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage1 {
}
================================================
FILE: src/it/TEST-24/project2/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-24-parent1.0.0test-24-project2Integration Test 24 (2)org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@org.apache.maven.pluginsmaven-dependency-plugin3.1.1copy-dependencies${project.groupId}test-24-project1pb${project.groupId}test-24-project11.0.0pb
================================================
FILE: src/it/TEST-24/verify.groovy
================================================
/*
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'project2/target/dependency')
assert outputDirectory.exists()
assert outputDirectory.isDirectory()
generatedDescriptorFile = new File(outputDirectory, 'test-24-project1-1.0.0.pb')
assert generatedDescriptorFile.exists()
assert generatedDescriptorFile.isFile()
return true
================================================
FILE: src/it/TEST-25/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = Verifies that protoc artifact can be downloaded from Maven repository.
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean generate-sources
================================================
FILE: src/it/TEST-25/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-251.0.0Integration Test 253.4.0org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@compile
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-25/src/main/proto/test.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "test";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage {
}
================================================
FILE: src/it/TEST-25/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'test/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package test');
assert content.contains('class Test');
assert content.contains('class TestMessage');
return true;
================================================
FILE: src/it/TEST-26/invoker.properties
================================================
#
# Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that a test protobuf file descriptor set is written in the expected location.
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean generate-test-resources
================================================
FILE: src/it/TEST-26/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-261.0.0Integration Test 26org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@test-compile-descriptor-set
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-26/src/test/proto/test.proto
================================================
//
// Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "test";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage {
message NestedMessage {
int32 bb = 1;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}
// Singular
int32 optional_int32 = 1;
}
================================================
FILE: src/it/TEST-26/verify.groovy
================================================
/*
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-test-resources/protobuf/descriptor-sets')
assert outputDirectory.exists()
assert outputDirectory.isDirectory()
generatedDescriptorFile = new File(outputDirectory, 'test-26-1.0.0.pb')
assert generatedDescriptorFile.exists()
assert generatedDescriptorFile.isFile()
return true
================================================
FILE: src/it/TEST-27/invoker.properties
================================================
#
# Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that a test protobuf descriptor set can be attached to the build and resolved in other modules in the reactor.
invoker.goals = clean install
================================================
FILE: src/it/TEST-27/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-27-parent1.0.0pomIntegration Test 27 (Parent)project1project2org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-27/project1/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-27-parent1.0.0test-27-project1Integration Test 27 (1)org.xolstice.maven.pluginsprotobuf-maven-plugintest-compile-descriptor-settrue
================================================
FILE: src/it/TEST-27/project1/src/test/proto/it/project1/test1.proto
================================================
//
// Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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 it.project1;
option java_package = "it.project1.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage1 {
}
================================================
FILE: src/it/TEST-27/project2/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-27-parent1.0.0test-27-project2Integration Test 27 (2)org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@org.apache.maven.pluginsmaven-dependency-plugin3.1.1copy-dependencies${project.groupId}test-27-project1test-pb${project.groupId}test-27-project11.0.0test-pbtesttest
================================================
FILE: src/it/TEST-27/verify.groovy
================================================
/*
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'project2/target/dependency')
assert outputDirectory.exists()
assert outputDirectory.isDirectory()
generatedDescriptorFile = new File(outputDirectory, 'test-27-project1-1.0.0-test.pb')
assert generatedDescriptorFile.exists()
assert generatedDescriptorFile.isFile()
return true
================================================
FILE: src/it/TEST-28/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = Verifies that a binary artifact for a protoc plugin can be downloaded from Maven repository.
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean package
================================================
FILE: src/it/TEST-28/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-281.0.0Integration Test 281.7.0org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@protoc-compilegenerate-sourcescompilecompile-customprotoc-test-compilegenerate-test-sourcestest-compiletest-compile-custom
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
grpc
io.grpc:protoc-gen-grpc-java:${grpcVersion}:exe:${os.detected.classifier}
io.grpcgrpc-netty${grpcVersion}io.grpcgrpc-protobuf${grpcVersion}io.grpcgrpc-stub${grpcVersion}
================================================
FILE: src/it/TEST-28/src/main/proto/test.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "test";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage {
message NestedMessage {
int32 zz = 1;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}
// Singular
int32 xx = 1;
repeated NestedEnum yy = 2;
}
service MyService {
rpc MyMethod(TestMessage) returns(TestMessage) {}
}
================================================
FILE: src/it/TEST-28/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'test/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package test');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage');
outputDirectory = new File(basedir, 'target/generated-sources/protobuf/grpc');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'test/MyServiceGrpc.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package test');
assert content.contains('class MyServiceGrpc');
assert content.contains('class MyServiceStub');
return true;
================================================
FILE: src/it/TEST-29/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = Verifies that protoc can be invoked with an @args file and that unicode file names are properly handled.
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean generate-sources
================================================
FILE: src/it/TEST-29/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-291.0.0Integration Test 29org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@compiletrue
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-29/src/main/proto/test.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "test";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage {
}
================================================
FILE: src/it/TEST-29/src/main/proto/тест.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "test";
option java_outer_classname = "TestProtosRu";
option optimize_for = SPEED;
message TestMessageRu {
}
================================================
FILE: src/it/TEST-29/src/main/proto/テスト.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "test";
option java_outer_classname = "TestProtosJp";
option optimize_for = SPEED;
message TestMessageJp {
}
================================================
FILE: src/it/TEST-29/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'test/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package test');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage');
generatedJavaFile = new File(outputDirectory, 'test/TestProtosJp.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package test');
assert content.contains('class TestProtosJp');
assert content.contains('class TestMessageJp');
generatedJavaFile = new File(outputDirectory, 'test/TestProtosRu.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package test');
assert content.contains('class TestProtosRu');
assert content.contains('class TestMessageRu');
return true;
================================================
FILE: src/it/TEST-3/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that the custom 'protobuf' tool chain cannot be picked up by maven-toolchains-plugin \
if protobuf-maven-plugin does not register its extensions with maven build.
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean validate
# The expected result of the build, possible values are "success" (default) and "failure"
invoker.buildResult = failure
================================================
FILE: src/it/TEST-3/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-31.0.0Integration Test 3[3.4.0,3.5.0)org.apache.maven.pluginsmaven-toolchains-pluginprotobuf-toolchainvalidatetoolchain${protobufVersion}
================================================
FILE: src/it/TEST-30/invoker.properties
================================================
#
# Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description=\
Verifies that protoc location is picked up from 'protobuf' tool chain, \
and proto compilation into C# completes successfully.
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals=clean generate-sources
================================================
FILE: src/it/TEST-30/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-301.0.0Integration Test 30org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@compile-csharp
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-30/src/main/proto/test.proto
================================================
//
// Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option csharp_namespace = "Test";
option optimize_for = SPEED;
message TestMessage {
message NestedMessage {
int32 bb = 1;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}
// Singular
int32 optional_int32 = 1;
}
================================================
FILE: src/it/TEST-30/verify.groovy
================================================
/*
* Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-sources/protobuf/csharp');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedFile = new File(outputDirectory, 'Test.cs');
assert generatedFile.exists();
assert generatedFile.isFile();
content = generatedFile.text;
assert content.contains('TestMessage');
assert content.contains('NestedMessage');
return true;
================================================
FILE: src/it/TEST-31/invoker.properties
================================================
#
# Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description=\
Verifies that protoc location is picked up from 'protobuf' tool chain, \
and test proto compilation into C# completes successfully.
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals=clean generate-test-sources
================================================
FILE: src/it/TEST-31/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-311.0.0Integration Test 31org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@test-compile-csharp
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-31/src/test/proto/test.proto
================================================
//
// Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option csharp_namespace = "Test";
option optimize_for = SPEED;
message TestMessage {
message NestedMessage {
int32 bb = 1;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}
// Singular
int32 optional_int32 = 1;
}
================================================
FILE: src/it/TEST-31/verify.groovy
================================================
/*
* Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-test-sources/protobuf/csharp');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedFile = new File(outputDirectory, 'Test.cs');
assert generatedFile.exists();
assert generatedFile.isFile();
content = generatedFile.text;
assert content.contains('TestMessage');
assert content.contains('NestedMessage');
return true;
================================================
FILE: src/it/TEST-32/invoker.properties
================================================
#
# Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description=Verifies that JavaScript generation works
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals=clean generate-sources
================================================
FILE: src/it/TEST-32/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-321.0.0Integration Test 32org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@compile-js
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-32/src/main/proto/test.proto
================================================
//
// Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
message TestMessage {
message NestedMessage {
int32 bb = 1;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}
// Singular
int32 optional_int32 = 1;
}
================================================
FILE: src/it/TEST-32/verify.groovy
================================================
/*
* Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-sources/protobuf/js');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedFile = new File(outputDirectory, 'testmessage.js');
assert generatedFile.exists();
assert generatedFile.isFile();
content = generatedFile.text;
assert content.contains('TestMessage');
assert content.contains('NestedMessage');
return true;
================================================
FILE: src/it/TEST-33/invoker.properties
================================================
#
# Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description=Verifies that JavaScript generation works, using additional generator options
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals=clean generate-sources
================================================
FILE: src/it/TEST-33/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-331.0.0Integration Test 33org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@compile-jsimport_style=commonjs,binary
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-33/src/main/proto/test.proto
================================================
//
// Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
message TestMessage {
message NestedMessage {
int32 bb = 1;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}
// Singular
int32 optional_int32 = 1;
}
================================================
FILE: src/it/TEST-33/verify.groovy
================================================
/*
* Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-sources/protobuf/js');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedFile = new File(outputDirectory, 'test_pb.js');
assert generatedFile.exists();
assert generatedFile.isFile();
content = generatedFile.text;
assert content.contains('TestMessage');
assert content.contains('NestedMessage');
return true;
================================================
FILE: src/it/TEST-34/invoker.properties
================================================
#
# Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description=Verifies that JavaScript generation works for test protos
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals=clean generate-test-sources
================================================
FILE: src/it/TEST-34/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-341.0.0Integration Test 34org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@test-compile-js
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-34/src/test/proto/test.proto
================================================
//
// Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
message TestMessage {
message NestedMessage {
int32 bb = 1;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}
// Singular
int32 optional_int32 = 1;
}
================================================
FILE: src/it/TEST-34/verify.groovy
================================================
/*
* Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-test-sources/protobuf/js');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedFile = new File(outputDirectory, 'testmessage.js');
assert generatedFile.exists();
assert generatedFile.isFile();
content = generatedFile.text;
assert content.contains('TestMessage');
assert content.contains('NestedMessage');
return true;
================================================
FILE: src/it/TEST-35/invoker.properties
================================================
#
# Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description=Verifies that JavaScript generation works for test protos, using additional generator options
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals=clean generate-test-sources
================================================
FILE: src/it/TEST-35/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-351.0.0Integration Test 35org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@test-compile-jsimport_style=commonjs,binary
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-35/src/test/proto/test.proto
================================================
//
// Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
message TestMessage {
message NestedMessage {
int32 bb = 1;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}
// Singular
int32 optional_int32 = 1;
}
================================================
FILE: src/it/TEST-35/verify.groovy
================================================
/*
* Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-test-sources/protobuf/js');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedFile = new File(outputDirectory, 'test_pb.js');
assert generatedFile.exists();
assert generatedFile.isFile();
content = generatedFile.text;
assert content.contains('TestMessage');
assert content.contains('NestedMessage');
return true;
================================================
FILE: src/it/TEST-36/invoker.properties
================================================
#
# Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description=Verifies that Java generation works for lite runtime, using additional generator options
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals=clean compile
================================================
FILE: src/it/TEST-36/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-361.0.0Integration Test 36protobuf-javaliteorg.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@compilelite
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-36/src/main/proto/test.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "test";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage {
message NestedMessage {
int32 bb = 1;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}
// Singular
int32 optional_int32 = 1;
}
================================================
FILE: src/it/TEST-36/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'test/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package test');
assert content.contains('class Test');
assert content.contains('class TestMessage');
assert content.contains('com.google.protobuf.GeneratedMessageLite');
return true;
================================================
FILE: src/it/TEST-37/invoker.properties
================================================
#
# Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description=Verifies that Java generation works for test protos and lite runtime, using additional generator options
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals=clean test-compile
================================================
FILE: src/it/TEST-37/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-371.0.0Integration Test 37protobuf-javaliteorg.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@test-compilelite
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-37/src/test/proto/test.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "test";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage {
message NestedMessage {
int32 bb = 1;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}
// Singular
int32 optional_int32 = 1;
}
================================================
FILE: src/it/TEST-37/verify.groovy
================================================
/*
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'target/generated-test-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'test/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package test');
assert content.contains('class Test');
assert content.contains('class TestMessage');
assert content.contains('com.google.protobuf.GeneratedMessageLite');
return true;
================================================
FILE: src/it/TEST-4/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = Verifies that protoc location is reverted to default if unspecified.
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean generate-sources
# Possible values are "fail-fast" (default), "fail-at-end" and "fail-never"
invoker.failureBehavior = fail-never
================================================
FILE: src/it/TEST-4/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-41.0.0Integration Test 4org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@compile
================================================
FILE: src/it/TEST-4/src/main/proto/test.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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.
//
option java_package = "test";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage {
}
================================================
FILE: src/it/TEST-4/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
buildLogFile = new File(basedir, 'build.log');
assert buildLogFile.exists();
assert buildLogFile.isFile();
content = buildLogFile.text;
assert content.contains("No 'protocExecutable' parameter is configured, using the default: 'protoc'");
return true;
================================================
FILE: src/it/TEST-5/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that protobuf definitions can be imported from dependency jars. \
The dependency has the default type of 'jar' (main protobuf files import \
main protobuf files from another project). \
In this test, imports are scoped to packages. \
We need to make sure that package structure for protobuf definitions \
is preserved in packaged jars, and correctly restored for importing.
# STEP 1
# Build project1 and install into local repo
invoker.profiles.1 = build-project1
invoker.goals.1 = clean install
# STEP 2
# Build project2, which depends on project1
# This will test unpacking imports from project1 jar file
invoker.profiles.2 = build-project2
invoker.goals.2 = clean compile
================================================
FILE: src/it/TEST-5/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-5-parent1.0.0pomIntegration Test 5 (Parent)build-project1project1build-project2project2org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-5/project1/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-5-parent1.0.0test-5-project1Integration Test 5 (1)org.xolstice.maven.pluginsprotobuf-maven-plugincompile
================================================
FILE: src/it/TEST-5/project1/src/main/proto/it/project1/test1.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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 it.project1;
option java_package = "it.project1.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage1 {
}
================================================
FILE: src/it/TEST-5/project2/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-5-parent1.0.0test-5-project2Integration Test 5 (2)org.xolstice.maven.pluginsprotobuf-maven-plugincompile${project.groupId}test-5-project11.0.0
================================================
FILE: src/it/TEST-5/project2/src/main/proto/it/project2/test2.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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 it.project2;
import "it/project1/test1.proto";
option java_package = "it.project2.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage2 {
it.project1.TestMessage1 included = 1;
}
================================================
FILE: src/it/TEST-5/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'project1/target/generated-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project1/messages/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project1.messages');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage1');
outputDirectory = new File(basedir, 'project2/target/generated-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project2/messages/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project2.messages');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage2');
return true;
================================================
FILE: src/it/TEST-6/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that protobuf definitions can be imported from dependency jars. \
In this test, imports are scoped to the default package.
# STEP 1
# Build project1 and install into local repo
invoker.profiles.1 = build-project1
invoker.goals.1 = clean install
# STEP 2
# Build project2, which depends on project1
# This will test unpacking imports from project1 jar file
invoker.profiles.2 = build-project2
invoker.goals.2 = clean compile
================================================
FILE: src/it/TEST-6/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-6-parent1.0.0pomIntegration Test 6 (Parent)build-project1project1build-project2project2org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-6/project1/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-6-parent1.0.0test-6-project1Integration Test 6 (1)org.xolstice.maven.pluginsprotobuf-maven-plugincompile
================================================
FILE: src/it/TEST-6/project1/src/main/proto/test1.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "it.project1.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage1 {
}
================================================
FILE: src/it/TEST-6/project2/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-6-parent1.0.0test-6-project2Integration Test 6 (2)org.xolstice.maven.pluginsprotobuf-maven-plugincompile${project.groupId}test-6-project11.0.0
================================================
FILE: src/it/TEST-6/project2/src/main/proto/test2.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
import "test1.proto";
option java_package = "it.project2.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage2 {
TestMessage1 included = 1;
}
================================================
FILE: src/it/TEST-6/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'project1/target/generated-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project1/messages/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project1.messages');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage1');
outputDirectory = new File(basedir, 'project2/target/generated-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project2/messages/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project2.messages');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage2');
return true;
================================================
FILE: src/it/TEST-7/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that protobuf definitions can be imported from dependency jars. \
The dependency has type of 'test-jar' (test protobuf files import \
test protobuf files from another project). \
In this test, imports are scoped to packages. \
We need to make sure that package structure for protobuf definitions \
is preserved in packaged jars, and correctly restored for importing.
# STEP 1
# Build project1 and install into local repo
invoker.profiles.1 = build-project1
invoker.goals.1 = clean install
# STEP 2
# Build project2, which depends on project1
# This will test unpacking imports from project1 jar file
invoker.profiles.2 = build-project2
invoker.goals.2 = clean test-compile
================================================
FILE: src/it/TEST-7/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-7-parent1.0.0pomIntegration Test 7 (Parent)build-project1project1build-project2project2org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-7/project1/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-7-parent1.0.0test-7-project1Integration Test 7 (1)org.xolstice.maven.pluginsprotobuf-maven-plugintest-compileorg.apache.maven.pluginsmaven-jar-plugintest-jar
================================================
FILE: src/it/TEST-7/project1/src/test/proto/it/project1/test1.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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 it.project1;
option java_package = "it.project1.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage1 {
}
================================================
FILE: src/it/TEST-7/project2/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-7-parent1.0.0test-7-project2Integration Test 7 (2)org.xolstice.maven.pluginsprotobuf-maven-plugintest-compile${project.groupId}test-7-project11.0.0test-jartest
================================================
FILE: src/it/TEST-7/project2/src/test/proto/it/project2/test2.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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 it.project2;
import "it/project1/test1.proto";
option java_package = "it.project2.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage2 {
it.project1.TestMessage1 included = 1;
}
================================================
FILE: src/it/TEST-7/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'project1/target/generated-test-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project1/messages/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project1.messages');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage1');
outputDirectory = new File(basedir, 'project2/target/generated-test-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project2/messages/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project2.messages');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage2');
return true;
================================================
FILE: src/it/TEST-8/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that protobuf definitions can be imported from dependency jars. \
In this test, imports are scoped to the default package.
# STEP 1
# Build project1 and install into local repo
invoker.profiles.1 = build-project1
invoker.goals.1 = clean install
# STEP 2
# Build project2, which depends on project1
# This will test unpacking imports from project1 jar file
invoker.profiles.2 = build-project2
invoker.goals.2 = clean test-compile
================================================
FILE: src/it/TEST-8/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-8-parent1.0.0pomIntegration Test 8 (Parent)build-project1project1build-project2project2org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-8/project1/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-8-parent1.0.0test-8-project1Integration Test 8 (1)org.xolstice.maven.pluginsprotobuf-maven-plugintest-compileorg.apache.maven.pluginsmaven-jar-plugintest-jar
================================================
FILE: src/it/TEST-8/project1/src/test/proto/test1.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
option java_package = "it.project1.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage1 {
}
================================================
FILE: src/it/TEST-8/project2/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-8-parent1.0.0test-8-project2Integration Test 8 (2)org.xolstice.maven.pluginsprotobuf-maven-plugintest-compile${project.groupId}test-8-project11.0.0test-jartest
================================================
FILE: src/it/TEST-8/project2/src/test/proto/test2.proto
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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";
import "test1.proto";
option java_package = "it.project2.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage2 {
TestMessage1 included = 1;
}
================================================
FILE: src/it/TEST-8/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'project1/target/generated-test-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project1/messages/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project1.messages');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage1');
outputDirectory = new File(basedir, 'project2/target/generated-test-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project2/messages/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project2.messages');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage2');
return true;
================================================
FILE: src/it/TEST-9/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that protobuf definitions can be imported from other modules in the reactor. \
The dependency has the default type of 'jar' (main protobuf files import \
main protobuf files from another module). \
In this test, imports are scoped to packages. \
We need to make sure that package structure for protobuf definitions \
is preserved in packaged jars, and correctly restored for importing.
invoker.goals = clean compile
================================================
FILE: src/it/TEST-9/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0test-9-parent1.0.0pomIntegration Test 9 (Parent)project1project2org.xolstice.maven.pluginsprotobuf-maven-plugin@project.version@
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
================================================
FILE: src/it/TEST-9/project1/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-9-parent1.0.0test-9-project1Integration Test 9 (1)org.xolstice.maven.pluginsprotobuf-maven-plugincompile
================================================
FILE: src/it/TEST-9/project1/src/main/proto/it/project1/test1.proto3
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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 it.project1;
option java_package = "it.project1.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage1 {
}
================================================
FILE: src/it/TEST-9/project2/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-9-parent1.0.0test-9-project2Integration Test 9 (2)org.xolstice.maven.pluginsprotobuf-maven-plugincompile${project.groupId}test-9-project11.0.0
================================================
FILE: src/it/TEST-9/project2/src/main/proto/it/project2/test2.proto3
================================================
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// 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 it.project2;
import "it/project1/test1.proto3";
option java_package = "it.project2.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
message TestMessage2 {
it.project1.TestMessage1 included = 1;
}
================================================
FILE: src/it/TEST-9/verify.groovy
================================================
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
outputDirectory = new File(basedir, 'project1/target/generated-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project1/messages/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project1.messages');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage1');
outputDirectory = new File(basedir, 'project2/target/generated-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();
generatedJavaFile = new File(outputDirectory, 'it/project2/messages/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();
content = generatedJavaFile.text;
assert content.contains('package it.project2.messages');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage2');
return true;
================================================
FILE: src/it/dependencies/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-dependencies1.0.0pomIntegration Test Dependencies
This POM file declares all plugins and dependencies that are used in integration tests.
CI tools can use this POM file to prefetch the dependencies into the local repository
ahead of running the tests, so that dependency caching can be implemented efficiently.
UTF-81.7.0kr.motd.mavenos-maven-plugin1.6.1org.apache.maven.pluginsmaven-enforcer-plugin3.0.0-M3org.apache.maven.pluginsmaven-toolchains-plugin3.0.0org.apache.maven.pluginsmaven-compiler-plugin3.8.1org.apache.maven.pluginsmaven-surefire-plugin3.0.0-M4org.apache.maven.pluginsmaven-jar-plugin3.2.0org.apache.maven.pluginsmaven-dependency-plugin3.1.1io.grpcgrpc-core${grpcVersion}runtimeio.grpcgrpc-netty${grpcVersion}runtimeio.grpcgrpc-protobuf${grpcVersion}runtimeio.grpcgrpc-stub${grpcVersion}runtimeio.grpcprotoc-gen-grpc-java${grpcVersion}exe${os.detected.classifier}providedcommons-clicommons-cli1.2runtimecommons-langcommons-lang2.6runtimejunitjunit4.12testprotoc-3.4.03.4.0com.google.protobufprotobuf-java${protobufVersion}runtimecom.google.protobufprotoc${protobufVersion}exe${os.detected.classifier}providedprotoc-3.11.13.11.1com.google.protobufprotobuf-java${protobufVersion}runtimecom.google.protobufprotoc${protobufVersion}exe${os.detected.classifier}provided
================================================
FILE: src/it/settings.xml
================================================
it-repotruelocal.central@localRepositoryUrl@truetruelocal.central@localRepositoryUrl@truetrue
================================================
FILE: src/it/setup-it-parent/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = \
Installs a common parent POM for all integration tests.
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean install
================================================
FILE: src/it/setup-it-parent/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itsit-parent1.0.0pomIntegration Test ParentUTF-81.8${java.sdk.version}${java.sdk.version}${java.sdk.version}3.3.93.11.1protobuf-javakr.motd.mavenos-maven-plugin1.6.1org.apache.maven.pluginsmaven-enforcer-plugin3.0.0-M3trueorg.apache.maven.pluginsmaven-toolchains-plugin3.0.0trueorg.apache.maven.pluginsmaven-resources-plugin3.1.0trueorg.apache.maven.pluginsmaven-compiler-plugin3.8.1trueorg.apache.maven.pluginsmaven-surefire-plugin3.0.0-M4trueorg.apache.maven.pluginsmaven-jar-plugin3.2.0trueorg.apache.maven.pluginsmaven-dependency-plugin3.1.1trueorg.apache.maven.pluginsmaven-enforcer-pluginenforce-build-environmentenforce[${mavenVersion},)[${java.sdk.version},)trueorg.apache.maven.pluginsmaven-toolchains-plugintruedefault-toolchainvalidatetoolchain[${java.sdk.version},)org.apache.maven.pluginsmaven-compiler-plugintrue${java.compiler.compilerVersion}${java.compiler.source}${java.compiler.target}falsefalsecom.google.protobuf${protobufJavaArtifact}${protobufVersion}junitjunit4.12test
================================================
FILE: src/it/setup-protoc-plugin/invoker.properties
================================================
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# 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.
#
# An optional description for this build job to be included in the build reports.
invoker.description = install minimal protoc plugin
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean install
================================================
FILE: src/it/setup-protoc-plugin/pom.xml
================================================
4.0.0org.xolstice.maven.plugins.protobuf.itstest-protoc-plugin1.0.5jarMinimal protoc pluginUTF-81.8${java.sdk.version}${java.sdk.version}${java.sdk.version}3.4.0org.apache.maven.pluginsmaven-enforcer-plugin3.0.0-M3trueorg.apache.maven.pluginsmaven-toolchains-plugin3.0.0trueorg.apache.maven.pluginsmaven-resources-plugin3.1.0org.apache.maven.pluginsmaven-compiler-plugin3.8.1trueorg.apache.maven.pluginsmaven-jar-plugin3.2.0org.apache.maven.pluginsmaven-toolchains-plugintruedefault-toolchainvalidatetoolchain[${java.sdk.version},)org.apache.maven.pluginsmaven-compiler-plugintrue${java.compiler.compilerVersion}${java.compiler.source}${java.compiler.target}truetrue-Xlint:all-Xlint:allcom.google.protobufprotobuf-java${protobufVersion}compilecommons-clicommons-cli1.2runtimecommons-langcommons-lang2.6providedjunitjunit4.12test
================================================
FILE: src/it/setup-protoc-plugin/src/main/java/org/xolstice/protobuf/plugin/minimal/MinimalPlugin.java
================================================
package org.xolstice.protobuf.plugin.minimal;
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import com.google.protobuf.CodedInputStream;
import com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest;
import com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse;
import com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.File;
import java.io.IOException;
/**
* A minimal protoc plugin that generates a file {@code foo.txt} for each protobuf file {@code foo.proto}.
* The content of the generated file is the name of the source file. Optionally, a file name prefix can be
* passed as an argument.
*/
public class MinimalPlugin {
public static void main(String... args) {
String prefix = (args.length > 0) ? args[0] : "";
try {
CodedInputStream in = CodedInputStream.newInstance(System.in);
CodeGeneratorRequest pluginRequest = CodeGeneratorRequest.newBuilder().mergeFrom(in).build();
CodeGeneratorResponse pluginResponse = generateCode(pluginRequest, prefix);
pluginResponse.writeTo(System.out);
} catch (Exception e) {
CodeGeneratorResponse errorResponse = CodeGeneratorResponse.newBuilder().setError(e.getMessage()).build();
try {
errorResponse.writeTo(System.out);
} catch (IOException ioe) {
// nothing we can do here
}
}
}
private static CodeGeneratorResponse generateCode(CodeGeneratorRequest request, String prefix) {
CodeGeneratorResponse.Builder responseBuilder = CodeGeneratorResponse.newBuilder();
for (String sourceFileName : request.getFileToGenerateList()) {
File.Builder fileBuilder = File.newBuilder();
fileBuilder.setName(prefix + sourceFileName.replace(".proto", ".txt"));
fileBuilder.setContent(sourceFileName);
responseBuilder.addFile(fileBuilder);
}
return responseBuilder.build();
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/AbstractProtocCompileMojo.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugins.annotations.Parameter;
import java.io.File;
import java.util.List;
import static java.util.Arrays.asList;
/**
* An abstract base mojo configuration for using {@code protoc} compiler with the main sources.
*
* @since 0.3.3
*/
public abstract class AbstractProtocCompileMojo extends AbstractProtocMojo {
/**
* The source directories containing the {@code .proto} definitions to be compiled.
*/
@Parameter(
required = true,
defaultValue = "${basedir}/src/main/proto"
)
private File protoSourceRoot;
@Override
protected void doAttachProtoSources() {
projectHelper.addResource(project, getProtoSourceRoot().getAbsolutePath(),
asList(getIncludes()), asList(getExcludes()));
}
@Override
protected void doAttachGeneratedFiles() {
final File outputDirectory = getOutputDirectory();
project.addCompileSourceRoot(outputDirectory.getAbsolutePath());
buildContext.refresh(outputDirectory);
}
@Override
protected List getDependencyArtifacts() {
return project.getCompileArtifacts();
}
@Override
protected File getProtoSourceRoot() {
return protoSourceRoot;
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/AbstractProtocMojo.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.artifact.resolver.ResolutionErrorHandler;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.toolchain.Toolchain;
import org.apache.maven.toolchain.ToolchainManager;
import org.apache.maven.toolchain.java.DefaultJavaToolChain;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.Os;
import org.codehaus.plexus.util.SelectorUtils;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.io.RawInputStreamFacade;
import org.sonatype.plexus.build.incremental.BuildContext;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import static java.lang.Math.max;
import static java.lang.String.format;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static java.util.Collections.singleton;
import static org.codehaus.plexus.util.FileUtils.cleanDirectory;
import static org.codehaus.plexus.util.FileUtils.copyStreamToFile;
import static org.codehaus.plexus.util.FileUtils.getDefaultExcludesAsString;
import static org.codehaus.plexus.util.FileUtils.getFileNames;
import static org.codehaus.plexus.util.FileUtils.getFiles;
import static org.codehaus.plexus.util.StringUtils.join;
/**
* Abstract Mojo implementation.
*
*
This class is extended by {@link ProtocCompileMojo} and
* {@link ProtocTestCompileMojo} in order to override the specific configuration for
* compiling the main or test classes respectively.
*/
abstract class AbstractProtocMojo extends AbstractMojo {
private static final String DEFAULT_INCLUDES = "**/*.proto*";
/**
* The current Maven project.
*/
@Parameter(defaultValue = "${project}", readonly = true)
protected MavenProject project;
/**
* The current Maven Session Object.
*
* @since 0.2.0
*/
@Parameter(defaultValue = "${session}", readonly = true)
protected MavenSession session;
/**
* Build context that tracks changes to the source and target files.
*
* @since 0.3.0
*/
@Component
protected BuildContext buildContext;
/**
* An optional tool chain manager.
*
* @since 0.2.0
*/
@Component
protected ToolchainManager toolchainManager;
/**
* A helper used to add resources to the project.
*/
@Component
protected MavenProjectHelper projectHelper;
/**
* A factory for Maven artifact definitions.
*
* @since 0.3.1
*/
@Component
private ArtifactFactory artifactFactory;
/**
* A component that implements resolution of Maven artifacts from repositories.
*
* @since 0.3.1
*/
@Component
private ArtifactResolver artifactResolver;
/**
* A component that handles resolution of Maven artifacts.
*
* @since 0.4.0
*/
@Component
private RepositorySystem repositorySystem;
/**
* A component that handles resolution errors.
*
* @since 0.4.0
*/
@Component
private ResolutionErrorHandler resolutionErrorHandler;
/**
* This is the path to the local maven {@code repository}.
*/
@Parameter(
required = true,
readonly = true,
property = "localRepository"
)
private ArtifactRepository localRepository;
/**
* Remote repositories for artifact resolution.
*
* @since 0.3.0
*/
@Parameter(
required = true,
readonly = true,
defaultValue = "${project.remoteArtifactRepositories}"
)
private List remoteRepositories;
/**
* A directory where temporary files will be generated.
*
* @since 0.6.0
*/
@Parameter(
required = true,
readonly = true,
defaultValue = "${project.build.directory}"
)
private File tempDirectory;
/**
* A directory where native launchers for java protoc plugins will be generated.
*
* @since 0.3.0
*/
@Parameter(
required = false,
defaultValue = "${project.build.directory}/protoc-plugins"
)
private File protocPluginDirectory;
/**
* This is the path to the {@code protoc} executable.
* When this parameter is not set, the plugin attempts to load
* a {@code protobuf} toolchain and use it locate {@code protoc} executable.
* If no {@code protobuf} toolchain is defined in the project,
* the {@code protoc} executable in the {@code PATH} is used.
*/
@Parameter(
required = false,
property = "protocExecutable"
)
private String protocExecutable;
/**
* Protobuf compiler artifact specification, in {@code groupId:artifactId:version[:type[:classifier]]} format.
* When this parameter is set, the plugin attempts to resolve the specified artifact as {@code protoc} executable.
*
* @since 0.4.1
*/
@Parameter(
required = false,
property = "protocArtifact"
)
private String protocArtifact;
/**
* Additional source paths for {@code .proto} definitions.
*/
@Parameter(
required = false
)
private File[] additionalProtoPathElements = {};
/**
* Since {@code protoc} cannot access jars, proto files in dependencies are extracted to this location
* and deleted on exit. This directory is always cleaned during execution.
*/
@Parameter(
required = true,
defaultValue = "${project.build.directory}/protoc-dependencies"
)
private File temporaryProtoFileDirectory;
/**
* Set this to {@code false} to disable hashing of dependent jar paths.
*
* This plugin expands jars on the classpath looking for embedded {@code .proto} files.
* Normally these paths are hashed (MD5) to avoid issues with long file names on windows.
* However if this property is set to {@code false} longer paths will be used.
*/
@Parameter(
required = true,
defaultValue = "true"
)
private boolean hashDependentPaths;
/**
* A list of <include> elements specifying the protobuf definition files (by pattern)
* that should be included in compilation.
* When not specified, the default includes will be:
*
* <includes>
* <include>**/*.proto</include>
* </includes>
*
*/
@Parameter(
required = false
)
private String[] includes = {DEFAULT_INCLUDES};
/**
* A list of <exclude> elements specifying the protobuf definition files (by pattern)
* that should be excluded from compilation.
* When not specified, the default excludes will be empty:
*
* <excludes>
* </excludes>
*
*/
@Parameter(
required = false
)
private String[] excludes = {};
/**
* If set to {@code true}, then the specified protobuf source files from this project will be attached
* as resources to the build, for subsequent inclusion into the final artifact.
* This is the default behaviour, as it allows downstream projects to import protobuf definitions
* from the upstream projects, and those imports are automatically resolved at build time.
*
*
If distribution of {@code .proto} source files is undesirable for security reasons
* or because of other considerations, then this parameter should be set to {@code false}.
*
* @since 0.4.1
*/
@Parameter(
required = true,
defaultValue = "true"
)
protected boolean attachProtoSources;
/**
* If set to {@code true}, all command line arguments to protoc will be written to a file,
* and only a path to that file will be passed to protoc on the command line.
* This helps prevent Command line is too long errors when the number of {@code .proto} files is large.
*
*
NOTE: This is only supported for protoc 3.5.0 and higher.
*
* @since 0.6.0
*/
@Parameter(
required = false,
defaultValue = "false"
)
protected boolean useArgumentFile;
/**
* Specifies one of more custom protoc plugins, written in Java
* and available as Maven artifacts. An executable plugin will be created
* at execution time. On UNIX the executable is a shell script and on
* Windows it is a WinRun4J .exe and .ini.
*/
@Parameter(
required = false
)
private List protocPlugins;
/**
* Sets the granularity in milliseconds of the last modification date
* for testing whether source protobuf definitions need recompilation.
*
*
This parameter is only used when {@link #checkStaleness} parameter is set to {@code true}.
*
*
If the project is built on NFS it's recommended to set this parameter to {@code 10000}.
*/
@Parameter(
required = false,
defaultValue = "0"
)
private long staleMillis;
/**
* Normally {@code protoc} is invoked on every execution of the plugin.
* Setting this parameter to {@code true} will enable checking
* timestamps of source protobuf definitions vs. generated sources.
*
* @see #staleMillis
*/
@Parameter(
required = false,
defaultValue = "false"
)
private boolean checkStaleness;
/**
* When {@code true}, skip the execution.
*
* @since 0.2.0
*/
@Parameter(
required = false,
property = "protoc.skip",
defaultValue = "false"
)
private boolean skip;
/**
* Usually most of protobuf mojos will not get executed on parent poms
* (i.e. projects with packaging type 'pom').
* Setting this parameter to {@code true} will force
* the execution of this mojo, even if it would usually get skipped in this case.
*
* @since 0.2.0
*/
@Parameter(
required = false,
property = "protoc.force",
defaultValue = "false"
)
private boolean forceMojoExecution;
/**
* When {@code true}, the output directory will be cleared out prior to code generation.
* With the latest versions of protoc (2.5.0 or later) this is generally not required,
* although some earlier versions reportedly had issues with running
* two code generations in a row without clearing out the output directory in between.
*
* @since 0.4.0
*/
@Parameter(
required = false,
property = "protoc.clearOutputDirectory",
defaultValue = "false"
)
private boolean clearOutputDirectory;
/**
* Executes the mojo.
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skipMojo()) {
return;
}
try {
checkParameters();
} catch (final MojoConfigurationException e) {
throw new MojoExecutionException("Configuration error: " + e.getMessage(), e);
} catch (final MojoInitializationException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
final File protoSourceRoot = getProtoSourceRoot();
if (protoSourceRoot.exists()) {
try {
final List protoFiles = findProtoFilesInDirectory(protoSourceRoot);
final File outputDirectory = getOutputDirectory();
final List outputFiles = findGeneratedFilesInDirectory(getOutputDirectory());
if (protoFiles.isEmpty()) {
getLog().info("No proto files to compile.");
} else if (!hasDelta(protoFiles)) {
getLog().info("Skipping compilation because build context has no changes.");
doAttachFiles();
} else if (checkStaleness && checkFilesUpToDate(protoFiles, outputFiles)) {
getLog().info("Skipping compilation because target directory newer than sources.");
doAttachFiles();
} else {
final List derivedProtoPathElements =
makeProtoPathFromJars(temporaryProtoFileDirectory, getDependencyArtifactFiles());
FileUtils.mkdir(outputDirectory.getAbsolutePath());
if (clearOutputDirectory) {
try {
cleanDirectory(outputDirectory);
} catch (final IOException e) {
throw new MojoInitializationException("Unable to clean output directory", e);
}
}
createProtocPlugins();
//get toolchain from context
final Toolchain tc = toolchainManager.getToolchainFromBuildContext("protobuf", session); //NOI18N
if (tc != null) {
getLog().info("Toolchain in protobuf-maven-plugin: " + tc);
//when the executable to use is explicitly set by user in mojo's parameter, ignore toolchains.
if (protocExecutable != null) {
getLog().warn(
"Toolchains are ignored, 'protocExecutable' parameter is set to " + protocExecutable);
} else {
//assign the path to executable from toolchains
protocExecutable = tc.findTool("protoc"); //NOI18N
}
}
if (protocExecutable == null && protocArtifact != null) {
final Artifact artifact = createDependencyArtifact(protocArtifact);
final File file = resolveBinaryArtifact(artifact);
protocExecutable = file.getAbsolutePath();
}
if (protocExecutable == null) {
// Try to fall back to 'protoc' in $PATH
getLog().warn("No 'protocExecutable' parameter is configured, using the default: 'protoc'");
protocExecutable = "protoc";
}
final Protoc.Builder protocBuilder =
new Protoc.Builder(protocExecutable)
.addProtoPathElement(protoSourceRoot)
.addProtoPathElements(derivedProtoPathElements)
.addProtoPathElements(asList(additionalProtoPathElements))
.addProtoFiles(protoFiles);
addProtocBuilderParameters(protocBuilder);
final Protoc protoc = protocBuilder.build();
if (getLog().isDebugEnabled()) {
getLog().debug("Proto source root:");
getLog().debug(" " + protoSourceRoot);
if (derivedProtoPathElements != null && !derivedProtoPathElements.isEmpty()) {
getLog().debug("Derived proto paths:");
for (final File path : derivedProtoPathElements) {
getLog().debug(" " + path);
}
}
if (additionalProtoPathElements != null && additionalProtoPathElements.length > 0) {
getLog().debug("Additional proto paths:");
for (final File path : additionalProtoPathElements) {
getLog().debug(" " + path);
}
}
}
protoc.logExecutionParameters(getLog());
getLog().info(format("Compiling %d proto file(s) to %s", protoFiles.size(), outputDirectory));
final int exitStatus = protoc.execute(getLog());
if (StringUtils.isNotBlank(protoc.getOutput())) {
getLog().info("PROTOC: " + protoc.getOutput());
}
if (exitStatus != 0) {
getLog().error("PROTOC FAILED: " + protoc.getError());
for (File pf : protoFiles) {
buildContext.removeMessages(pf);
buildContext.addMessage(pf, 0, 0, protoc.getError(), BuildContext.SEVERITY_ERROR, null);
}
throw new MojoFailureException(
"protoc did not exit cleanly. Review output for more information.");
} else if (StringUtils.isNotBlank(protoc.getError())) {
getLog().warn("PROTOC: " + protoc.getError());
}
doAttachFiles();
}
} catch (final MojoConfigurationException e) {
throw new MojoExecutionException("Configuration error: " + e.getMessage(), e);
} catch (final MojoInitializationException e) {
throw new MojoExecutionException(e.getMessage(), e);
} catch (final CommandLineException e) {
throw new MojoExecutionException("An error occurred while invoking protoc: " + e.getMessage(), e);
} catch (final InterruptedException e) {
getLog().info("Process interrupted");
}
} else {
getLog().info(format("%s does not exist. Review the configuration or consider disabling the plugin.",
protoSourceRoot));
}
}
/**
* Generates native launchers for java protoc plugins.
* These launchers will later be added as parameters for protoc compiler.
*
* @since 0.3.0
*/
protected void createProtocPlugins() {
if (protocPlugins == null) {
return;
}
final String javaHome = detectJavaHome();
for (final ProtocPlugin plugin : protocPlugins) {
if (plugin.getJavaHome() != null) {
getLog().debug("Using javaHome defined in plugin definition: " + plugin.getJavaHome());
} else {
getLog().debug("Setting javaHome for plugin: " + javaHome);
plugin.setJavaHome(javaHome);
}
getLog().info("Building protoc plugin: " + plugin.getId());
final ProtocPluginAssembler assembler = new ProtocPluginAssembler(
plugin,
session,
project.getArtifact(),
artifactFactory,
repositorySystem,
resolutionErrorHandler,
localRepository,
remoteRepositories,
protocPluginDirectory,
getLog());
assembler.execute();
}
}
/**
* Attempts to detect java home directory, using {@code jdk} toolchain if available,
* with a fallback to {@code java.home} system property.
*
* @return path to java home directory.
*
* @since 0.3.0
*/
protected String detectJavaHome() {
String javaHome = null;
final Toolchain tc = toolchainManager.getToolchainFromBuildContext("jdk", session);
if (tc != null) {
if (tc instanceof DefaultJavaToolChain) {
javaHome = ((DefaultJavaToolChain) tc).getJavaHome();
if (javaHome != null) {
getLog().debug("Using javaHome from toolchain: " + javaHome);
}
} else {
// Try to infer JAVA_HOME from location of 'java' tool in toolchain, if available.
// We don't use 'java' directly because for Windows we need to find the path to
// jvm.dll instead, which the assembler tries to figure out relative to JAVA_HOME.
final String javaExecutable = tc.findTool("java");
if (javaExecutable != null) {
File parent = new File(javaExecutable).getParentFile();
if (parent != null) {
parent = parent.getParentFile();
if (parent != null && parent.isDirectory()) {
javaHome = parent.getAbsolutePath();
getLog().debug(
"Using javaHome based on 'java' location returned by toolchain: " + javaHome);
}
}
}
}
}
if (javaHome == null) {
// Default location is the current JVM's JAVA_HOME.
javaHome = System.getProperty("java.home");
getLog().debug("Using javaHome from java.home system property: " + javaHome);
}
return javaHome;
}
/**
* Adds mojo-specific parameters to the protoc builder.
*
* @param protocBuilder the builder to be modified.
*/
protected void addProtocBuilderParameters(final Protoc.Builder protocBuilder) {
if (protocPlugins != null) {
for (final ProtocPlugin plugin : protocPlugins) {
protocBuilder.addPlugin(plugin);
}
protocPluginDirectory.mkdirs();
protocBuilder.setPluginDirectory(protocPluginDirectory);
}
protocBuilder.setTempDirectory(tempDirectory);
protocBuilder.useArgumentFile(useArgumentFile);
}
/**
*
Determine if the mojo execution should get skipped.
* This is the case if:
*
*
{@link #skip} is true
*
if the mojo gets executed on a project with packaging type 'pom' and
* {@link #forceMojoExecution} is false
*
*
* @return true if the mojo execution should be skipped.
*
* @since 0.2.0
*/
protected boolean skipMojo() {
if (skip) {
getLog().info("Skipping mojo execution");
return true;
}
if (!forceMojoExecution && "pom".equals(this.project.getPackaging())) {
getLog().info("Skipping mojo execution for project with packaging type 'pom'");
return true;
}
return false;
}
protected static List findGeneratedFilesInDirectory(final File directory) {
if (directory == null || !directory.isDirectory()) {
return emptyList();
}
final List generatedFilesInDirectory;
try {
generatedFilesInDirectory = getFiles(directory, "**/*", getDefaultExcludesAsString());
} catch (final IOException e) {
throw new MojoInitializationException("Unable to scan output directory", e);
}
return generatedFilesInDirectory;
}
/**
* Returns timestamp for the most recently modified file in the given set.
*
* @param files a collection of file descriptors.
* @return timestamp of the most recently modified file.
*/
protected static long lastModified(final Iterable files) {
long result = 0L;
for (final File file : files) {
result = max(result, file.lastModified());
}
return result;
}
/**
* Checks that the source files don't have modification time that is later than the target files.
*
* @param sourceFiles a collection of source files.
* @param targetFiles a collection of target files.
* @return {@code true}, if source files are not later than the target files; {@code false}, otherwise.
*/
protected boolean checkFilesUpToDate(final Iterable sourceFiles, final Iterable targetFiles) {
return lastModified(sourceFiles) + staleMillis < lastModified(targetFiles);
}
/**
* Checks if the injected build context has changes in any of the specified files.
*
* @param files files to be checked for changes.
* @return {@code true}, if at least one file has changes; {@code false}, if no files have changes.
*
* @since 0.3.0
*/
protected boolean hasDelta(final Iterable files) {
for (final File file : files) {
if (buildContext.hasDelta(file)) {
return true;
}
}
return false;
}
protected void checkParameters() {
if (project == null) {
throw new MojoConfigurationException("'project' is null");
}
if (projectHelper == null) {
throw new MojoConfigurationException("'projectHelper' is null");
}
final File protoSourceRoot = getProtoSourceRoot();
if (protoSourceRoot == null) {
throw new MojoConfigurationException("'protoSourceRoot' is null");
}
if (protoSourceRoot.isFile()) {
throw new MojoConfigurationException("'protoSourceRoot' is a file, not a directory");
}
if (temporaryProtoFileDirectory == null) {
throw new MojoConfigurationException("'temporaryProtoFileDirectory' is null");
}
if (temporaryProtoFileDirectory.isFile()) {
throw new MojoConfigurationException("'temporaryProtoFileDirectory' is a file, not a directory");
}
final File outputDirectory = getOutputDirectory();
if (outputDirectory == null) {
throw new MojoConfigurationException("'outputDirectory' is null");
}
if (outputDirectory.isFile()) {
throw new MojoConfigurationException("'outputDirectory' is a file, not a directory");
}
}
protected abstract File getProtoSourceRoot();
protected String[] getIncludes() {
return includes;
}
protected String[] getExcludes() {
return excludes;
}
// TODO add artifact filtering (inclusions and exclusions)
// TODO add filtering for proto definitions in included artifacts
protected abstract List getDependencyArtifacts();
/**
* Returns the output directory for generated sources. Depends on build phase so must
* be defined in concrete implementation.
*
* @return output directory for generated sources.
*/
protected abstract File getOutputDirectory();
protected void doAttachFiles() {
if (attachProtoSources) {
doAttachProtoSources();
}
doAttachGeneratedFiles();
}
protected abstract void doAttachProtoSources();
protected abstract void doAttachGeneratedFiles();
/**
* Gets the {@link File} for each dependency artifact.
*
* @return A list of all dependency artifacts.
*/
protected List getDependencyArtifactFiles() {
final List dependencyArtifacts = getDependencyArtifacts();
if (dependencyArtifacts.isEmpty()) {
return emptyList();
}
final List dependencyArtifactFiles = new ArrayList<>(dependencyArtifacts.size());
for (final Artifact artifact : dependencyArtifacts) {
dependencyArtifactFiles.add(artifact.getFile());
}
return dependencyArtifactFiles;
}
/**
* Unpacks proto descriptors that are bundled inside dependent artifacts into a temporary directory.
* This is needed because protobuf compiler cannot handle imported descriptors that are packed inside jar files.
*
* @param temporaryProtoFileDirectory temporary directory to serve as root for unpacked structure.
* @param classpathElementFiles classpath elements, can be either jar files or directories.
* @return a list of import roots for protobuf compiler
* (these will all be subdirectories of the temporary directory).
*/
protected List makeProtoPathFromJars(
final File temporaryProtoFileDirectory,
final Iterable classpathElementFiles
) {
if (classpathElementFiles == null) {
throw new MojoConfigurationException("'classpathElementFiles' is null");
}
if (!classpathElementFiles.iterator().hasNext()) {
return emptyList();
}
// clean the temporary directory to ensure that stale files aren't used
if (temporaryProtoFileDirectory.exists()) {
try {
cleanDirectory(temporaryProtoFileDirectory);
} catch (IOException e) {
throw new MojoInitializationException("Unable to clean up temporary proto file directory", e);
}
}
final List protoDirectories = new ArrayList<>();
for (final File classpathElementFile : classpathElementFiles) {
// for some reason under IAM, we receive poms as dependent files
// I am excluding .xml rather than including .jar as there may be other extensions in use (sar, har, zip)
if (classpathElementFile.isFile() && classpathElementFile.canRead() &&
!classpathElementFile.getName().endsWith(".xml")) {
// create the jar file. the constructor validates.
try (final JarFile classpathJar = new JarFile(classpathElementFile)) {
final Enumeration jarEntries = classpathJar.entries();
while (jarEntries.hasMoreElements()) {
final JarEntry jarEntry = jarEntries.nextElement();
final String jarEntryName = jarEntry.getName();
if (!jarEntry.isDirectory() && SelectorUtils.matchPath(DEFAULT_INCLUDES, jarEntryName, "/", true)) {
final File jarDirectory;
try {
jarDirectory = new File(temporaryProtoFileDirectory, truncatePath(classpathJar.getName()));
// Check for Zip Slip vulnerability
// https://snyk.io/research/zip-slip-vulnerability
final String canonicalJarDirectoryPath = jarDirectory.getCanonicalPath();
final File uncompressedCopy = new File(jarDirectory, jarEntryName);
final String canonicalUncompressedCopyPath = uncompressedCopy.getCanonicalPath();
if (!canonicalUncompressedCopyPath.startsWith(canonicalJarDirectoryPath + File.separator)) {
throw new MojoInitializationException(
"ZIP SLIP: Entry " + jarEntry.getName() +
" in " + classpathJar.getName() + " is outside of the target dir");
}
FileUtils.mkdir(uncompressedCopy.getParentFile().getAbsolutePath());
copyStreamToFile(
new RawInputStreamFacade(classpathJar.getInputStream(jarEntry)),
uncompressedCopy);
} catch (final IOException e) {
throw new MojoInitializationException("Unable to unpack proto files", e);
}
protoDirectories.add(jarDirectory);
}
}
} catch (final IOException e) {
throw new MojoInitializationException(
"Not a readable JAR artifact: " + classpathElementFile.getAbsolutePath(), e);
}
} else if (classpathElementFile.isDirectory()) {
final List protoFiles;
try {
protoFiles = getFileNames(classpathElementFile, DEFAULT_INCLUDES, null, true);
} catch (final IOException e) {
throw new MojoInitializationException(
"Unable to scan for proto files in: " + classpathElementFile.getAbsolutePath(), e);
}
if (!protoFiles.isEmpty()) {
protoDirectories.add(classpathElementFile);
}
}
}
return protoDirectories;
}
protected List findProtoFilesInDirectory(final File directory) {
if (directory == null) {
throw new MojoConfigurationException("'directory' is null");
}
if (!directory.isDirectory()) {
throw new MojoConfigurationException(format("%s is not a directory", directory));
}
final List protoFilesInDirectory;
try {
final String includes = join(getIncludes(), ",");
final String excludes = join(getExcludes(), ",");
protoFilesInDirectory = getFiles(directory, includes, excludes);
} catch (IOException e) {
throw new MojoInitializationException("Unable to retrieve the list of files: " + e.getMessage(), e);
}
return protoFilesInDirectory;
}
protected List findProtoFilesInDirectories(final Iterable directories) {
if (directories == null) {
throw new MojoConfigurationException("'directories' is null");
}
final List protoFiles = new ArrayList<>();
for (final File directory : directories) {
protoFiles.addAll(findProtoFilesInDirectory(directory));
}
return protoFiles;
}
/**
* Truncates the path of jar files so that they are relative to the local repository.
*
* @param jarPath the full path of a jar file.
* @return the truncated path relative to the local repository or root of the drive.
*/
protected String truncatePath(final String jarPath) {
if (hashDependentPaths) {
return md5Hash(jarPath);
}
String repository = localRepository.getBasedir().replace('\\', '/');
if (!repository.endsWith("/")) {
repository += "/";
}
String path = jarPath.replace('\\', '/');
final int repositoryIndex = path.indexOf(repository);
if (repositoryIndex != -1) {
path = path.substring(repositoryIndex + repository.length());
}
// By now the path should be good, but do a final check to fix windows machines.
final int colonIndex = path.indexOf(':');
if (colonIndex != -1) {
// 2 = :\ in C:\
path = path.substring(colonIndex + 2);
}
return path;
}
private static String md5Hash(final String string) {
final MessageDigest digest;
try {
digest = MessageDigest.getInstance("MD5");
} catch (final NoSuchAlgorithmException e) {
throw new MojoInitializationException("Unable to create MD5 digest", e);
}
final byte[] input = string.getBytes(Charset.forName("UTF-8"));
return toHexString(digest.digest(input));
}
private static final char[] HEX_CHARS = "0123456789abcdef".toCharArray();
protected static String toHexString(final byte[] byteArray) {
final StringBuilder hexString = new StringBuilder(2 * byteArray.length);
for (final byte b : byteArray) {
hexString.append(HEX_CHARS[(b & 0xF0) >> 4]).append(HEX_CHARS[b & 0x0F]);
}
return hexString.toString();
}
protected File resolveBinaryArtifact(final Artifact artifact) {
final ArtifactResolutionResult result;
final ArtifactResolutionRequest request = new ArtifactResolutionRequest()
.setArtifact(project.getArtifact())
.setResolveRoot(false)
.setResolveTransitively(false)
.setArtifactDependencies(singleton(artifact))
.setManagedVersionMap(emptyMap())
.setLocalRepository(localRepository)
.setRemoteRepositories(remoteRepositories)
.setOffline(session.isOffline())
.setForceUpdate(session.getRequest().isUpdateSnapshots())
.setServers(session.getRequest().getServers())
.setMirrors(session.getRequest().getMirrors())
.setProxies(session.getRequest().getProxies());
result = repositorySystem.resolve(request);
try {
resolutionErrorHandler.throwErrors(request, result);
} catch (final ArtifactResolutionException e) {
throw new MojoInitializationException("Unable to resolve artifact: " + e.getMessage(), e);
}
final Set artifacts = result.getArtifacts();
if (artifacts == null || artifacts.isEmpty()) {
throw new MojoInitializationException("Unable to resolve artifact");
}
final Artifact resolvedBinaryArtifact = artifacts.iterator().next();
if (getLog().isDebugEnabled()) {
getLog().debug("Resolved artifact: " + resolvedBinaryArtifact);
}
// Copy the file to the project build directory and make it executable
final File sourceFile = resolvedBinaryArtifact.getFile();
final String sourceFileName = sourceFile.getName();
final String targetFileName;
if (Os.isFamily(Os.FAMILY_WINDOWS) && !sourceFileName.endsWith(".exe")) {
targetFileName = sourceFileName + ".exe";
} else {
targetFileName = sourceFileName;
}
final File targetFile = new File(protocPluginDirectory, targetFileName);
if (targetFile.exists()) {
// The file must have already been copied in a prior plugin execution/invocation
getLog().debug("Executable file already exists: " + targetFile.getAbsolutePath());
return targetFile;
}
try {
FileUtils.forceMkdir(protocPluginDirectory);
} catch (final IOException e) {
throw new MojoInitializationException("Unable to create directory " + protocPluginDirectory, e);
}
try {
FileUtils.copyFile(sourceFile, targetFile);
} catch (final IOException e) {
throw new MojoInitializationException("Unable to copy the file to " + protocPluginDirectory, e);
}
if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
targetFile.setExecutable(true);
}
if (getLog().isDebugEnabled()) {
getLog().debug("Executable file: " + targetFile.getAbsolutePath());
}
return targetFile;
}
/**
* Creates a dependency artifact from a specification in
* {@code groupId:artifactId:version[:type[:classifier]]} format.
*
* @param artifactSpec artifact specification.
* @return artifact object instance.
*/
protected Artifact createDependencyArtifact(final String artifactSpec) {
final String[] parts = artifactSpec.split(":");
if (parts.length < 3 || parts.length > 5) {
throw new MojoConfigurationException(
"Invalid artifact specification format"
+ ", expected: groupId:artifactId:version[:type[:classifier]]"
+ ", actual: " + artifactSpec);
}
final String type = parts.length >= 4 ? parts[3] : "exe";
final String classifier = parts.length == 5 ? parts[4] : null;
return createDependencyArtifact(parts[0], parts[1], parts[2], type, classifier);
}
protected Artifact createDependencyArtifact(
final String groupId,
final String artifactId,
final String version,
final String type,
final String classifier
) {
final VersionRange versionSpec;
try {
versionSpec = VersionRange.createFromVersionSpec(version);
} catch (final InvalidVersionSpecificationException e) {
throw new MojoConfigurationException("Invalid version specification", e);
}
return artifactFactory.createDependencyArtifact(
groupId,
artifactId,
versionSpec,
type,
classifier,
Artifact.SCOPE_RUNTIME);
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/AbstractProtocTestCompileMojo.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugins.annotations.Parameter;
import java.io.File;
import java.util.List;
import static java.util.Arrays.asList;
/**
* An abstract base mojo configuration for using {@code protoc} compiler with the test sources.
*
* @since 0.3.3
*/
public abstract class AbstractProtocTestCompileMojo extends AbstractProtocMojo {
/**
* The source directories containing the test {@code .proto} definitions to be compiled.
*/
@Parameter(
required = true,
defaultValue = "${basedir}/src/test/proto"
)
private File protoTestSourceRoot;
@Override
protected void doAttachProtoSources() {
projectHelper.addTestResource(project, getProtoSourceRoot().getAbsolutePath(),
asList(getIncludes()), asList(getExcludes()));
}
@Override
protected void doAttachGeneratedFiles() {
final File outputDirectory = getOutputDirectory();
project.addTestCompileSourceRoot(outputDirectory.getAbsolutePath());
buildContext.refresh(outputDirectory);
}
@Override
protected List getDependencyArtifacts() {
return project.getTestArtifacts();
}
@Override
protected File getProtoSourceRoot() {
return protoTestSourceRoot;
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/MojoConfigurationException.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
/**
* An exception to indicate that plugin configuration was incorrect.
*
* @since 0.6.0
*/
public final class MojoConfigurationException extends RuntimeException {
private static final long serialVersionUID = 6662087467815362518L;
public MojoConfigurationException(final String message) {
super(message);
}
public MojoConfigurationException(final String message, final Throwable cause) {
super(message, cause);
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/MojoInitializationException.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
/**
* An exception to indicate that plugin initialization has failed.
*
* @since 0.6.0
*/
public final class MojoInitializationException extends RuntimeException {
private static final long serialVersionUID = 821723854984670341L;
public MojoInitializationException(final String message) {
super(message);
}
public MojoInitializationException(final String message, final Throwable cause) {
super(message, cause);
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/Protoc.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.plugin.logging.Log;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer;
import org.codehaus.plexus.util.cli.Commandline;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import static org.codehaus.plexus.util.StringUtils.join;
/**
* This class represents an invokable configuration of the {@code protoc} compiler.
* The actual executable is invoked using the plexus {@link Commandline}.
*/
final class Protoc {
/**
* Prefix for logging the debug messages.
*/
public static final String LOG_PREFIX = "[PROTOC] ";
/**
* Path to the {@code protoc} executable.
*/
private final String executable;
/**
* A set of directories in which to search for definition imports.
*/
private final List protoPathElements;
/**
* A set of protobuf definitions to process.
*/
private final List protoFiles;
/**
* A directory into which Java source files will be generated.
*/
private final File javaOutputDirectory;
private final List plugins;
private final File pluginDirectory;
private final String nativePluginId;
private final String nativePluginExecutable;
private final String nativePluginParameter;
/**
* A directory into which C++ source files will be generated.
*/
private final File cppOutputDirectory;
/**
* A directory into which Python source files will be generated.
*/
private final File pythonOutputDirectory;
/**
* A directory into which C# source files will be generated.
*/
private final File csharpOutputDirectory;
/**
* A directory into which JavaScript source files will be generated.
*/
private final File javaScriptOutputDirectory;
/**
* A directory into which a custom protoc plugin will generate files.
*/
private final File customOutputDirectory;
private final File descriptorSetFile;
private final boolean includeImportsInDescriptorSet;
private final boolean includeSourceInfoInDescriptorSet;
/**
* A buffer to consume standard output from the {@code protoc} executable.
*/
private final StringStreamConsumer output;
/**
* A buffer to consume error output from the {@code protoc} executable.
*/
private final StringStreamConsumer error;
/**
* A directory where temporary files will be generated.
*/
private final File tempDirectory;
/**
* A boolean indicating if the parameters to protoc should be passed in an argument file.
*/
private final boolean useArgumentFile;
/**
* Constructs a new instance. This should only be used by the {@link Builder}.
*
* @param executable path to the {@code protoc} executable.
* @param protoPath a set of directories in which to search for definition imports.
* @param protoFiles a set of protobuf definitions to process.
* @param javaOutputDirectory a directory into which Java source files will be generated.
* @param cppOutputDirectory a directory into which C++ source files will be generated.
* @param pythonOutputDirectory a directory into which Python source files will be generated.
* @param csharpOutputDirectory a directory into which C# source files will be generated.
* @param javaScriptOutputDirectory a directory into which JavaScript source files will be generated.
* @param customOutputDirectory a directory into which a custom protoc plugin will generate files.
* @param descriptorSetFile The directory into which a descriptor set will be generated;
* if {@code null}, no descriptor set will be written
* @param includeImportsInDescriptorSet If {@code true}, dependencies will be included in the descriptor set.
* @param includeSourceInfoInDescriptorSet If {@code true}, source code information will be included
* in the descriptor set.
* @param plugins a set of java protoc plugins.
* @param pluginDirectory location of protoc plugins to be added to system path.
* @param nativePluginId a unique id of a native plugin.
* @param nativePluginExecutable path to the native plugin executable.
* @param nativePluginParameter an optional parameter for a native plugin.
* @param tempDirectory a directory where temporary files will be generated.
* @param useArgumentFile If {@code true}, parameters to protoc will be put in an argument file
*/
private Protoc(
final String executable,
final List protoPath,
final List protoFiles,
final File javaOutputDirectory,
final File cppOutputDirectory,
final File pythonOutputDirectory,
final File csharpOutputDirectory,
final File javaScriptOutputDirectory,
final File customOutputDirectory,
final File descriptorSetFile,
final boolean includeImportsInDescriptorSet,
final boolean includeSourceInfoInDescriptorSet,
final List plugins,
final File pluginDirectory,
final String nativePluginId,
final String nativePluginExecutable,
final String nativePluginParameter,
final File tempDirectory,
final boolean useArgumentFile
) {
if (executable == null) {
throw new MojoConfigurationException("'executable' is null");
}
if (protoPath == null) {
throw new MojoConfigurationException("'protoPath' is null");
}
if (protoFiles == null) {
throw new MojoConfigurationException("'protoFiles' is null");
}
this.executable = executable;
this.protoPathElements = protoPath;
this.protoFiles = protoFiles;
this.javaOutputDirectory = javaOutputDirectory;
this.cppOutputDirectory = cppOutputDirectory;
this.pythonOutputDirectory = pythonOutputDirectory;
this.csharpOutputDirectory = csharpOutputDirectory;
this.javaScriptOutputDirectory = javaScriptOutputDirectory;
this.customOutputDirectory = customOutputDirectory;
this.descriptorSetFile = descriptorSetFile;
this.includeImportsInDescriptorSet = includeImportsInDescriptorSet;
this.includeSourceInfoInDescriptorSet = includeSourceInfoInDescriptorSet;
this.plugins = plugins;
this.pluginDirectory = pluginDirectory;
this.nativePluginId = nativePluginId;
this.nativePluginExecutable = nativePluginExecutable;
this.nativePluginParameter = nativePluginParameter;
this.tempDirectory = tempDirectory;
this.useArgumentFile = useArgumentFile;
this.error = new StringStreamConsumer();
this.output = new StringStreamConsumer();
}
/**
* Invokes the {@code protoc} compiler using the configuration specified at construction.
*
* @param log logger instance.
* @return The exit status of {@code protoc}.
* @throws CommandLineException if command line environment cannot be set up.
* @throws InterruptedException if the execution was interrupted by the user.
*/
public int execute(final Log log) throws CommandLineException, InterruptedException {
final Commandline cl = new Commandline();
cl.setExecutable(executable);
String[] args = buildProtocCommand().toArray(new String[] {});
if (useArgumentFile) {
try {
File argumentsFile = createFileWithArguments(args);
log.debug(LOG_PREFIX + "Using arguments file " + argumentsFile.getPath());
cl.addArguments(new String[] {"@" + argumentsFile.getAbsolutePath()});
} catch (final IOException e) {
throw new CommandLineException("Error creating file with protoc arguments", e);
}
} else {
cl.addArguments(args);
}
// There is a race condition in JDK that may sporadically prevent process creation on Linux
// https://bugs.openjdk.java.net/browse/JDK-8068370
// In order to mitigate that, retry up to 2 more times before giving up
int attemptsLeft = 3;
while (true) {
try {
return CommandLineUtils.executeCommandLine(cl, null, output, error);
} catch (CommandLineException e) {
if (--attemptsLeft == 0 || e.getCause() == null) {
throw e;
}
log.warn(LOG_PREFIX + "Unable to invoke protoc, will retry " + attemptsLeft + " time(s)", e);
Thread.sleep(1000L);
}
}
}
/**
* Creates the command line arguments.
*
*
This method has been made visible for testing only.
*
* @return A list consisting of the executable followed by any arguments.
*/
public List buildProtocCommand() {
final List command = new ArrayList<>();
// add the executable
for (final File protoPathElement : protoPathElements) {
command.add("--proto_path=" + protoPathElement);
}
if (javaOutputDirectory != null) {
String outputOption = "--java_out=";
if (nativePluginParameter != null) {
outputOption += nativePluginParameter + ':';
}
outputOption += javaOutputDirectory;
command.add(outputOption);
// For now we assume all custom plugins produce Java output
for (final ProtocPlugin plugin : plugins) {
final File pluginExecutable = plugin.getPluginExecutableFile(pluginDirectory);
command.add("--plugin=protoc-gen-" + plugin.getId() + '=' + pluginExecutable);
command.add("--" + plugin.getId() + "_out=" + javaOutputDirectory);
}
}
if (cppOutputDirectory != null) {
command.add("--cpp_out=" + cppOutputDirectory);
}
if (pythonOutputDirectory != null) {
command.add("--python_out=" + pythonOutputDirectory);
}
if (csharpOutputDirectory != null) {
command.add("--csharp_out=" + csharpOutputDirectory);
}
if (javaScriptOutputDirectory != null) {
String outputOption = "--js_out=";
if (nativePluginParameter != null) {
outputOption += nativePluginParameter + ':';
}
outputOption += javaScriptOutputDirectory;
command.add(outputOption);
}
if (customOutputDirectory != null) {
if (nativePluginExecutable != null) {
command.add("--plugin=protoc-gen-" + nativePluginId + '=' + nativePluginExecutable);
}
String outputOption = "--" + nativePluginId + "_out=";
if (nativePluginParameter != null) {
outputOption += nativePluginParameter + ':';
}
outputOption += customOutputDirectory;
command.add(outputOption);
}
for (final File protoFile : protoFiles) {
command.add(protoFile.toString());
}
if (descriptorSetFile != null) {
command.add("--descriptor_set_out=" + descriptorSetFile);
if (includeImportsInDescriptorSet) {
command.add("--include_imports");
}
if (includeSourceInfoInDescriptorSet) {
command.add("--include_source_info");
}
}
return command;
}
/**
* Logs execution parameters on debug level to the specified logger.
* All log messages will be prefixed with {@value #LOG_PREFIX}.
*
* @param log a logger.
*/
public void logExecutionParameters(final Log log) {
if (log.isDebugEnabled()) {
log.debug(LOG_PREFIX + "Executable: ");
log.debug(LOG_PREFIX + ' ' + executable);
if (protoPathElements != null && !protoPathElements.isEmpty()) {
log.debug(LOG_PREFIX + "Protobuf import paths:");
for (final File protoPathElement : protoPathElements) {
log.debug(LOG_PREFIX + ' ' + protoPathElement);
}
}
if (javaOutputDirectory != null) {
log.debug(LOG_PREFIX + "Java output directory:");
log.debug(LOG_PREFIX + ' ' + javaOutputDirectory);
if (plugins.size() > 0) {
log.debug(LOG_PREFIX + "Plugins for Java output:");
for (final ProtocPlugin plugin : plugins) {
log.debug(LOG_PREFIX + ' ' + plugin.getId());
}
}
}
if (pluginDirectory != null) {
log.debug(LOG_PREFIX + "Plugin directory:");
log.debug(LOG_PREFIX + ' ' + pluginDirectory);
}
if (cppOutputDirectory != null) {
log.debug(LOG_PREFIX + "C++ output directory:");
log.debug(LOG_PREFIX + ' ' + cppOutputDirectory);
}
if (pythonOutputDirectory != null) {
log.debug(LOG_PREFIX + "Python output directory:");
log.debug(LOG_PREFIX + ' ' + pythonOutputDirectory);
}
if (csharpOutputDirectory != null) {
log.debug(LOG_PREFIX + "C# output directory:");
log.debug(LOG_PREFIX + ' ' + csharpOutputDirectory);
}
if (javaScriptOutputDirectory != null) {
log.debug(LOG_PREFIX + "JavaScript output directory:");
log.debug(LOG_PREFIX + ' ' + javaScriptOutputDirectory);
}
if (descriptorSetFile != null) {
log.debug(LOG_PREFIX + "Descriptor set output file:");
log.debug(LOG_PREFIX + ' ' + descriptorSetFile);
log.debug(LOG_PREFIX + "Include imports:");
log.debug(LOG_PREFIX + ' ' + includeImportsInDescriptorSet);
}
log.debug(LOG_PREFIX + "Protobuf descriptors:");
for (final File protoFile : protoFiles) {
log.debug(LOG_PREFIX + ' ' + protoFile);
}
final List cl = buildProtocCommand();
if (cl != null && !cl.isEmpty()) {
log.debug(LOG_PREFIX + "Command line options:");
log.debug(LOG_PREFIX + join(cl.iterator(), " "));
}
}
}
/**
* @return the output
*/
public String getOutput() {
return fixUnicodeOutput(output.getOutput());
}
/**
* @return the error
*/
public String getError() {
return fixUnicodeOutput(error.getOutput());
}
/**
* Transcodes the output from system default charset to UTF-8.
* Protoc emits messages in UTF-8, but they are captured into a stream that has a system-default encoding.
*
* @param message a UTF-8 message in system-default encoding.
* @return the same message converted into a unicode string.
*/
private static String fixUnicodeOutput(final String message) {
return new String(message.getBytes(), Charset.forName("UTF-8"));
}
/**
* Put args into a temp file to be referenced using the @ option in protoc command line.
*
* @param args
* @return the temporary file wth the arguments
* @throws IOException
*/
private File createFileWithArguments(String... args) throws IOException {
PrintWriter writer = null;
try {
final File tempFile = File.createTempFile("protoc", null, tempDirectory);
tempFile.deleteOnExit();
writer = new PrintWriter(tempFile, "UTF-8");
for (final String arg : args) {
writer.println(arg);
}
writer.flush();
return tempFile;
} finally {
if (writer != null) {
writer.close();
}
}
}
/**
* This class builds {@link Protoc} instances.
*/
static final class Builder {
/**
* Path to the {@code protoc} executable.
*/
private final String executable;
private final LinkedHashSet protopathElements;
private final List protoFiles;
private final List plugins;
private File tempDirectory;
private File pluginDirectory;
// TODO reorganise support for custom plugins
// This place is currently a mess because of the two different type of custom plugins supported:
// pure java (wrapped in a native launcher) and binary native.
private String nativePluginId;
private String nativePluginExecutable;
private String nativePluginParameter;
/**
* A directory into which Java source files will be generated.
*/
private File javaOutputDirectory;
/**
* A directory into which C++ source files will be generated.
*/
private File cppOutputDirectory;
/**
* A directory into which Python source files will be generated.
*/
private File pythonOutputDirectory;
/**
* A directory into which C# source files will be generated.
*/
private File csharpOutputDirectory;
/**
* A directory into which JavaScript source files will be generated.
*/
private File javaScriptOutputDirectory;
/**
* A directory into which a custom protoc plugin will generate files.
*/
private File customOutputDirectory;
private File descriptorSetFile;
private boolean includeImportsInDescriptorSet;
private boolean includeSourceInfoInDescriptorSet;
private boolean useArgumentFile;
/**
* Constructs a new builder.
*
* @param executable The path to the {@code protoc} executable.
*/
Builder(final String executable) {
if (executable == null) {
throw new MojoConfigurationException("'executable' is null");
}
this.executable = executable;
protoFiles = new ArrayList<>();
protopathElements = new LinkedHashSet<>();
plugins = new ArrayList<>();
}
public Builder setTempDirectory(final File tempDirectory) {
if (tempDirectory == null) {
throw new MojoConfigurationException("'tempDirectory' is null");
}
if (!tempDirectory.isDirectory()) {
throw new MojoConfigurationException(
"'tempDirectory' is not a directory: " + tempDirectory.getAbsolutePath());
}
this.tempDirectory = tempDirectory;
return this;
}
/**
* Sets the directory into which Java source files will be generated.
*
* @param javaOutputDirectory a directory into which Java source files will be generated.
* @return this builder instance.
*/
public Builder setJavaOutputDirectory(final File javaOutputDirectory) {
if (javaOutputDirectory == null) {
throw new MojoConfigurationException("'javaOutputDirectory' is null");
}
if (!javaOutputDirectory.isDirectory()) {
throw new MojoConfigurationException(
"'javaOutputDirectory' is not a directory: " + javaOutputDirectory.getAbsolutePath());
}
this.javaOutputDirectory = javaOutputDirectory;
return this;
}
/**
* Sets the directory into which C++ source files will be generated.
*
* @param cppOutputDirectory a directory into which C++ source files will be generated.
* @return this builder instance.
*/
public Builder setCppOutputDirectory(final File cppOutputDirectory) {
if (cppOutputDirectory == null) {
throw new MojoConfigurationException("'cppOutputDirectory' is null");
}
if (!cppOutputDirectory.isDirectory()) {
throw new MojoConfigurationException(
"'cppOutputDirectory' is not a directory: " + cppOutputDirectory.getAbsolutePath());
}
this.cppOutputDirectory = cppOutputDirectory;
return this;
}
/**
* Sets the directory into which Python source files will be generated.
*
* @param pythonOutputDirectory a directory into which Python source files will be generated.
* @return this builder instance.
*/
public Builder setPythonOutputDirectory(final File pythonOutputDirectory) {
if (pythonOutputDirectory == null) {
throw new MojoConfigurationException("'pythonOutputDirectory' is null");
}
if (!pythonOutputDirectory.isDirectory()) {
throw new MojoConfigurationException(
"'pythonOutputDirectory' is not a directory: " + pythonOutputDirectory.getAbsolutePath());
}
this.pythonOutputDirectory = pythonOutputDirectory;
return this;
}
/**
* Sets the directory into which C# source files will be generated.
*
* @param csharpOutputDirectory a directory into which C# source files will be generated.
* @return this builder instance.
*/
public Builder setCsharpOutputDirectory(final File csharpOutputDirectory) {
if (csharpOutputDirectory == null) {
throw new MojoConfigurationException("'csharpOutputDirectory' is null");
}
if (!csharpOutputDirectory.isDirectory()) {
throw new MojoConfigurationException(
"'csharpOutputDirectory' is not a directory: " + csharpOutputDirectory.getAbsolutePath());
}
this.csharpOutputDirectory = csharpOutputDirectory;
return this;
}
/**
* Sets the directory into which JavaScript source files will be generated.
*
* @param javaScriptOutputDirectory a directory into which JavaScript source files will be generated.
* @return this builder instance.
*/
public Builder setJavaScriptOutputDirectory(final File javaScriptOutputDirectory) {
if (javaScriptOutputDirectory == null) {
throw new MojoConfigurationException("'javaScriptOutputDirectory' is null");
}
if (!javaScriptOutputDirectory.isDirectory()) {
throw new MojoConfigurationException(
"'javaScriptOutputDirectory' is not a directory: "
+ javaScriptOutputDirectory.getAbsolutePath());
}
this.javaScriptOutputDirectory = javaScriptOutputDirectory;
return this;
}
/**
* Sets the directory into which a custom protoc plugin will generate files.
*
* @param customOutputDirectory a directory into which a custom protoc plugin will generate files.
* @return this builder instance.
*/
public Builder setCustomOutputDirectory(final File customOutputDirectory) {
if (customOutputDirectory == null) {
throw new MojoConfigurationException("'customOutputDirectory' is null");
}
if (!customOutputDirectory.isDirectory()) {
throw new MojoConfigurationException(
"'customOutputDirectory' is not a directory: " + customOutputDirectory.getAbsolutePath());
}
this.customOutputDirectory = customOutputDirectory;
return this;
}
/**
* Adds a proto file to be compiled. Proto files must be on the protopath
* and this method will fail if a proto file is added without first adding a
* parent directory to the protopath.
*
* @param protoFile source protobuf definitions file.
* @return The builder.
*/
public Builder addProtoFile(final File protoFile) {
if (protoFile == null) {
throw new MojoConfigurationException("'protoFile' is null");
}
if (!protoFile.isFile()) {
throw new MojoConfigurationException("Proto file is not a file: " + protoFile.getAbsolutePath());
}
checkProtoFileIsInProtopath(protoFile);
protoFiles.add(protoFile);
return this;
}
/**
* Adds a protoc plugin definition for custom code generation.
* @param plugin plugin definition
* @return this builder instance.
*/
public Builder addPlugin(final ProtocPlugin plugin) {
if (plugin == null) {
throw new MojoConfigurationException("'plugin' is null");
}
plugins.add(plugin);
return this;
}
public Builder setPluginDirectory(final File pluginDirectory) {
if (pluginDirectory == null) {
throw new MojoConfigurationException("'pluginDirectory' is null");
}
if (!pluginDirectory.isDirectory()) {
throw new MojoConfigurationException(
"'pluginDirectory' is not a directory: " + pluginDirectory.getAbsolutePath());
}
this.pluginDirectory = pluginDirectory;
return this;
}
public Builder setNativePluginId(final String nativePluginId) {
if (nativePluginId == null || nativePluginId.isEmpty()) {
throw new MojoConfigurationException("'nativePluginId' is null or empty");
}
if (nativePluginId.equals("java")
|| nativePluginId.equals("js")
|| nativePluginId.equals("python")
|| nativePluginId.equals("csharp")
|| nativePluginId.equals("cpp")
|| nativePluginId.equals("descriptor_set")) {
throw new MojoConfigurationException("'nativePluginId' matches one of the built-in "
+ "protoc plugins: " + nativePluginId);
}
this.nativePluginId = nativePluginId;
return this;
}
public Builder setNativePluginExecutable(final String nativePluginExecutable) {
if (nativePluginExecutable == null || nativePluginExecutable.isEmpty()) {
throw new MojoConfigurationException("'nativePluginExecutable' is null or empty");
}
this.nativePluginExecutable = nativePluginExecutable;
return this;
}
public Builder setNativePluginParameter(final String nativePluginParameter) {
if (nativePluginParameter == null) {
throw new MojoConfigurationException("'nativePluginParameter' is null");
}
if (nativePluginParameter.contains(":")) {
throw new MojoConfigurationException("'nativePluginParameter' contains illegal characters");
}
this.nativePluginParameter = nativePluginParameter;
return this;
}
public Builder withDescriptorSetFile(
final File descriptorSetFile,
final boolean includeImports,
final boolean includeSourceInfoInDescriptorSet
) {
if (descriptorSetFile == null) {
throw new MojoConfigurationException("'descriptorSetFile' is null");
}
final File descriptorSetFileParent = descriptorSetFile.getParentFile();
if (!descriptorSetFileParent.exists()) {
throw new MojoConfigurationException("Parent directory for 'descriptorSetFile' does not exist");
}
if (!descriptorSetFileParent.isDirectory()) {
throw new MojoConfigurationException("Parent for 'descriptorSetFile' is not a directory");
}
this.descriptorSetFile = descriptorSetFile;
this.includeImportsInDescriptorSet = includeImports;
this.includeSourceInfoInDescriptorSet = includeSourceInfoInDescriptorSet;
return this;
}
public Builder useArgumentFile(final boolean useArgumentFile) {
this.useArgumentFile = useArgumentFile;
return this;
}
private void checkProtoFileIsInProtopath(final File protoFile) {
if (!protoFile.isFile()) {
throw new MojoConfigurationException("Not a regular file: " + protoFile.getAbsolutePath());
}
if (!checkProtoFileIsInProtopathHelper(protoFile.getParentFile())) {
throw new MojoConfigurationException("File is not in proto path: " + protoFile.getAbsolutePath());
}
}
private boolean checkProtoFileIsInProtopathHelper(final File directory) {
if (!directory.isDirectory()) {
throw new MojoConfigurationException("Not a directory: " + directory.getAbsolutePath());
}
if (protopathElements.contains(directory)) {
return true;
}
final File parentDirectory = directory.getParentFile();
return parentDirectory != null && checkProtoFileIsInProtopathHelper(parentDirectory);
}
/**
* Adds a collection of proto files to be compiled.
*
* @param protoFiles a collection of source protobuf definition files.
* @return this builder instance.
* @see #addProtoFile(File)
*/
public Builder addProtoFiles(final Iterable protoFiles) {
for (final File protoFile : protoFiles) {
addProtoFile(protoFile);
}
return this;
}
/**
* Adds the {@code protopathElement} to the protopath.
*
* @param protopathElement A directory to be searched for imported protocol buffer definitions.
* @return The builder.
*/
public Builder addProtoPathElement(final File protopathElement) {
if (protopathElement == null) {
throw new MojoConfigurationException("'protopathElement' is null");
}
if (!protopathElement.isDirectory()) {
throw new MojoConfigurationException(
"Proto path element is not a directory: " + protopathElement.getAbsolutePath());
}
protopathElements.add(protopathElement);
return this;
}
/**
* Adds a number of elements to the protopath.
*
* @param protopathElements directories to be searched for imported protocol buffer definitions.
* @return this builder instance.
* @see #addProtoPathElement(File)
*/
public Builder addProtoPathElements(final Iterable protopathElements) {
for (final File protopathElement : protopathElements) {
addProtoPathElement(protopathElement);
}
return this;
}
/**
* Validates the internal state for consistency and completeness.
*/
private void validateState() {
if (protoFiles.isEmpty()) {
throw new MojoConfigurationException("No proto files specified");
}
if (javaOutputDirectory == null
&& cppOutputDirectory == null
&& pythonOutputDirectory == null
&& csharpOutputDirectory == null
&& javaScriptOutputDirectory == null
&& customOutputDirectory == null
&& descriptorSetFile == null) {
throw new MojoConfigurationException("At least one of these properties must be set:" +
" 'javaOutputDirectory', 'cppOutputDirectory'," +
" 'pythonOutputDirectory', 'csharpOutputDirectory', 'javaScriptOutputDirectory'," +
" 'customOutputDirectory', or 'descriptorSetFile'");
}
}
/**
* Builds and returns a fully configured instance of {@link Protoc} wrapper.
*
* @return a configured {@link Protoc} instance.
*/
public Protoc build() {
validateState();
return new Protoc(
executable,
new ArrayList<>(protopathElements),
protoFiles,
javaOutputDirectory,
cppOutputDirectory,
pythonOutputDirectory,
csharpOutputDirectory,
javaScriptOutputDirectory,
customOutputDirectory,
descriptorSetFile,
includeImportsInDescriptorSet,
includeSourceInfoInDescriptorSet,
plugins,
pluginDirectory,
nativePluginId,
nativePluginExecutable,
nativePluginParameter,
tempDirectory,
useArgumentFile);
}
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/ProtocCompileCppMojo.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import java.io.File;
/**
* This mojo executes the {@code protoc} compiler for generating main C++ sources
* from protocol buffer definitions. It also searches dependency artifacts for
* {@code .proto} files and includes them in the {@code proto_path} so that they can be
* referenced. Finally, it adds the {@code .proto} files to the project as resources so
* that they are included in the final artifact.
*
* @since 0.3.3
*/
@Mojo(
name = "compile-cpp",
defaultPhase = LifecyclePhase.GENERATE_SOURCES,
requiresDependencyResolution = ResolutionScope.COMPILE,
threadSafe = true
)
public final class ProtocCompileCppMojo extends AbstractProtocCompileMojo {
/**
* This is the directory into which the {@code .cpp} will be created.
*/
@Parameter(
required = true,
property = "cppOutputDirectory",
defaultValue = "${project.build.directory}/generated-sources/protobuf/cpp"
)
private File outputDirectory;
@Override
protected void addProtocBuilderParameters(final Protoc.Builder protocBuilder) {
super.addProtocBuilderParameters(protocBuilder);
protocBuilder.setCppOutputDirectory(getOutputDirectory());
}
@Override
protected File getOutputDirectory() {
return outputDirectory;
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/ProtocCompileCsharpMojo.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import java.io.File;
/**
* This mojo executes the {@code protoc} compiler for generating main C# sources
* from protocol buffer definitions. It also searches dependency artifacts for
* {@code .proto} files and includes them in the {@code proto_path} so that they can be
* referenced. Finally, it adds the {@code .proto} files to the project as resources so
* that they are included in the final artifact.
*
* @since 0.6.0
*/
@Mojo(
name = "compile-csharp",
defaultPhase = LifecyclePhase.GENERATE_SOURCES,
requiresDependencyResolution = ResolutionScope.COMPILE,
threadSafe = true
)
public final class ProtocCompileCsharpMojo extends AbstractProtocCompileMojo {
/**
* This is the directory into which the {@code .cs} will be created.
*/
@Parameter(
required = true,
property = "csharpOutputDirectory",
defaultValue = "${project.build.directory}/generated-sources/protobuf/csharp"
)
private File outputDirectory;
@Override
protected void addProtocBuilderParameters(final Protoc.Builder protocBuilder) {
super.addProtocBuilderParameters(protocBuilder);
protocBuilder.setCsharpOutputDirectory(getOutputDirectory());
}
@Override
protected File getOutputDirectory() {
return outputDirectory;
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/ProtocCompileCustomMojo.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.toolchain.Toolchain;
import java.io.File;
/**
* This mojo executes the {@code protoc} compiler with the specified plugin
* executable to generate main sources from protocol buffer definitions.
* It also searches dependency artifacts for {@code .proto} files and
* includes them in the {@code proto_path} so that they can be referenced.
* Finally, it adds the {@code .proto} files to the project as resources so
* that they are included in the final artifact.
*
* @since 0.4.1
*/
@Mojo(
name = "compile-custom",
defaultPhase = LifecyclePhase.GENERATE_SOURCES,
requiresDependencyResolution = ResolutionScope.COMPILE,
threadSafe = true
)
public final class ProtocCompileCustomMojo extends AbstractProtocCompileMojo {
/**
* A unique id that identifies the plugin to protoc.
* Cannot be one of the built-in protoc plugins:
*
*
java
*
js
*
csharp
*
cpp
*
python
*
descriptor-set
*
*/
@Parameter(
required = true,
property = "protocPluginId"
)
private String pluginId;
/**
* This is the base directory for the generated code.
* If an explicit {@link #outputDirectory} parameter is not specified,
* an output directory named after {@link #pluginId} will be created
* inside this base directory.
*/
@Parameter(
required = true,
readonly = true,
defaultValue = "${project.build.directory}/generated-sources/protobuf"
)
private File outputBaseDirectory;
/**
* This is the directory where the generated code will be placed.
* If this parameter is unspecified, then the default location is constructed as follows:
* ${project.build.directory}/generated-sources/protobuf/<pluginId>
*/
@Parameter(
required = false,
property = "protocPluginOutputDirectory"
)
private File outputDirectory;
/**
* An optional path to plugin executable.
* If unspecified, alternative options must be used (e.g. toolchains).
*/
@Parameter(
required = false,
property = "protocPluginExecutable"
)
private String pluginExecutable;
/**
* An optional parameter to be passed to the plugin.
* Cannot contain colon (:) symbols.
*/
@Parameter(
required = false,
property = "protocPluginParameter"
)
private String pluginParameter;
/**
* A name of an optional custom toolchain that can be used to locate the plugin executable.
* The toolchain must be registered as a build extension and initialised properly.
*/
@Parameter(
required = false,
property = "protocPluginToolchain"
)
private String pluginToolchain;
/**
* If {@link #pluginToolchain} is specified, this parameter specifies the tool in the toolchain,
* which is to be resolved as plugin executable.
*/
@Parameter(
required = false,
property = "protocPluginTool"
)
private String pluginTool;
/**
* Plugin artifact specification, in {@code groupId:artifactId:version[:type[:classifier]]} format.
* When this parameter is set, the specified artifact will be resolved as a plugin executable.
*
* @since 0.4.1
*/
@Parameter(
required = false,
property = "protocPluginArtifact"
)
private String pluginArtifact;
@Override
protected void addProtocBuilderParameters(final Protoc.Builder protocBuilder) {
super.addProtocBuilderParameters(protocBuilder);
protocBuilder.setNativePluginId(pluginId);
if (pluginToolchain != null && pluginTool != null) {
//get toolchain from context
final Toolchain tc = toolchainManager.getToolchainFromBuildContext(pluginToolchain, session);
if (tc != null) {
getLog().info("Toolchain in protobuf-maven-plugin: " + tc);
//when the executable to use is explicitly set by user in mojo's parameter, ignore toolchains.
if (pluginExecutable != null) {
getLog().warn("Toolchains are ignored, 'pluginExecutable' parameter is set to " + pluginExecutable);
} else {
//assign the path to executable from toolchains
pluginExecutable = tc.findTool(pluginTool);
}
}
}
if (pluginExecutable == null && pluginArtifact != null) {
final Artifact artifact = createDependencyArtifact(pluginArtifact);
final File file = resolveBinaryArtifact(artifact);
pluginExecutable = file.getAbsolutePath();
}
if (pluginExecutable != null) {
protocBuilder.setNativePluginExecutable(pluginExecutable);
}
if (pluginParameter != null) {
protocBuilder.setNativePluginParameter(pluginParameter);
}
protocBuilder.setCustomOutputDirectory(getOutputDirectory());
}
@Override
protected File getOutputDirectory() {
File outputDirectory = this.outputDirectory;
if (outputDirectory == null) {
outputDirectory = new File(outputBaseDirectory, pluginId);
}
return outputDirectory;
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/ProtocCompileDescriptorSetMojo.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import java.io.File;
/**
* This mojo executes {@code protoc} compiler for generating descriptor sets
* from protocol buffer definitions. It also searches dependency artifacts for
* {@code .proto} files and includes them in the {@code proto_path} so that they can be
* referenced. Finally, it adds the {@code .proto} files to the project as resources so
* that they are included in the final artifact. The generated descriptor set can be
* optionally also attached to the project.
*
* @since 0.7.0
*/
@Mojo(
name = "compile-descriptor-set",
defaultPhase = LifecyclePhase.GENERATE_RESOURCES,
requiresDependencyResolution = ResolutionScope.COMPILE,
threadSafe = true
)
public final class ProtocCompileDescriptorSetMojo extends AbstractProtocCompileMojo {
/**
* This is the directory into which the descriptor set file will be created.
*/
@Parameter(
required = true,
property = "descriptorSetOutputDirectory",
defaultValue = "${project.build.directory}/generated-resources/protobuf/descriptor-sets"
)
private File outputDirectory;
/**
* The descriptor set file name.
*/
@Parameter(
required = true,
defaultValue = "${project.build.finalName}.pb"
)
protected String descriptorSetFileName;
/**
* If set to {@code true}, the generated descriptor set will be attached to the build.
*/
@Parameter(
required = true,
defaultValue = "false"
)
protected boolean attach;
/**
* If generated descriptor set is to be attached to the build, specifies an optional classifier.
*/
@Parameter(
required = false
)
protected String classifier;
/**
* If {@code true}, the compiler will include all dependencies in the descriptor set, making it self-contained.
*/
@Parameter(
required = false,
defaultValue = "false"
)
protected boolean includeImports;
/**
* If {@code true}, do not strip {@code SourceCodeInfo} from the {@code FileDescriptorProto}.
* This results in significantly larger descriptors that include information about the original location
* of each declaration in the source file, as well as surrounding comments.
*/
@Parameter(
required = false,
defaultValue = "false"
)
protected boolean includeSourceInfo;
@Override
protected void addProtocBuilderParameters(final Protoc.Builder protocBuilder) {
super.addProtocBuilderParameters(protocBuilder);
final File descriptorSetFile = new File(getOutputDirectory(), descriptorSetFileName);
getLog().info("Will generate descriptor set:");
getLog().info(" " + descriptorSetFile.getAbsolutePath());
protocBuilder.withDescriptorSetFile(descriptorSetFile, includeImports, includeSourceInfo);
}
@Override
protected File getOutputDirectory() {
return outputDirectory;
}
@SuppressWarnings("MethodDoesntCallSuperMethod")
@Override
protected void doAttachGeneratedFiles() {
final File outputDirectory = getOutputDirectory();
if (attach) {
final File descriptorSetFile = new File(getOutputDirectory(), descriptorSetFileName);
projectHelper.attachArtifact(project, "pb", classifier, descriptorSetFile);
}
buildContext.refresh(outputDirectory);
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/ProtocCompileJavaScriptMojo.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import java.io.File;
/**
* This mojo executes the {@code protoc} compiler for generating main JavaScript sources
* from protocol buffer definitions. It also searches dependency artifacts for
* {@code .proto} files and includes them in the {@code proto_path} so that they can be
* referenced. Finally, it adds the {@code .proto} files to the project as resources so
* that they are included in the final artifact.
*
* @since 0.6.0
*/
@Mojo(
name = "compile-js",
defaultPhase = LifecyclePhase.GENERATE_SOURCES,
requiresDependencyResolution = ResolutionScope.COMPILE,
threadSafe = true
)
public final class ProtocCompileJavaScriptMojo extends AbstractProtocCompileMojo {
/**
* This is the directory into which the {@code .js} will be created.
*/
@Parameter(
required = true,
property = "javaScriptOutputDirectory",
defaultValue = "${project.build.directory}/generated-sources/protobuf/js"
)
private File outputDirectory;
/**
* Additional comma-separated options to be passed to the JavaScript generator.
* Cannot contain colon (:) symbols.
*/
@Parameter(
required = false,
property = "javaScriptOptions"
)
private String javaScriptOptions;
@Override
protected void addProtocBuilderParameters(final Protoc.Builder protocBuilder) {
super.addProtocBuilderParameters(protocBuilder);
if (javaScriptOptions != null) {
protocBuilder.setNativePluginParameter(javaScriptOptions);
}
protocBuilder.setJavaScriptOutputDirectory(getOutputDirectory());
}
@Override
protected File getOutputDirectory() {
return outputDirectory;
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/ProtocCompileMojo.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import java.io.File;
/**
* This mojo executes the {@code protoc} compiler for generating main Java sources
* from protocol buffer definitions. It also searches dependency artifacts for
* {@code .proto} files and includes them in the {@code proto_path} so that they can be
* referenced. Finally, it adds the {@code .proto} files to the project as resources so
* that they are included in the final artifact.
*/
@Mojo(
name = "compile",
defaultPhase = LifecyclePhase.GENERATE_SOURCES,
requiresDependencyResolution = ResolutionScope.COMPILE,
threadSafe = true
)
public final class ProtocCompileMojo extends AbstractProtocCompileMojo {
/**
* This is the directory into which the {@code .java} will be created.
*/
@Parameter(
required = true,
property = "javaOutputDirectory",
defaultValue = "${project.build.directory}/generated-sources/protobuf/java"
)
private File outputDirectory;
/**
* Additional comma-separated options to be passed to the Java generator.
* Cannot contain colon (:) symbols.
*
* @since 0.7.0
*/
@Parameter(
required = false,
property = "javaOptions"
)
private String javaOptions;
@Override
protected void addProtocBuilderParameters(final Protoc.Builder protocBuilder) {
super.addProtocBuilderParameters(protocBuilder);
if (javaOptions != null) {
protocBuilder.setNativePluginParameter(javaOptions);
}
protocBuilder.setJavaOutputDirectory(getOutputDirectory());
}
@Override
protected File getOutputDirectory() {
return outputDirectory;
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/ProtocCompilePythonMojo.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import java.io.File;
/**
* This mojo executes the {@code protoc} compiler for generating main python sources
* from protocol buffer definitions. It also searches dependency artifacts for
* {@code .proto} files and includes them in the {@code proto_path} so that they can be
* referenced. Finally, it adds the {@code .proto} files to the project as resources so
* that they are included in the final artifact.
*
* @since 0.3.3
*/
@Mojo(
name = "compile-python",
defaultPhase = LifecyclePhase.GENERATE_SOURCES,
requiresDependencyResolution = ResolutionScope.COMPILE,
threadSafe = true
)
public final class ProtocCompilePythonMojo extends AbstractProtocCompileMojo {
/**
* This is the directory into which the {@code .py} will be created.
*/
@Parameter(
required = true,
property = "pythonOutputDirectory",
defaultValue = "${project.build.directory}/generated-sources/protobuf/python"
)
private File outputDirectory;
@Override
protected void addProtocBuilderParameters(final Protoc.Builder protocBuilder) {
super.addProtocBuilderParameters(protocBuilder);
protocBuilder.setPythonOutputDirectory(getOutputDirectory());
}
@Override
protected File getOutputDirectory() {
return outputDirectory;
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/ProtocPlugin.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.plugin.logging.Log;
import org.codehaus.plexus.util.Os;
import java.io.File;
import java.util.List;
import static java.util.Collections.emptyList;
/**
* Describes a {@code protoc} plugin that is written in Java and
* assembled from resolved artifacts at runtime.
* The state is populated from the Maven plugin's configuration.
*
* @since 0.3.0
*/
public class ProtocPlugin {
private static final String DATA_MODEL_SYSPROP = "sun.arch.data.model";
private static final String WIN_JVM_DATA_MODEL_32 = "32";
private static final String WIN_JVM_DATA_MODEL_64 = "64";
private String id;
private String groupId;
private String artifactId;
private String version;
private String classifier;
private String mainClass;
private String javaHome;
// Assuming we're running a HotSpot JVM, use the data model of the
// current JVM as the default. This property is only relevant on
// Windows where we need to pick the right version of the WinRun4J executable.
private String winJvmDataModel;
private List args;
private List jvmArgs;
/**
* Returns the unique id for this plugin.
*
* @return the plugin's unique id.
*/
public String getId() {
return id;
}
/**
* Returns group id of the plugin's artifact for dependency resolution.
*
* @return the plugin's group id.
*/
public String getGroupId() {
return groupId;
}
/**
* Returns the plugin's artifact id for dependency resolution.
*
* @return the plugin's artifact id.
*/
public String getArtifactId() {
return artifactId;
}
/**
* Returns the plugin's version specification for dependency resolution.
* This can be specified as either a single version or a version range.
*
* @return the plugin's version or version range.
*/
public String getVersion() {
return version;
}
/**
* Returns an optional classifier of the plugin's artifact for dependency resolution.
*
* @return the plugin's artifact classifier.
*/
public String getClassifier() {
return classifier;
}
/**
* Returns the plugin's Java main class to be execute by protoc.
*
* @return fully qualified name for the main class.
*/
public String getMainClass() {
return mainClass;
}
/**
* Returns optional command line arguments to pass to the {@code main()} method.
*
* @return a list of command-line arguments.
*/
public List getArgs() {
return args != null ? args : emptyList();
}
/**
* Returns optional JVM options for plugin execution.
*
* @return a list of JVM options.
*/
public List getJvmArgs() {
return jvmArgs != null ? jvmArgs : emptyList();
}
public String getJavaHome() {
return javaHome;
}
public void setJavaHome(final String javaHome) {
this.javaHome = javaHome;
}
public String getWinJvmDataModel() {
return winJvmDataModel;
}
public String getPluginName() {
return "protoc-gen-" + id;
}
/**
* Validate the state of this plugin specification.
*
* @param log a logger instance for diagnostic output.
*/
public void validate(final Log log) {
if (id == null) {
throw new MojoConfigurationException("id must be set in protocPlugin definition");
}
if (groupId == null) {
throw new MojoConfigurationException("groupId must be set in protocPlugin definition");
}
if (artifactId == null) {
throw new MojoConfigurationException("artifactId must be set in protocPlugin definition");
}
if (version == null) {
throw new MojoConfigurationException("version must be set in protocPlugin definition");
}
if (mainClass == null) {
throw new MojoConfigurationException("mainClass must be set in protocPlugin definition");
}
if (javaHome == null || !new File(javaHome).isDirectory()) {
throw new MojoConfigurationException("javaHome is invalid: " + javaHome);
}
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
// If winJvmDataModel isn't set explicitly, try to guess the architecture
// by looking at the directories in the JDK/JRE javaHome points at.
// If that fails, try to figure out from the currently running JVM.
if (winJvmDataModel != null) {
if (!(winJvmDataModel.equals(WIN_JVM_DATA_MODEL_32) || winJvmDataModel.equals(WIN_JVM_DATA_MODEL_64))) {
throw new MojoConfigurationException("winJvmDataModel must be '32' or '64'");
}
} else if (archDirectoryExists("amd64")) {
winJvmDataModel = WIN_JVM_DATA_MODEL_64;
if (log.isDebugEnabled()) {
log.debug("detected 64-bit JVM from directory structure");
}
} else if (archDirectoryExists("i386")) {
winJvmDataModel = WIN_JVM_DATA_MODEL_32;
if (log.isDebugEnabled()) {
log.debug("detected 32-bit JVM from directory structure");
}
} else if (System.getProperty(DATA_MODEL_SYSPROP) != null) {
winJvmDataModel = System.getProperty(DATA_MODEL_SYSPROP);
if (log.isDebugEnabled()) {
log.debug("detected " + winJvmDataModel + "-bit JVM from system property " + DATA_MODEL_SYSPROP);
}
} else {
winJvmDataModel = WIN_JVM_DATA_MODEL_32;
if (log.isDebugEnabled()) {
log.debug("defaulting to 32-bit JVM");
}
}
}
}
private boolean archDirectoryExists(String arch) {
return javaHome != null
&& (new File(javaHome, "jre/lib/" + arch).isDirectory()
|| new File(javaHome, "lib/" + arch).isDirectory());
}
/**
* Returns the generated plugin executable path.
*
* @param pluginDirectory directory where plugins will be created
* @return file handle for the plugin executable.
*/
public File getPluginExecutableFile(final File pluginDirectory) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
return new File(pluginDirectory, getPluginName() + ".exe");
} else {
return new File(pluginDirectory, getPluginName());
}
}
@Override
public String toString() {
return "ProtocPlugin{" +
"id='" + id + '\'' +
", groupId='" + groupId + '\'' +
", artifactId='" + artifactId + '\'' +
", version='" + version + '\'' +
", classifier='" + classifier + '\'' +
", mainClass='" + mainClass + '\'' +
", javaHome='" + javaHome + '\'' +
", winJvmDataModel='" + winJvmDataModel + '\'' +
", args=" + args +
", jvmArgs=" + jvmArgs +
'}';
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/ProtocPluginAssembler.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.ResolutionErrorHandler;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.repository.RepositorySystem;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.Os;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import static java.util.Collections.emptyMap;
/**
* Creates an executable {@code protoc} plugin (written in Java) from a {@link ProtocPlugin} specification.
*
* @since 0.3.0
*/
public class ProtocPluginAssembler {
private final ProtocPlugin pluginDefinition;
private final MavenSession session;
private final Artifact rootResolutionArtifact;
private final ArtifactFactory artifactFactory;
private final RepositorySystem repositorySystem;
private final ResolutionErrorHandler resolutionErrorHandler;
private final ArtifactRepository localRepository;
private final List remoteRepositories;
private final File pluginDirectory;
private final List resolvedJars = new ArrayList<>();
private final File pluginExecutableFile;
private final Log log;
public ProtocPluginAssembler(
final ProtocPlugin pluginDefinition,
final MavenSession session,
final Artifact rootResolutionArtifact,
final ArtifactFactory artifactFactory,
final RepositorySystem repositorySystem,
final ResolutionErrorHandler resolutionErrorHandler,
final ArtifactRepository localRepository,
final List remoteRepositories,
final File pluginDirectory,
final Log log) {
this.pluginDefinition = pluginDefinition;
this.session = session;
this.rootResolutionArtifact = rootResolutionArtifact;
this.artifactFactory = artifactFactory;
this.repositorySystem = repositorySystem;
this.resolutionErrorHandler = resolutionErrorHandler;
this.localRepository = localRepository;
this.remoteRepositories = remoteRepositories;
this.pluginDirectory = pluginDirectory;
this.pluginExecutableFile = pluginDefinition.getPluginExecutableFile(pluginDirectory);
this.log = log;
}
/**
* Resolves the plugin's dependencies to the local Maven repository and builds the plugin executable.
*/
public void execute() {
pluginDefinition.validate(log);
if (log.isDebugEnabled()) {
log.debug("plugin definition: " + pluginDefinition);
}
resolvePluginDependencies();
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
buildWindowsPlugin();
copyWinRun4JExecutable();
} else {
buildUnixPlugin();
pluginExecutableFile.setExecutable(true);
}
}
private void buildWindowsPlugin() {
createPluginDirectory();
// Try to locate jvm.dll based on pluginDefinition's javaHome property
final File javaHome = new File(pluginDefinition.getJavaHome());
final File jvmLocation = findJvmLocation(javaHome,
"jre/bin/server/jvm.dll",
"bin/server/jvm.dll",
"jre/bin/client/jvm.dll",
"bin/client/jvm.dll");
final File winRun4JIniFile = new File(pluginDirectory, pluginDefinition.getPluginName() + ".ini");
if (log.isDebugEnabled()) {
log.debug("javaHome=" + javaHome.getAbsolutePath());
log.debug("jvmLocation=" + (jvmLocation != null ? jvmLocation.getAbsolutePath() : "(none)"));
log.debug("winRun4JIniFile=" + winRun4JIniFile.getAbsolutePath());
log.debug("winJvmDataModel=" + pluginDefinition.getWinJvmDataModel());
}
try (final PrintWriter out = new PrintWriter(new FileWriter(winRun4JIniFile))) {
if (jvmLocation != null) {
out.println("vm.location=" + jvmLocation.getAbsolutePath());
}
int index = 1;
for (final File resolvedJar : resolvedJars) {
out.println("classpath." + index + "=" + resolvedJar.getAbsolutePath());
index++;
}
out.println("main.class=" + pluginDefinition.getMainClass());
index = 1;
for (final String arg : pluginDefinition.getArgs()) {
out.println("arg." + index + "=" + arg);
index++;
}
index = 1;
for (final String jvmArg : pluginDefinition.getJvmArgs()) {
out.println("vmarg." + index + "=" + jvmArg);
index++;
}
out.println("vm.version.min=1.8");
// keep from logging to stdout (the default)
out.println("log.level=none");
out.println("[ErrorMessages]");
out.println("show.popup=false");
} catch (IOException e) {
throw new MojoInitializationException(
"Could not write WinRun4J ini file: " + winRun4JIniFile.getAbsolutePath(), e);
}
}
private static File findJvmLocation(final File javaHome, final String... paths) {
for (final String path : paths) {
final File jvmLocation = new File(javaHome, path);
if (jvmLocation.isFile()) {
return jvmLocation;
}
}
return null;
}
private void copyWinRun4JExecutable() {
final String executablePath = getWinrun4jExecutablePath();
final URL url = Thread.currentThread().getContextClassLoader().getResource(executablePath);
if (url == null) {
throw new MojoInitializationException(
"Could not locate WinRun4J executable at path: " + executablePath);
}
try {
FileUtils.copyURLToFile(url, pluginExecutableFile);
} catch (IOException e) {
throw new MojoInitializationException(
"Could not copy WinRun4J executable to: " + pluginExecutableFile.getAbsolutePath(), e);
}
}
private void buildUnixPlugin() {
createPluginDirectory();
final File javaLocation = new File(pluginDefinition.getJavaHome(), "bin/java");
if (log.isDebugEnabled()) {
log.debug("javaLocation=" + javaLocation.getAbsolutePath());
}
try (final PrintWriter out = new PrintWriter(new FileWriter(pluginExecutableFile))) {
out.println("#!/bin/sh");
out.println();
out.print("CP=");
for (int i = 0; i < resolvedJars.size(); i++) {
if (i > 0) {
out.print(":");
}
out.print("\"" + resolvedJars.get(i).getAbsolutePath() + "\"");
}
out.println();
out.print("ARGS=\"");
for (final String arg : pluginDefinition.getArgs()) {
out.print(arg + " ");
}
out.println("\"");
out.print("JVMARGS=\"");
for (final String jvmArg : pluginDefinition.getJvmArgs()) {
out.print(jvmArg + " ");
}
out.println("\"");
out.println();
out.println("\"" + javaLocation.getAbsolutePath() + "\" $JVMARGS -cp $CP "
+ pluginDefinition.getMainClass() + " $ARGS");
out.println();
} catch (IOException e) {
throw new MojoInitializationException("Could not write plugin script file: " + pluginExecutableFile, e);
}
}
private void createPluginDirectory() {
pluginDirectory.mkdirs();
if (!pluginDirectory.isDirectory()) {
throw new MojoInitializationException("Could not create protoc plugin directory: "
+ pluginDirectory.getAbsolutePath());
}
}
private void resolvePluginDependencies() {
final VersionRange versionSpec;
try {
versionSpec = VersionRange.createFromVersionSpec(pluginDefinition.getVersion());
} catch (InvalidVersionSpecificationException e) {
throw new MojoConfigurationException("Invalid plugin version specification", e);
}
final Artifact protocPluginArtifact =
artifactFactory.createDependencyArtifact(
pluginDefinition.getGroupId(),
pluginDefinition.getArtifactId(),
versionSpec,
"jar",
pluginDefinition.getClassifier(),
Artifact.SCOPE_RUNTIME);
final ArtifactResolutionRequest request = new ArtifactResolutionRequest()
.setArtifact(rootResolutionArtifact)
.setResolveRoot(false)
.setArtifactDependencies(Collections.singleton(protocPluginArtifact))
.setManagedVersionMap(emptyMap())
.setLocalRepository(localRepository)
.setRemoteRepositories(remoteRepositories)
.setOffline(session.isOffline())
.setForceUpdate(session.getRequest().isUpdateSnapshots())
.setServers(session.getRequest().getServers())
.setMirrors(session.getRequest().getMirrors())
.setProxies(session.getRequest().getProxies());
final ArtifactResolutionResult result = repositorySystem.resolve(request);
try {
resolutionErrorHandler.throwErrors(request, result);
} catch (ArtifactResolutionException e) {
throw new MojoInitializationException("Unable to resolve plugin artifact: " + e.getMessage(), e);
}
final Set artifacts = result.getArtifacts();
if (artifacts == null || artifacts.isEmpty()) {
throw new MojoInitializationException("Unable to resolve plugin artifact");
}
for (final Artifact artifact : artifacts) {
resolvedJars.add(artifact.getFile());
}
if (log.isDebugEnabled()) {
log.debug("Resolved jars: " + resolvedJars);
}
}
private String getWinrun4jExecutablePath() {
return "winrun4j/WinRun4J" + pluginDefinition.getWinJvmDataModel() + ".exe";
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/ProtocTestCompileCppMojo.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import java.io.File;
/**
* This mojo executes the {@code protoc} compiler for generating test C++ sources
* from protocol buffer definitions. It also searches dependency artifacts in the test scope for
* {@code .proto} files and includes them in the {@code proto_path} so that they can be
* referenced. Finally, it adds the {@code .proto} files to the project as test resources so
* that they can be included in the test-jar artifact.
*
* @since 0.3.3
*/
@Mojo(
name = "test-compile-cpp",
defaultPhase = LifecyclePhase.GENERATE_TEST_SOURCES,
requiresDependencyResolution = ResolutionScope.TEST,
threadSafe = true
)
public final class ProtocTestCompileCppMojo extends AbstractProtocTestCompileMojo {
/**
* This is the directory into which the {@code .cpp} test sources will be created.
*/
@Parameter(
required = true,
property = "cppTestOutputDirectory",
defaultValue = "${project.build.directory}/generated-test-sources/protobuf/cpp"
)
private File outputDirectory;
@Override
protected void addProtocBuilderParameters(final Protoc.Builder protocBuilder) {
super.addProtocBuilderParameters(protocBuilder);
protocBuilder.setCppOutputDirectory(getOutputDirectory());
// We need to add project output directory to the protobuf import paths,
// in case test protobuf definitions extend or depend on production ones
final File buildOutputDirectory = new File(project.getBuild().getOutputDirectory());
if (buildOutputDirectory.exists()) {
protocBuilder.addProtoPathElement(buildOutputDirectory);
}
}
@Override
protected File getOutputDirectory() {
return outputDirectory;
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/ProtocTestCompileCsharpMojo.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import java.io.File;
/**
* This mojo executes the {@code protoc} compiler for generating test C# sources
* from protocol buffer definitions. It also searches dependency artifacts in the test scope for
* {@code .proto} files and includes them in the {@code proto_path} so that they can be
* referenced. Finally, it adds the {@code .proto} files to the project as test resources so
* that they can be included in the test-jar artifact.
*
* @since 0.6.0
*/
@Mojo(
name = "test-compile-csharp",
defaultPhase = LifecyclePhase.GENERATE_TEST_SOURCES,
requiresDependencyResolution = ResolutionScope.TEST,
threadSafe = true
)
public final class ProtocTestCompileCsharpMojo extends AbstractProtocTestCompileMojo {
/**
* This is the directory into which the {@code .cs} test sources will be created.
*/
@Parameter(
required = true,
property = "csharpTestOutputDirectory",
defaultValue = "${project.build.directory}/generated-test-sources/protobuf/csharp"
)
private File outputDirectory;
@Override
protected void addProtocBuilderParameters(final Protoc.Builder protocBuilder) {
super.addProtocBuilderParameters(protocBuilder);
protocBuilder.setCsharpOutputDirectory(getOutputDirectory());
// We need to add project output directory to the protobuf import paths,
// in case test protobuf definitions extend or depend on production ones
final File buildOutputDirectory = new File(project.getBuild().getOutputDirectory());
if (buildOutputDirectory.exists()) {
protocBuilder.addProtoPathElement(buildOutputDirectory);
}
}
@Override
protected File getOutputDirectory() {
return outputDirectory;
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/ProtocTestCompileCustomMojo.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.toolchain.Toolchain;
import java.io.File;
/**
* This mojo executes the {@code protoc} compiler with the specified plugin
* executable to generate test sources from protocol buffer definitions.
* It also searches dependency artifacts for {@code .proto} files and
* includes them in the {@code proto_path} so that they can be referenced.
* Finally, it adds the {@code .proto} files to the project as resources so
* that they can be included in the test-jar artifact.
*
* @since 0.4.1
*/
@Mojo(
name = "test-compile-custom",
defaultPhase = LifecyclePhase.GENERATE_TEST_SOURCES,
requiresDependencyResolution = ResolutionScope.TEST,
threadSafe = true
)
public final class ProtocTestCompileCustomMojo extends AbstractProtocTestCompileMojo {
/**
* A unique id that identifies the plugin to protoc.
* Cannot be one of the built-in protoc plugins:
*
*
java
*
js
*
csharp
*
cpp
*
python
*
descriptor-set
*
*/
@Parameter(
required = true,
property = "protocPluginId"
)
private String pluginId;
/**
* This is the base directory for the generated code.
* If an explicit {@link #outputDirectory} parameter is not specified,
* an output directory named after {@link #pluginId} will be created
* inside this base directory.
*/
@Parameter(
required = true,
readonly = true,
defaultValue = "${project.build.directory}/generated-test-sources/protobuf"
)
private File outputBaseDirectory;
/**
* This is the directory where the generated code will be placed.
* If this parameter is unspecified, then the default location is constructed as follows:
* ${project.build.directory}/generated-test-sources/protobuf/<pluginId>
*/
@Parameter(
required = false,
property = "protocPluginOutputDirectory"
)
private File outputDirectory;
/**
* An optional path to plugin executable.
* If unspecified, alternative options must be used (e.g. toolchains).
*/
@Parameter(
required = false,
property = "protocPluginExecutable"
)
private String pluginExecutable;
/**
* An optional parameter to be passed to the plugin.
* Cannot contain colon (:) symbols.
*/
@Parameter(
required = false,
property = "protocPluginParameter"
)
private String pluginParameter;
/**
* A name of an optional custom toolchain that can be used to locate the plugin executable.
* The toolchain must be registered as a build extension and initialised properly.
*/
@Parameter(
required = false,
property = "protocPluginToolchain"
)
private String pluginToolchain;
/**
* If {@link #pluginToolchain} is specified, this parameter specifies the tool in the toolchain,
* which is to be resolved as plugin executable.
*/
@Parameter(
required = false,
property = "protocPluginTool"
)
private String pluginTool;
/**
* Plugin artifact specification, in {@code groupId:artifactId:version[:type[:classifier]]} format.
* When this parameter is set, the specified artifact will be resolved as a plugin executable.
*
* @since 0.4.1
*/
@Parameter(
required = false,
property = "protocPluginArtifact"
)
private String pluginArtifact;
@Override
protected void addProtocBuilderParameters(final Protoc.Builder protocBuilder) {
super.addProtocBuilderParameters(protocBuilder);
protocBuilder.setNativePluginId(pluginId);
if (pluginToolchain != null && pluginTool != null) {
//get toolchain from context
final Toolchain tc = toolchainManager.getToolchainFromBuildContext(pluginToolchain, session);
if (tc != null) {
getLog().info("Toolchain in protobuf-maven-plugin: " + tc);
//when the executable to use is explicitly set by user in mojo's parameter, ignore toolchains.
if (pluginExecutable != null) {
getLog().warn("Toolchains are ignored, 'pluginExecutable' parameter is set to " + pluginExecutable);
} else {
//assign the path to executable from toolchains
pluginExecutable = tc.findTool(pluginTool);
}
}
}
if (pluginExecutable == null && pluginArtifact != null) {
final Artifact artifact = createDependencyArtifact(pluginArtifact);
final File file = resolveBinaryArtifact(artifact);
pluginExecutable = file.getAbsolutePath();
}
if (pluginExecutable != null) {
protocBuilder.setNativePluginExecutable(pluginExecutable);
}
if (pluginParameter != null) {
protocBuilder.setNativePluginParameter(pluginParameter);
}
protocBuilder.setCustomOutputDirectory(getOutputDirectory());
// We need to add project output directory to the protobuf import paths,
// in case test protobuf definitions extend or depend on production ones
final File buildOutputDirectory = new File(project.getBuild().getOutputDirectory());
if (buildOutputDirectory.exists()) {
protocBuilder.addProtoPathElement(buildOutputDirectory);
}
}
@Override
protected File getOutputDirectory() {
File outputDirectory = this.outputDirectory;
if (outputDirectory == null) {
outputDirectory = new File(outputBaseDirectory, pluginId);
}
return outputDirectory;
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/ProtocTestCompileDescriptorSetMojo.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import java.io.File;
/**
* This mojo executes {@code protoc} compiler for generating descriptor sets
* from test protocol buffer definitions. It also searches dependency artifacts for
* {@code .proto} files and includes them in the {@code proto_path} so that they can be
* referenced. Finally, it adds the {@code .proto} files to the project as test resources so
* that they can be included in the test-jar artifact. The generated descriptor set can be
* optionally also attached to the project.
*
* @since 0.7.0
*/
@Mojo(
name = "test-compile-descriptor-set",
defaultPhase = LifecyclePhase.GENERATE_TEST_RESOURCES,
requiresDependencyResolution = ResolutionScope.TEST,
threadSafe = true
)
public final class ProtocTestCompileDescriptorSetMojo extends AbstractProtocTestCompileMojo {
/**
* This is the directory into which the descriptor set file will be created.
*/
@Parameter(
required = true,
property = "descriptorSetTestOutputDirectory",
defaultValue = "${project.build.directory}/generated-test-resources/protobuf/descriptor-sets"
)
private File outputDirectory;
/**
* The descriptor set file name.
*/
@Parameter(
required = true,
defaultValue = "${project.build.finalName}.pb"
)
protected String descriptorSetFileName;
/**
* If set to {@code true}, the generated descriptor set will be attached to the build.
*/
@Parameter(
required = true,
defaultValue = "false"
)
protected boolean attach;
/**
* If generated descriptor set is to be attached to the build, specifies an optional classifier.
*/
@Parameter(
required = false,
defaultValue = "test"
)
protected String classifier;
/**
* If {@code true}, the compiler will include all dependencies in the descriptor set, making it self-contained.
*/
@Parameter(
required = false,
defaultValue = "false"
)
protected boolean includeImports;
/**
* If {@code true}, do not strip {@code SourceCodeInfo} from the {@code FileDescriptorProto}.
* This results in significantly larger descriptors that include information about the original location
* of each declaration in the source file, as well as surrounding comments.
*/
@Parameter(
required = false,
defaultValue = "false"
)
protected boolean includeSourceInfo;
@Override
protected void addProtocBuilderParameters(final Protoc.Builder protocBuilder) {
super.addProtocBuilderParameters(protocBuilder);
final File descriptorSetFile = new File(getOutputDirectory(), descriptorSetFileName);
getLog().info("Will generate descriptor set:");
getLog().info(" " + descriptorSetFile.getAbsolutePath());
protocBuilder.withDescriptorSetFile(descriptorSetFile, includeImports, includeSourceInfo);
// We need to add project output directory to the protobuf import paths,
// in case test protobuf definitions extend or depend on production ones
final File buildOutputDirectory = new File(project.getBuild().getOutputDirectory());
if (buildOutputDirectory.exists()) {
protocBuilder.addProtoPathElement(buildOutputDirectory);
}
}
@Override
protected File getOutputDirectory() {
return outputDirectory;
}
@SuppressWarnings("MethodDoesntCallSuperMethod")
@Override
protected void doAttachGeneratedFiles() {
final File outputDirectory = getOutputDirectory();
if (attach) {
final File descriptorSetFile = new File(getOutputDirectory(), descriptorSetFileName);
projectHelper.attachArtifact(project, "test-pb", classifier, descriptorSetFile);
}
buildContext.refresh(outputDirectory);
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/ProtocTestCompileJavaScriptMojo.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import java.io.File;
/**
* This mojo executes the {@code protoc} compiler for generating test JavaScript sources
* from protocol buffer definitions. It also searches dependency artifacts in the test scope for
* {@code .proto} files and includes them in the {@code proto_path} so that they can be
* referenced. Finally, it adds the {@code .proto} files to the project as test resources so
* that they can be included in the test-jar artifact.
*
* @since 0.6.0
*/
@Mojo(
name = "test-compile-js",
defaultPhase = LifecyclePhase.GENERATE_TEST_SOURCES,
requiresDependencyResolution = ResolutionScope.TEST,
threadSafe = true
)
public final class ProtocTestCompileJavaScriptMojo extends AbstractProtocTestCompileMojo {
/**
* This is the directory into which the {@code .js} test sources will be created.
*/
@Parameter(
required = true,
property = "javaScriptTestOutputDirectory",
defaultValue = "${project.build.directory}/generated-test-sources/protobuf/js"
)
private File outputDirectory;
/**
* Additional comma-separated options to be passed to the JavaScript generator.
* Cannot contain colon (:) symbols.
*/
@Parameter(
required = false,
property = "javaScriptOptions"
)
private String javaScriptOptions;
@Override
protected void addProtocBuilderParameters(final Protoc.Builder protocBuilder) {
super.addProtocBuilderParameters(protocBuilder);
if (javaScriptOptions != null) {
protocBuilder.setNativePluginParameter(javaScriptOptions);
}
protocBuilder.setJavaScriptOutputDirectory(getOutputDirectory());
// We need to add project output directory to the protobuf import paths,
// in case test protobuf definitions extend or depend on production ones
final File buildOutputDirectory = new File(project.getBuild().getOutputDirectory());
if (buildOutputDirectory.exists()) {
protocBuilder.addProtoPathElement(buildOutputDirectory);
}
}
@Override
protected File getOutputDirectory() {
return outputDirectory;
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/ProtocTestCompileMojo.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import java.io.File;
/**
* This mojo executes the {@code protoc} compiler for generating test Java sources
* from protocol buffer definitions. It also searches dependency artifacts in the test scope for
* {@code .proto} files and includes them in the {@code proto_path} so that they can be
* referenced. Finally, it adds the {@code .proto} files to the project as test resources so
* that they can be included in the test-jar artifact.
*
* @since 0.3.3
*/
@Mojo(
name = "test-compile",
defaultPhase = LifecyclePhase.GENERATE_TEST_SOURCES,
requiresDependencyResolution = ResolutionScope.TEST,
threadSafe = true
)
public final class ProtocTestCompileMojo extends AbstractProtocTestCompileMojo {
/**
* This is the directory into which the {@code .java} test sources will be created.
*/
@Parameter(
required = true,
property = "javaTestOutputDirectory",
defaultValue = "${project.build.directory}/generated-test-sources/protobuf/java"
)
private File outputDirectory;
/**
* Additional comma-separated options to be passed to the Java generator.
* Cannot contain colon (:) symbols.
*
* @since 0.7.0
*/
@Parameter(
required = false,
property = "javaOptions"
)
private String javaOptions;
@Override
protected void addProtocBuilderParameters(final Protoc.Builder protocBuilder) {
super.addProtocBuilderParameters(protocBuilder);
if (javaOptions != null) {
protocBuilder.setNativePluginParameter(javaOptions);
}
protocBuilder.setJavaOutputDirectory(getOutputDirectory());
// We need to add project output directory to the protobuf import paths,
// in case test protobuf definitions extend or depend on production ones
final File buildOutputDirectory = new File(project.getBuild().getOutputDirectory());
if (buildOutputDirectory.exists()) {
protocBuilder.addProtoPathElement(buildOutputDirectory);
}
}
@Override
protected File getOutputDirectory() {
return outputDirectory;
}
}
================================================
FILE: src/main/java/org/xolstice/maven/plugin/protobuf/ProtocTestCompilePythonMojo.java
================================================
package org.xolstice.maven.plugin.protobuf;
/*
* Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import java.io.File;
/**
* This mojo executes the {@code protoc} compiler for generating test python sources
* from protocol buffer definitions. It also searches dependency artifacts in the test scope for
* {@code .proto} files and includes them in the {@code proto_path} so that they can be
* referenced. Finally, it adds the {@code .proto} files to the project as test resources so
* that they can be included in the test-jar artifact.
*
* @since 0.3.3
*/
@Mojo(
name = "test-compile-python",
defaultPhase = LifecyclePhase.GENERATE_TEST_SOURCES,
requiresDependencyResolution = ResolutionScope.TEST,
threadSafe = true
)
public final class ProtocTestCompilePythonMojo extends AbstractProtocTestCompileMojo {
/**
* This is the directory into which the {@code .py} test sources will be created.
*/
@Parameter(
required = true,
property = "pythonTestOutputDirectory",
defaultValue = "${project.build.directory}/generated-test-sources/protobuf/python"
)
private File outputDirectory;
@Override
protected void addProtocBuilderParameters(final Protoc.Builder protocBuilder) {
super.addProtocBuilderParameters(protocBuilder);
protocBuilder.setPythonOutputDirectory(getOutputDirectory());
// We need to add project output directory to the protobuf import paths,
// in case test protobuf definitions extend or depend on production ones
final File buildOutputDirectory = new File(project.getBuild().getOutputDirectory());
if (buildOutputDirectory.exists()) {
protocBuilder.addProtoPathElement(buildOutputDirectory);
}
}
@Override
protected File getOutputDirectory() {
return outputDirectory;
}
}
================================================
FILE: src/main/java/org/xolstice/maven/toolchain/protobuf/DefaultProtobufToolchain.java
================================================
package org.xolstice.maven.toolchain.protobuf;
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.toolchain.DefaultToolchain;
import org.apache.maven.toolchain.model.ToolchainModel;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.FileUtils;
import java.io.File;
/**
* Based on {@code org.apache.maven.toolchain.java.DefaultJavaToolChain}.
*
* @since 0.2.0
*/
public class DefaultProtobufToolchain extends DefaultToolchain implements ProtobufToolchain {
public static final String KEY_PROTOC_EXECUTABLE = "protocExecutable";
protected DefaultProtobufToolchain(ToolchainModel model, Logger logger) {
super(model, "protobuf", logger);
}
private String protocExecutable;
@Override
public String findTool(String toolName) {
if ("protoc".equals(toolName)) {
File protoc = new File(FileUtils.normalize(getProtocExecutable()));
if (protoc.exists()) {
return protoc.getAbsolutePath();
}
}
return null;
}
@Override
public String getProtocExecutable() {
return this.protocExecutable;
}
@Override
public void setProtocExecutable(String protocExecutable) {
this.protocExecutable = protocExecutable;
}
@Override
public String toString() {
return "PROTOC[" + getProtocExecutable() + "]";
}
}
================================================
FILE: src/main/java/org/xolstice/maven/toolchain/protobuf/DefaultProtobufToolchainFactory.java
================================================
package org.xolstice.maven.toolchain.protobuf;
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* 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.
*/
import org.apache.maven.toolchain.MisconfiguredToolchainException;
import org.apache.maven.toolchain.RequirementMatcher;
import org.apache.maven.toolchain.RequirementMatcherFactory;
import org.apache.maven.toolchain.ToolchainFactory;
import org.apache.maven.toolchain.ToolchainPrivate;
import org.apache.maven.toolchain.model.ToolchainModel;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.io.File;
import java.util.Map;
import java.util.Properties;
/**
* Based on {@code org.apache.maven.toolchain.java.DefaultJavaToolchainFactory}.
*
* @since 0.2.0
*/
@Component(
role = ToolchainFactory.class,
hint = "protobuf",
description = "A default factory for 'protobuf' toolchains")
public class DefaultProtobufToolchainFactory implements ToolchainFactory {
@Requirement
private Logger logger;
@Override
public ToolchainPrivate createToolchain(final ToolchainModel model) throws MisconfiguredToolchainException {
if (model == null) {
return null;
}
final DefaultProtobufToolchain toolchain = new DefaultProtobufToolchain(model, logger);
// populate the configuration section
final Properties configuration = toProperties((Xpp3Dom) model.getConfiguration());
final String protocExecutable = configuration.getProperty(DefaultProtobufToolchain.KEY_PROTOC_EXECUTABLE);
if (protocExecutable == null) {
throw new MisconfiguredToolchainException(
"Protobuf toolchain without the "
+ DefaultProtobufToolchain.KEY_PROTOC_EXECUTABLE
+ " configuration element.");
}
final String normalizedProtocExecutablePath = FileUtils.normalize(protocExecutable);
final File protocExecutableFile = new File(normalizedProtocExecutablePath);
if (protocExecutableFile.exists()) {
toolchain.setProtocExecutable(normalizedProtocExecutablePath);
} else {
throw new MisconfiguredToolchainException(
"Non-existing protoc executable at " + protocExecutableFile.getAbsolutePath());
}
// populate the provides section
final Properties provides = model.getProvides();
for (final Map.Entry