Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
maven-thrift-plugin
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
maven-thrift-plugin
Commits
4c467f9e
Commit
4c467f9e
authored
Sep 24, 2010
by
Cees de Groot
Committed by
David Trott
Sep 28, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduced "generator" configuration option to be able to manipulate the thrift --gen option
parent
5232afcf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
4 deletions
+40
-4
src/main/java/org/apache/thrift/maven/AbstractThriftMojo.java
...main/java/org/apache/thrift/maven/AbstractThriftMojo.java
+11
-0
src/main/java/org/apache/thrift/maven/Thrift.java
src/main/java/org/apache/thrift/maven/Thrift.java
+20
-3
src/test/java/org/apache/thrift/maven/TestThrift.java
src/test/java/org/apache/thrift/maven/TestThrift.java
+9
-1
No files found.
src/main/java/org/apache/thrift/maven/AbstractThriftMojo.java
View file @
4c467f9e
...
...
@@ -75,6 +75,15 @@ abstract class AbstractThriftMojo extends AbstractMojo {
*/
private
String
thriftExecutable
;
/**
* This string is passed to the {@code --gen} option of the {@code thrift} parameter. By default
* it will generate Java output. The main reason for this option is to be able to add options
* to the Java generator - if you generate something else, you're on your own.
*
* @parameter default-value="java"
*/
private
String
generator
;
/**
* @parameter
*/
...
...
@@ -140,6 +149,7 @@ abstract class AbstractThriftMojo extends AbstractMojo {
cleanDirectory
(
outputDirectory
);
Thrift
thrift
=
new
Thrift
.
Builder
(
thriftExecutable
,
outputDirectory
)
.
setGenerator
(
generator
)
.
addThriftPathElement
(
thriftSourceRoot
)
.
addThriftPathElements
(
derivedThriftPathElements
)
.
addThriftPathElements
(
asList
(
additionalThriftPathElements
))
...
...
@@ -171,6 +181,7 @@ abstract class AbstractThriftMojo extends AbstractMojo {
checkNotNull
(
project
,
"project"
);
checkNotNull
(
projectHelper
,
"projectHelper"
);
checkNotNull
(
thriftExecutable
,
"thriftExecutable"
);
checkNotNull
(
generator
,
"generator"
);
final
File
thriftSourceRoot
=
getThriftSourceRoot
();
checkNotNull
(
thriftSourceRoot
);
checkArgument
(!
thriftSourceRoot
.
isFile
(),
"thriftSourceRoot is a file, not a diretory"
);
...
...
src/main/java/org/apache/thrift/maven/Thrift.java
View file @
4c467f9e
...
...
@@ -33,6 +33,7 @@ final class Thrift {
final
static
String
GENERATED_JAVA
=
"gen-java"
;
private
final
String
executable
;
private
final
String
generator
;
private
final
ImmutableSet
<
File
>
thriftPathElements
;
private
final
ImmutableSet
<
File
>
thriftFiles
;
private
final
File
javaOutputDirectory
;
...
...
@@ -43,14 +44,16 @@ final class Thrift {
* Constructs a new instance. This should only be used by the {@link Builder}.
*
* @param executable The path to the {@code thrift} executable.
* @param generator The value for the {@code --gen} option.
* @param thriftPath The directories in which to search for imports.
* @param thriftFiles The thrift source files to compile.
* @param javaOutputDirectory The directory into which the java source files
* will be generated.
*/
private
Thrift
(
String
executable
,
ImmutableSet
<
File
>
thriftPath
,
private
Thrift
(
String
executable
,
String
generator
,
ImmutableSet
<
File
>
thriftPath
,
ImmutableSet
<
File
>
thriftFiles
,
File
javaOutputDirectory
)
{
this
.
executable
=
checkNotNull
(
executable
,
"executable"
);
this
.
generator
=
checkNotNull
(
generator
,
"generator"
);
this
.
thriftPathElements
=
checkNotNull
(
thriftPath
,
"thriftPath"
);
this
.
thriftFiles
=
checkNotNull
(
thriftFiles
,
"thriftFiles"
);
this
.
javaOutputDirectory
=
checkNotNull
(
javaOutputDirectory
,
"javaOutputDirectory"
);
...
...
@@ -101,7 +104,7 @@ final class Thrift {
command
.
add
(
"-o"
);
command
.
add
(
javaOutputDirectory
.
toString
());
command
.
add
(
"--gen"
);
command
.
add
(
"java"
);
command
.
add
(
generator
);
command
.
add
(
thriftFile
.
toString
());
return
ImmutableList
.
copyOf
(
command
);
}
...
...
@@ -151,6 +154,7 @@ final class Thrift {
private
final
File
javaOutputDirectory
;
private
Set
<
File
>
thriftPathElements
;
private
Set
<
File
>
thriftFiles
;
private
String
generator
;
/**
* Constructs a new builder. The two parameters are present as they are
...
...
@@ -191,6 +195,19 @@ final class Thrift {
return
this
;
}
/**
* Adds the option string for the Thrift executable's {@code --gen} parameter.
*
* @param generator
* @return The builder
* @throws NullPointerException If {@code generator} is {@code null}.
*/
public
Builder
setGenerator
(
String
generator
)
{
checkNotNull
(
generator
);
this
.
generator
=
generator
;
return
this
;
}
private
void
checkThriftFileIsInThriftPath
(
File
thriftFile
)
{
assert
thriftFile
.
isFile
();
checkState
(
checkThriftFileIsInThriftPathHelper
(
thriftFile
.
getParentFile
()));
...
...
@@ -250,7 +267,7 @@ final class Thrift {
*/
public
Thrift
build
()
{
checkState
(!
thriftFiles
.
isEmpty
());
return
new
Thrift
(
executable
,
ImmutableSet
.
copyOf
(
thriftPathElements
),
return
new
Thrift
(
executable
,
generator
,
ImmutableSet
.
copyOf
(
thriftPathElements
),
ImmutableSet
.
copyOf
(
thriftFiles
),
javaOutputDirectory
);
}
}
...
...
src/test/java/org/apache/thrift/maven/TestThrift.java
View file @
4c467f9e
...
...
@@ -36,7 +36,9 @@ public class TestThrift {
idlDir
=
new
File
(
testResourceDir
,
"idl"
);
genJavaDir
=
new
File
(
testRootDir
,
Thrift
.
GENERATED_JAVA
);
builder
=
new
Thrift
.
Builder
(
"thrift"
,
testRootDir
);
builder
.
addThriftPathElement
(
idlDir
);
builder
.
setGenerator
(
"java"
)
.
addThriftPathElement
(
idlDir
);
}
@Test
...
...
@@ -59,6 +61,12 @@ public class TestThrift {
new
File
(
testRootDir
,
"shared/SharedService.java"
).
exists
());
}
@Test
public
void
testThriftCompileWithGeneratorOption
()
throws
Exception
{
builder
.
setGenerator
(
"java:private-members,hashcode"
);
testThriftCompile
();
}
@Test
public
void
testThriftMultipleFileCompile
()
throws
Exception
{
final
File
sharedThrift
=
new
File
(
idlDir
,
"shared.thrift"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment