protobuf

生成

IDEA with Maven

http://www.cnblogs.com/kaituorensheng/p/9022591.html

POM.xml

  1. <project xmlns="http://maven.apache.org/POM/4.0.0"
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <groupId>com.haima.sage.bigdata</groupId>
  6. <artifactId>bigdata-protobuf</artifactId>
  7. <version>1.0.1</version>
  8. <packaging>jar</packaging>
  9. <name>bigdata-protobuf</name>
  10. <url>http://www.myorganization.org</url>
  11. <properties>
  12. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  13. <java.version>1.8</java.version>
  14. <scala.binary.version>2.11</scala.binary.version>
  15. <scala.version>2.11.12</scala.version>
  16. <log4j2.version>2.11.1</log4j2.version>
  17. <protobuf.input.directory>${project.basedir}/src/main/proto</protobuf.input.directory>
  18. <protobuf.output.directory>src/main/gen-java</protobuf.output.directory>
  19. <protobuf.protoc.path>${settings.localRepository}/protoc</protobuf.protoc.path>
  20. <protobuf.version>2.6.1</protobuf.version>
  21. <jackson.version>2.9.6</jackson.version>
  22. <log4j2.version>2.11.1</log4j2.version>
  23. </properties>
  24. <dependencies>
  25. <!-- config -->
  26. <dependency>
  27. <groupId>com.typesafe</groupId>
  28. <artifactId>config</artifactId>
  29. <version>1.3.2</version>
  30. </dependency>
  31. <!-- scala -->
  32. <dependency>
  33. <groupId>org.scala-lang</groupId>
  34. <artifactId>scala-library</artifactId>
  35. <version>${scala.version}</version>
  36. </dependency>
  37. <dependency>
  38. <groupId>org.scala-lang</groupId>
  39. <artifactId>scala-reflect</artifactId>
  40. <version>${scala.version}</version>
  41. </dependency>
  42. <dependency>
  43. <groupId>org.scala-lang</groupId>
  44. <artifactId>scala-compiler</artifactId>
  45. <version>${scala.version}</version>
  46. <exclusions>
  47. <exclusion>
  48. <artifactId>scala-parser-combinators_2.11</artifactId>
  49. <groupId>org.scala-lang.modules</groupId>
  50. </exclusion>
  51. <exclusion>
  52. <artifactId>scala-library</artifactId>
  53. <groupId>org.scala-lang</groupId>
  54. </exclusion>
  55. </exclusions>
  56. </dependency>
  57. <dependency>
  58. <groupId>org.scala-lang.modules</groupId>
  59. <artifactId>scala-parser-combinators_2.11</artifactId>
  60. <version>1.1.1</version>
  61. </dependency>
  62. <dependency>
  63. <groupId>org.scalatest</groupId>
  64. <artifactId>scalatest_${scala.binary.version}</artifactId>
  65. <version>3.0.5</version>
  66. <scope>test</scope>
  67. <exclusions>
  68. <exclusion>
  69. <artifactId>scala-xml_2.11</artifactId>
  70. <groupId>org.scala-lang.modules</groupId>
  71. </exclusion>
  72. </exclusions>
  73. </dependency>
  74. <!-- log4j2 -->
  75. <dependency>
  76. <groupId>org.apache.logging.log4j</groupId>
  77. <artifactId>log4j-1.2-api</artifactId>
  78. <version>${log4j2.version}</version>
  79. </dependency>
  80. <dependency>
  81. <groupId>org.apache.logging.log4j</groupId>
  82. <artifactId>log4j-jcl</artifactId>
  83. <version>${log4j2.version}</version>
  84. <exclusions>
  85. <exclusion>
  86. <artifactId>commons-logging</artifactId>
  87. <groupId>commons-logging</groupId>
  88. </exclusion>
  89. </exclusions>
  90. </dependency>
  91. <dependency>
  92. <groupId>org.apache.logging.log4j</groupId>
  93. <artifactId>log4j-slf4j-impl</artifactId>
  94. <version>${log4j2.version}</version>
  95. </dependency>
  96. <dependency>
  97. <groupId>org.apache.logging.log4j</groupId>
  98. <artifactId>log4j-jul</artifactId>
  99. <version>${log4j2.version}</version>
  100. </dependency>
  101. <dependency>
  102. <groupId>org.apache.logging.log4j</groupId>
  103. <artifactId>log4j-api-scala_${scala.binary.version}</artifactId>
  104. <version>11.0</version>
  105. <exclusions>
  106. <exclusion>
  107. <artifactId>log4j-api</artifactId>
  108. <groupId>org.apache.logging.log4j</groupId>
  109. </exclusion>
  110. <exclusion>
  111. <artifactId>scala-library</artifactId>
  112. <groupId>org.scala-lang</groupId>
  113. </exclusion>
  114. <exclusion>
  115. <artifactId>scala-reflect</artifactId>
  116. <groupId>org.scala-lang</groupId>
  117. </exclusion>
  118. </exclusions>
  119. </dependency>
  120. <dependency>
  121. <groupId>org.apache.logging.log4j</groupId>
  122. <artifactId>log4j-api</artifactId>
  123. <version>${log4j2.version}</version>
  124. </dependency>
  125. <dependency>
  126. <groupId>org.apache.logging.log4j</groupId>
  127. <artifactId>log4j-core</artifactId>
  128. <version>${log4j2.version}</version>
  129. </dependency>
  130. <dependency>
  131. <groupId>com.google.protobuf</groupId>
  132. <artifactId>protobuf-java</artifactId>
  133. <version>${protobuf.version}</version>
  134. </dependency>
  135. <!-- kafka -->
  136. <dependency>
  137. <groupId>org.apache.kafka</groupId>
  138. <artifactId>kafka-clients</artifactId>
  139. <version>0.11.0.2</version>
  140. <exclusions>
  141. <exclusion>
  142. <artifactId>slf4j-api</artifactId>
  143. <groupId>org.slf4j</groupId>
  144. </exclusion>
  145. <exclusion>
  146. <artifactId>snappy-java</artifactId>
  147. <groupId>org.xerial.snappy</groupId>
  148. </exclusion>
  149. </exclusions>
  150. </dependency>
  151. <!-- json-->
  152. <dependency>
  153. <groupId>com.fasterxml.jackson.dataformat</groupId>
  154. <artifactId>jackson-dataformat-xml</artifactId>
  155. <version>${jackson.version}</version>
  156. <exclusions>
  157. <exclusion>
  158. <artifactId>jackson-annotations</artifactId>
  159. <groupId>com.fasterxml.jackson.core</groupId>
  160. </exclusion>
  161. <exclusion>
  162. <artifactId>jackson-core</artifactId>
  163. <groupId>com.fasterxml.jackson.core</groupId>
  164. </exclusion>
  165. <exclusion>
  166. <artifactId>jackson-databind</artifactId>
  167. <groupId>com.fasterxml.jackson.core</groupId>
  168. </exclusion>
  169. </exclusions>
  170. </dependency>
  171. <dependency>
  172. <groupId>com.fasterxml.jackson.dataformat</groupId>
  173. <artifactId>jackson-dataformat-protobuf</artifactId>
  174. <version>${jackson.version}</version>
  175. <exclusions>
  176. <exclusion>
  177. <artifactId>jackson-annotations</artifactId>
  178. <groupId>com.fasterxml.jackson.core</groupId>
  179. </exclusion>
  180. <exclusion>
  181. <artifactId>jackson-core</artifactId>
  182. <groupId>com.fasterxml.jackson.core</groupId>
  183. </exclusion>
  184. <exclusion>
  185. <artifactId>jackson-databind</artifactId>
  186. <groupId>com.fasterxml.jackson.core</groupId>
  187. </exclusion>
  188. </exclusions>
  189. </dependency>
  190. <dependency>
  191. <groupId>com.fasterxml.jackson.dataformat</groupId>
  192. <artifactId>jackson-dataformat-avro</artifactId>
  193. <version>${jackson.version}</version>
  194. <exclusions>
  195. <exclusion>
  196. <artifactId>jackson-annotations</artifactId>
  197. <groupId>com.fasterxml.jackson.core</groupId>
  198. </exclusion>
  199. <exclusion>
  200. <artifactId>jackson-core</artifactId>
  201. <groupId>com.fasterxml.jackson.core</groupId>
  202. </exclusion>
  203. <exclusion>
  204. <artifactId>jackson-databind</artifactId>
  205. <groupId>com.fasterxml.jackson.core</groupId>
  206. </exclusion>
  207. <exclusion>
  208. <artifactId>paranamer</artifactId>
  209. <groupId>com.thoughtworks.paranamer</groupId>
  210. </exclusion>
  211. <exclusion>
  212. <artifactId>slf4j-api</artifactId>
  213. <groupId>org.slf4j</groupId>
  214. </exclusion>
  215. <exclusion>
  216. <artifactId>snappy-java</artifactId>
  217. <groupId>org.xerial.snappy</groupId>
  218. </exclusion>
  219. <exclusion>
  220. <artifactId>avro</artifactId>
  221. <groupId>org.apache.avro</groupId>
  222. </exclusion>
  223. </exclusions>
  224. </dependency>
  225. <dependency>
  226. <groupId>com.fasterxml.jackson.module</groupId>
  227. <artifactId>jackson-module-scala_${scala.binary.version}</artifactId>
  228. <version>${jackson.version}</version>
  229. <scope>compile</scope>
  230. <exclusions>
  231. <exclusion>
  232. <groupId>com.fasterxml.jackson.core</groupId>
  233. <artifactId>jackson-databind</artifactId>
  234. </exclusion>
  235. <exclusion>
  236. <artifactId>scala-reflect</artifactId>
  237. <groupId>org.scala-lang</groupId>
  238. </exclusion>
  239. <exclusion>
  240. <artifactId>scala-library</artifactId>
  241. <groupId>org.scala-lang</groupId>
  242. </exclusion>
  243. </exclusions>
  244. </dependency>
  245. <dependency>
  246. <groupId>com.fasterxml.jackson.core</groupId>
  247. <artifactId>jackson-databind</artifactId>
  248. <version>${jackson.version}</version>
  249. <exclusions>
  250. <exclusion>
  251. <artifactId>jackson-annotations</artifactId>
  252. <groupId>com.fasterxml.jackson.core</groupId>
  253. </exclusion>
  254. </exclusions>
  255. </dependency>
  256. </dependencies>
  257. <build>
  258. <extensions>
  259. <extension>
  260. <groupId>kr.motd.maven</groupId>
  261. <artifactId>os-maven-plugin</artifactId>
  262. <version>1.4.1.Final</version>
  263. </extension>
  264. </extensions>
  265. <plugins>
  266. <plugin>
  267. <groupId>org.xolstice.maven.plugins</groupId>
  268. <artifactId>protobuf-maven-plugin</artifactId>
  269. <version>0.5.0</version>
  270. <configuration>
  271. <!--默认的proto文件路径-->
  272. <protoSourceRoot>${basedir}/src/main/proto</protoSourceRoot>
  273. <protocArtifact>
  274. com.google.protobuf:protoc:2.6.1:exe:${os.detected.classifier}
  275. </protocArtifact>
  276. <pluginId>grpc-java</pluginId>
  277. <outputDirectory>${project.build.sourceDirectory}</outputDirectory>
  278. </configuration>
  279. <executions>
  280. <execution>
  281. <goals>
  282. <goal>compile</goal>
  283. <goal>compile-custom</goal>
  284. </goals>
  285. </execution>
  286. </executions>
  287. </plugin>
  288. <!-- Java Compiler -->
  289. <plugin>
  290. <groupId>org.apache.maven.plugins</groupId>
  291. <artifactId>maven-compiler-plugin</artifactId>
  292. <version>3.8.0</version>
  293. <configuration>
  294. <source>${java.version}</source>
  295. <target>${java.version}</target>
  296. </configuration>
  297. </plugin>
  298. <!-- Scala Compiler -->
  299. <plugin>
  300. <groupId>net.alchim31.maven</groupId>
  301. <artifactId>scala-maven-plugin</artifactId>
  302. <version>3.2.1</version>
  303. <executions>
  304. <execution>
  305. <goals>
  306. <goal>compile</goal>
  307. <goal>testCompile</goal>
  308. </goals>
  309. </execution>
  310. </executions>
  311. </plugin>
  312. <!-- Eclipse Scala Integration -->
  313. <plugin>
  314. <groupId>org.apache.maven.plugins</groupId>
  315. <artifactId>maven-eclipse-plugin</artifactId>
  316. <version>2.10</version>
  317. <configuration>
  318. <downloadSources>true</downloadSources>
  319. <projectnatures>
  320. <projectnature>org.scala-ide.sdt.core.scalanature</projectnature>
  321. <projectnature>org.eclipse.jdt.core.javanature</projectnature>
  322. </projectnatures>
  323. <buildcommands>
  324. <buildcommand>org.scala-ide.sdt.core.scalabuilder</buildcommand>
  325. </buildcommands>
  326. <classpathContainers>
  327. <classpathContainer>org.scala-ide.sdt.launching.SCALA_CONTAINER</classpathContainer>
  328. <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
  329. </classpathContainers>
  330. <excludes>
  331. <exclude>org.scala-lang:scala-library</exclude>
  332. <exclude>org.scala-lang:scala-compiler</exclude>
  333. </excludes>
  334. <sourceIncludes>
  335. <sourceInclude>**/*.scala</sourceInclude>
  336. <sourceInclude>**/*.java</sourceInclude>
  337. </sourceIncludes>
  338. </configuration>
  339. </plugin>
  340. <plugin>
  341. <groupId>org.codehaus.mojo</groupId>
  342. <artifactId>build-helper-maven-plugin</artifactId>
  343. <version>1.7</version>
  344. <executions>
  345. <!-- Add src/main/scala to eclipse build path -->
  346. <execution>
  347. <id>add-source</id>
  348. <phase>generate-sources</phase>
  349. <goals>
  350. <goal>add-source</goal>
  351. </goals>
  352. <configuration>
  353. <sources>
  354. <source>src/main/scala</source>
  355. </sources>
  356. </configuration>
  357. </execution>
  358. <!-- Add src/test/scala to eclipse build path -->
  359. <execution>
  360. <id>add-test-source</id>
  361. <phase>generate-test-sources</phase>
  362. <goals>
  363. <goal>add-test-source</goal>
  364. </goals>
  365. <configuration>
  366. <sources>
  367. <source>src/test/scala</source>
  368. </sources>
  369. </configuration>
  370. </execution>
  371. </executions>
  372. </plugin>
  373. </plugins>
  374. </build>
  375. <profiles>
  376. <profile>
  377. <id>add-dependencies-for-IDEA</id>
  378. <activation>
  379. <property>
  380. <name>idea.version</name>
  381. </property>
  382. </activation>
  383. <dependencies>
  384. <dependency>
  385. <groupId>org.scala-lang</groupId>
  386. <artifactId>scala-library</artifactId>
  387. <version>${scala.version}</version>
  388. <scope>compile</scope>
  389. </dependency>
  390. <dependency>
  391. <groupId>org.scalatest</groupId>
  392. <artifactId>scalatest_${scala.binary.version}</artifactId>
  393. <version>3.0.5</version>
  394. <scope>test</scope>
  395. <exclusions>
  396. <exclusion>
  397. <artifactId>scala-xml_2.11</artifactId>
  398. <groupId>org.scala-lang.modules</groupId>
  399. </exclusion>
  400. <exclusion>
  401. <artifactId>scala-library</artifactId>
  402. <groupId>org.scala-lang</groupId>
  403. </exclusion>
  404. </exclusions>
  405. </dependency>
  406. </dependencies>
  407. </profile>
  408. </profiles>
  409. </project>
文档更新时间: 2019-06-21 20:02