dtrott / maven-thrift-plugin Goto Github PK
View Code? Open in Web Editor NEWMaven Thrift Plugin that executes the thrift code generator (base on protocol buffers plugin)
Maven Thrift Plugin that executes the thrift code generator (base on protocol buffers plugin)
Hey David,
it would be great, if this projects artifacts would be on maven central. Why: Because Maven Central only accepts the submission of artifacts, whose dependencies are in there as well. As I plan to submit one of my projects using your plugin - that would be great.
How to do this? Have a look at http://maven.apache.org/guides/mini/guide-central-repository-upload.html
Best,
Benjamin
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>nd.pemo</groupId>
<artifactId>thrift-rpc-sample-client</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>0.18.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
</dependencies>
<build>
<defaultGoal>clean generate-sources compile install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.thrift.tools</groupId>
<artifactId>maven-thrift-plugin</artifactId>
<version>0.1.11</version>
<configuration>
<generator>java</generator>
<thriftExecutable>/usr/bin/thrift</thriftExecutable>
<thriftSourceRoot>${basedir}/src/main/resources/thrift</thriftSourceRoot>
<outputDirectory>${basedir}/src/main/java/thrift</outputDirectory>
</configuration>
<executions>
<execution>
<id>thrift-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
namespace java thrift.rpc.api.user
namespace cpp thrift.rpc.api.user
struct LoginRequest {
1: string username,
2: string password
}
struct APIResponse {
1: string responsemessage,
2: i32 responseCode
}
# empty for logout request
struct Empty {
}
# specific response for logout
struct LogoutResponse {
1: string logoutmessage,
2: i32 responseCode
}
service User {
APIResponse login(1:LoginRequest loginRequest);
LogoutResponse logout(1:Empty empty);
}
The namespace java thrift.rpc.api.user
will append another thrift
to <outputDirectory>${basedir}/src/main/java/thrift</outputDirectory>
. So, it will be src/main/java/thrift/thrift/rpc/api/user
. The package of generated classes would be wrong.
I've only discovered that artifactId is now thrift-maven-plugin instead of maven-thrift-plugin by looking at pom.xml (while trying to find out what is the latest version, which also could usefully be listed in README).
I am using Thrift 0.6.0 with the 0.1.10 thrift plugin. If I use
java:beans
I get a NPE with the following stack trace
java.lang.NullPointerException
at org.apache.thrift.maven.Thrift.moveGeneratedFiles(Thrift.java:117)
at org.apache.thrift.maven.Thrift.compile(Thrift.java:85)
at org.apache.thrift.maven.AbstractThriftMojo.execute(AbstractThriftMojo.java:158)
at org.apache.thrift.maven.ThriftCompileMojo.execute(ThriftCompileMojo.java:22)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
...
This happens because with the java:beans generator, the code is output into the "gen-javabean" directory. However, Thrift.java defines GENERATED_JAVA to be "gen-java" and this causes the NPE. Not sure what the recommended fix is but I would be happy to spin up a patch after discussion.
It seems the plugin is not compatible with latest thrift version (Apache Thrift v0.11.0). Could any one please suggest the solution or alternatives?
Each of the source files carries a license blob but it would be good to have a project level license file as well
I just upgraded my environment to Eclipse 3.7 (Indigo) and the m2e plugin (using the 0.1.11 maven-thrift-plugin). m2e now complains about "Plugin execution not covered by lifecycle configuration" for the maven-thrift-plugin.
More information on this problem can be found at http://wiki.eclipse.org/M2E_plugin_execution_not_covered and, while one could always set the plugin to always execute, I think it might be better to "delegate". Any recommendations on what the preferred config should be? I am not completely familiar with how the thrift plugin/maven plugin ecosystem. Happy to experiment and report back on suggestions.
See also http://jira.codehaus.org/browse/MFINDBUGS-100 - in Eclipse, which uses Maven 3 beta, I get exactly the same messages about Maven not being able to setup the localRepository for the Compile Mojo. The patch attached to that issue also seems to apply to the Thrift plugin, because when I s/DefaultArtifactRepository/ArtifactRepository/, the errors go away.
What user can expect:
mvn generate-sources
generate the sources for the main foldermvn generate-test-sources
generate the sources for the test folderWhat it should be writted:
<executions> <execution> <phase>generate-sources</phase> <goals> <goal>compile</goal> </goals> </execution> <execution> <phase>generate-test-sources</phase> <goals> <goal>testCompile</goal> </goals> </execution> </executions>
I am trying to make a mvn clean install using.. the following maven file and this is what I get:
[ERROR] thrift failed error: !!! Unrecognized option: -out
this is my file
4.0.0 logtrust thrifttest 0.0.1-SNAPSHOT org.apache.maven.plugins maven-compiler-plugin </executions>
</plugin>
</plugins>
</build>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.8</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
</dependencies>
The buildThriftCommand method in Thrift.java generates a -out param which isn't recognised. In earlier versions of Thrift -- well, 0.5.0 which is the only one I've tried -- this should be -o.
Feel free to mark as WONTFIX if backwards compat. isn't a goal :-)
If I specify outputDirectory as ./src/main/java/, it will cleanup all my source files in ./src/main/java.
I would like generate the thrift java files so that the same project could import and use it. But if I set the outputDirectory as the path of my source code, it will cleanup all files.
Hello,
Is there a way to invoke this plugin for multiple idl files?
Note that in my case, there is no parent/shared folder that contains my separate idls, I cannot afford to pass a common root folder and recursively generate code for all thrift files below it.
Thanks
Feature suggestion: it would be cool if it were possible to have multiple invocations of the thrift compiler, varying the param in order to generate source for multiple languages.
Could maven-thrift-plugin use libthrift instead of the thrift executable?
Enviroment:
openjdk version "1.8.0"
OpenJDK Runtime Environment (build 1.8.0-b132)
OpenJDK Server VM (build 25.0-b70, mixed mode)
Apache Maven 3.2.1
Maven home: /usr/share/maven
Java version: 1.8.0-b132, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.0/jre
Default locale: it_IT, platform encoding: UTF-8
OS name: "linux", version: "3.13.7-100.fc19.i686", arch: "i386", family: "unix"
[ERROR] /rpmbuild/BUILD/maven-thrift-plugin-thrift-maven-plugin-0.1.12/src/main/java/org/apache/thrift/maven/ThriftTestCompileMojo.java:[54,22] method addTestResource in interface org.apache.maven.project.MavenProjectHelper cannot be applied to given types;
required: org.apache.maven.project.MavenProject,java.lang.String,java.util.List<java.lang.String>,java.util.List<java.lang.String>
found: org.apache.maven.project.MavenProject,java.lang.String,com.google.common.collect.ImmutableList<java.lang.String>,com.google.common.collect.ImmutableList<java.lang.Object>
reason: actual argument com.google.common.collect.ImmutableList<java.lang.Object> cannot be converted to java.util.List<java.lang.String> by method invocation conversion
[ERROR] /rpmbuild/BUILD/maven-thrift-plugin-thrift-maven-plugin-0.1.12/src/main/java/org/apache/thrift/maven/ThriftCompileMojo.java:[79,22] method addResource in interface org.apache.maven.project.MavenProjectHelper cannot be applied to given types;
required: org.apache.maven.project.MavenProject,java.lang.String,java.util.List<java.lang.String>,java.util.List<java.lang.String>
found: org.apache.maven.project.MavenProject,java.lang.String,com.google.common.collect.ImmutableList<java.lang.String>,com.google.common.collect.ImmutableList<java.lang.Object>
reason: actual argument com.google.common.collect.ImmutableList<java.lang.Object> cannot be converted to java.util.List<java.lang.String> by method invocation conversion
any ideas?
thanks in advance
regards
Build maven project via maven-thrift-plugin, the pom as below. The java class generated by thrift has hashcode
method, which is using org.apache.commons.lang3.builder.HashCodeBuilder.
But when I generate java code by thrift command in terminal, the hashcode
method will not be using HashCodeBuilder
.
Using HashCodeBuilder
need to add a common-lang3 dependency, and the package jar will be different with the others.
What can I do to avoid HashCodeBuilder
?
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.thrift.tools</groupId>
<artifactId>maven-thrift-plugin</artifactId>
<version>0.1.11</version>
<configuration>
<thriftExecutable>thrift</thriftExecutable>
</configuration>
<executions>
<execution>
<id>thrift-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>thrift-test-sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Not available LICENSE file in source directory structure
Please. Added license and copyright notice.
the fedora pakaging guideline is very strictly precise about this problem
https://fedoraproject.org/wiki/Packaging:LicensingGuidelines?rd=Packaging/LicensingGuidelines#License_Text
thanks
regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.