Skip to content

Commit

Permalink
switch compile proto to use protobuf plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mdavis95 committed Jun 28, 2017
1 parent b91eac6 commit ab5137f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 92 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}
}

defaultTasks 'compileProto', 'createDeploy'
defaultTasks 'createDeploy'

apply plugin: 'java'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,8 @@
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.index.TermsEnum.SeekStatus;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.BoostAttribute;
import org.apache.lucene.search.FieldDoc;
import org.apache.lucene.search.FuzzyTermsEnum;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MaxNonCompetitiveBoostAttribute;
import org.apache.lucene.search.MultiCollector;
import org.apache.lucene.search.*;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.SortField;
import org.apache.lucene.search.SortedNumericSelector;
import org.apache.lucene.search.SortedNumericSortField;
import org.apache.lucene.search.SortedSetSelector;
import org.apache.lucene.search.SortedSetSortField;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocsCollector;
import org.apache.lucene.search.TopFieldCollector;
import org.apache.lucene.search.TopScoreDocCollector;
import org.apache.lucene.search.highlight.Fragmenter;
import org.apache.lucene.search.highlight.QueryScorer;
import org.apache.lucene.search.highlight.SimpleHTMLFormatter;
Expand All @@ -72,36 +54,8 @@
import org.apache.lucene.util.NumericUtils;
import org.lumongo.LumongoConstants;
import org.lumongo.cluster.message.Lumongo;
import org.lumongo.cluster.message.Lumongo.AnalysisRequest;
import org.lumongo.cluster.message.Lumongo.AnalysisResult;
import org.lumongo.cluster.message.Lumongo.AnalyzerSettings;
import org.lumongo.cluster.message.Lumongo.CountRequest;
import org.lumongo.cluster.message.Lumongo.FacetAs;
import org.lumongo.cluster.message.Lumongo.FacetCount;
import org.lumongo.cluster.message.Lumongo.FacetGroup;
import org.lumongo.cluster.message.Lumongo.FacetRequest;
import org.lumongo.cluster.message.Lumongo.FetchType;
import org.lumongo.cluster.message.Lumongo.FieldConfig;
import org.lumongo.cluster.message.Lumongo.FieldSort;
import org.lumongo.cluster.message.Lumongo.*;
import org.lumongo.cluster.message.Lumongo.FieldSort.Direction;
import org.lumongo.cluster.message.Lumongo.FuzzyTerm;
import org.lumongo.cluster.message.Lumongo.GetFieldNamesResponse;
import org.lumongo.cluster.message.Lumongo.GetTermsRequest;
import org.lumongo.cluster.message.Lumongo.GetTermsResponse;
import org.lumongo.cluster.message.Lumongo.HighlightRequest;
import org.lumongo.cluster.message.Lumongo.HighlightResult;
import org.lumongo.cluster.message.Lumongo.IndexAs;
import org.lumongo.cluster.message.Lumongo.IndexSettings;
import org.lumongo.cluster.message.Lumongo.Metadata;
import org.lumongo.cluster.message.Lumongo.ProjectAs;
import org.lumongo.cluster.message.Lumongo.ResultDocument;
import org.lumongo.cluster.message.Lumongo.ScoredResult;
import org.lumongo.cluster.message.Lumongo.SegmentCountResponse;
import org.lumongo.cluster.message.Lumongo.SegmentResponse;
import org.lumongo.cluster.message.Lumongo.SortAs;
import org.lumongo.cluster.message.Lumongo.SortRequest;
import org.lumongo.cluster.message.Lumongo.SortValue;
import org.lumongo.cluster.message.Lumongo.SortValues;
import org.lumongo.server.config.IndexConfig;
import org.lumongo.server.config.IndexConfigUtil;
import org.lumongo.server.highlighter.LumongoHighlighter;
Expand Down
81 changes: 39 additions & 42 deletions lumongo-common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
plugins {
id "com.google.protobuf" version "0.8.1"
}

apply from: '../maven.gradle'

defaultTasks 'compileProto', 'build'
defaultTasks 'generateProto', 'build'

description 'Lumongo Common'

def grpcVersion = '1.4.0'

dependencies {

compile "io.grpc:grpc-netty:${grpcVersion}"
compile "io.grpc:grpc-protobuf:${grpcVersion}"
compile "io.grpc:grpc-stub:${grpcVersion}"

compile "org.mongodb:mongo-java-driver:$mongoJavaVersion"
compile 'com.google.guava:guava:18.0'
compile 'com.googlecode.protobuf-rpc-pro:protobuf-rpc-pro-duplex:3.3.4'
Expand All @@ -18,56 +29,42 @@ dependencies {
compile 'com.jcraft:jzlib:1.1.3'
}

protobuf {

sourceSets {
main { java { srcDir 'gen-src' } }
protoc {
artifact = 'com.google.protobuf:protoc:3.3.0'
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
}
}
generateProtoTasks {
all()*.plugins {
grpc {
// To generate deprecated interfaces and static bindService method,
// turn the enable_deprecated option to true below:
option 'enable_deprecated=false'
}
}
}
}


task compileProto {
doLast {
File outputDir = project.file("gen-src")
File protoDir = project.file("proto")

String os = System.getProperty("os.name").toLowerCase();
String protocCommand = "protoc";

println("OS: " + os);
if (os.contains("linux")) {
protocCommand = rootProject.file("util" + File.separator + "protoc").toString();
}
else {
println("Using protoc on path");
}

if (!outputDir.exists()) {
outputDir.mkdir();
}
// Inform IntelliJ projects about the generated code.
apply plugin: 'idea'

if (protoDir.isDirectory() && protoDir.exists()) {

String[] protos = protoDir.list()

for (String proto : protos) {
if (proto.endsWith(".proto")) {
String protoFull = protoDir.getAbsolutePath() + File.separator + proto
println("Compiling proto in <" + protoFull + "> to <" + outputDir.getAbsolutePath() + ">")
exec {
setStandardOutput(System.out)
executable protocCommand
args '--proto_path=' + protoDir.getAbsolutePath(), '--java_out=' + outputDir.getAbsolutePath(), protoFull
}
}
}
}
else {
println("Error: " + protoDir.getAbsolutePath() + " does not exist or is not a directory")
}
idea {
module {
// Not using generatedSourceDirs because of
// https://discuss.gradle.org/t/support-for-intellij-2016/15294/8
sourceDirs += file("${projectDir}/build/generated/source/proto/main/java");
sourceDirs += file("${projectDir}/build/generated/source/proto/main/grpc");
}
}

compileJava.dependsOn compileProto
eclipseProject.dependsOn compileProto




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

import org.bson.Document;
import org.lumongo.cluster.message.Lumongo;
import org.lumongo.util.LumongoUtil;

import java.util.ArrayList;
import java.util.List;
Expand Down
File renamed without changes.
Binary file removed util/protoc
Binary file not shown.

0 comments on commit ab5137f

Please sign in to comment.