pom.xml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License. See accompanying LICENSE file.
  12. -->
  13. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  14. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  15. <modelVersion>4.0.0</modelVersion>
  16. <parent>
  17. <groupId>org.apache.hadoop</groupId>
  18. <artifactId>hadoop-project</artifactId>
  19. <version>3.5.0-SNAPSHOT</version>
  20. <relativePath>../../hadoop-project</relativePath>
  21. </parent>
  22. <artifactId>hadoop-client-check-invariants</artifactId>
  23. <version>3.5.0-SNAPSHOT</version>
  24. <packaging>pom</packaging>
  25. <description>
  26. Enforces our invariants for the api and runtime client modules.
  27. E.g. that modules have a specific set of transitive dependencies
  28. and shaded artifacts only contain classes that are in particular
  29. packages. Does the enforcement through the maven-enforcer-plugin
  30. and an integration test.
  31. </description>
  32. <name>Apache Hadoop Client Packaging Invariants</name>
  33. <properties>
  34. </properties>
  35. <dependencies>
  36. <dependency>
  37. <groupId>org.apache.hadoop</groupId>
  38. <artifactId>hadoop-client-api</artifactId>
  39. </dependency>
  40. <dependency>
  41. <groupId>org.apache.hadoop</groupId>
  42. <artifactId>hadoop-client-runtime</artifactId>
  43. </dependency>
  44. </dependencies>
  45. <build>
  46. <plugins>
  47. <plugin>
  48. <groupId>org.apache.maven.plugins</groupId>
  49. <artifactId>maven-enforcer-plugin</artifactId>
  50. <dependencies>
  51. <dependency>
  52. <groupId>org.codehaus.mojo</groupId>
  53. <artifactId>extra-enforcer-rules</artifactId>
  54. <version>1.5.1</version>
  55. </dependency>
  56. </dependencies>
  57. <executions>
  58. <execution>
  59. <id>enforce-banned-dependencies</id>
  60. <goals>
  61. <goal>enforce</goal>
  62. </goals>
  63. <configuration>
  64. <rules>
  65. <banTransitiveDependencies>
  66. <!--
  67. <message>
  68. Our client-facing artifacts are not supposed to have additional dependencies
  69. and one or more of them do. The output from the enforcer plugin should give
  70. specifics.
  71. </message>
  72. -->
  73. <excludes>
  74. <!-- annotations is provided, and both artifacts exclude the tools transitive,
  75. but enforcer still sees it.
  76. -->
  77. <exclude>org.apache.hadoop:hadoop-annotations</exclude>
  78. <!-- Leave slf4j unshaded so downstream users can configure logging. -->
  79. <exclude>org.slf4j:slf4j-api</exclude>
  80. <!-- Leave commons-logging unshaded so downstream users can configure logging. -->
  81. <exclude>commons-logging:commons-logging</exclude>
  82. <!-- Leave log4j unshaded so downstream users can configure logging. -->
  83. <exclude>log4j:log4j</exclude>
  84. <!-- Leave javax annotations we need exposed -->
  85. <exclude>com.google.code.findbugs:jsr305</exclude>
  86. <!-- Leave bouncycastle unshaded because it's signed with a special Oracle certificate so it can be a custom JCE security provider -->
  87. <exclude>org.bouncycastle:*</exclude>
  88. <!-- Leave snappy that includes native methods which cannot be relocated. -->
  89. <exclude>org.xerial.snappy:*</exclude>
  90. </excludes>
  91. </banTransitiveDependencies>
  92. <banDuplicateClasses>
  93. <findAllDuplicates>true</findAllDuplicates>
  94. <dependencies>
  95. <dependency>
  96. <groupId>org.apache.hadoop</groupId>
  97. <artifactId>hadoop-annotations</artifactId>
  98. <ignoreClasses>
  99. <ignoreClass>*</ignoreClass>
  100. </ignoreClasses>
  101. </dependency>
  102. </dependencies>
  103. </banDuplicateClasses>
  104. </rules>
  105. <!-- TODO we need a rule for "the constants in this set of classes haven't been shaded / don't have this prefix"
  106. Manually checking the set of Keys that look like packages we relocate:
  107. cat `find . \( -name '*Keys.java' -o -name '*KeysPublic.java' \) -a -path '*/src/main/*'` | grep -E "\"(io\.|org\.|com\.|net\.)" | grep -v "^package" | grep -v "^import" | grep -v "\"org.apache.hadoop"
  108. Manually check the set of shaded artifacts to see if the Keys constants have been relocated:
  109. for clazz in `find . \( -name '*Keys.java' -o -name '*KeysPublic.java' \) -a -path '*/src/main/*'`; do
  110. clazz=${clazz#*src/main/java/}
  111. clazz="${clazz%.java}"
  112. javap -cp hadoop-client-modules/hadoop-client-api/target/hadoop-client-api-3.0.0-alpha2-SNAPSHOT.jar:hadoop-client-modules/hadoop-client-runtime/target/hadoop-client-runtime-3.0.0-alpha2-SNAPSHOT.jar:hadoop-client-modules/hadoop-client-minicluster/target/hadoop-client-minicluster-3.0.0-alpha2-SNAPSHOT.jar \
  113. -constants "${clazz//\//.}" | grep "org.apache.hadoop.shaded"
  114. done
  115. -->
  116. </configuration>
  117. </execution>
  118. </executions>
  119. </plugin>
  120. <plugin>
  121. <groupId>org.apache.maven.plugins</groupId>
  122. <artifactId>maven-resources-plugin</artifactId>
  123. <executions>
  124. <execution>
  125. <id>test-resources</id>
  126. <phase>pre-integration-test</phase>
  127. <goals>
  128. <goal>testResources</goal>
  129. </goals>
  130. </execution>
  131. </executions>
  132. </plugin>
  133. <plugin>
  134. <groupId>org.apache.maven.plugins</groupId>
  135. <artifactId>maven-dependency-plugin</artifactId>
  136. <executions>
  137. <!-- create a maven pom property that has all of our dependencies.
  138. below in the integration-test phase we'll pass this list
  139. of paths to our jar checker script.
  140. -->
  141. <execution>
  142. <id>put-client-artifacts-in-a-property</id>
  143. <phase>pre-integration-test</phase>
  144. <goals>
  145. <goal>build-classpath</goal>
  146. </goals>
  147. <configuration>
  148. <excludeTransitive>true</excludeTransitive>
  149. <pathSeparator>;</pathSeparator>
  150. <outputProperty>hadoop-client-artifacts</outputProperty>
  151. </configuration>
  152. </execution>
  153. </executions>
  154. </plugin>
  155. <!--
  156. Check that we actually relocated everything we included.
  157. It's critical that we don't ship third party dependencies that haven't
  158. been relocated under our pacakge space, since this will lead to
  159. difficult to debug classpath errors for downstream. Unfortunately, that
  160. means inspecting all the jars.
  161. -->
  162. <plugin>
  163. <groupId>org.codehaus.mojo</groupId>
  164. <artifactId>exec-maven-plugin</artifactId>
  165. <executions>
  166. <execution>
  167. <id>check-jar-contents</id>
  168. <phase>integration-test</phase>
  169. <goals>
  170. <goal>exec</goal>
  171. </goals>
  172. <configuration>
  173. <executable>${shell-executable}</executable>
  174. <workingDirectory>${project.build.testOutputDirectory}</workingDirectory>
  175. <arguments>
  176. <argument>ensure-jars-have-correct-contents.sh</argument>
  177. <argument>${hadoop-client-artifacts}</argument>
  178. </arguments>
  179. </configuration>
  180. </execution>
  181. </executions>
  182. </plugin>
  183. </plugins>
  184. </build>
  185. </project>