YUBI LEE created HADOOP-18398:
---------------------------------

             Summary: Prevent AvroRecord*.class from being included non-test jar
                 Key: HADOOP-18398
                 URL: https://issues.apache.org/jira/browse/HADOOP-18398
             Project: Hadoop Common
          Issue Type: Bug
          Components: common
    Affects Versions: 3.3.3, 3.3.4
            Reporter: YUBI LEE


bq. 
{code}
[WARNING] Rule 1: org.apache.maven.plugins.enforcer.BanDuplicateClasses failed 
with message:
Duplicate classes found:

Found in:
org.apache.hadoop:hadoop-client-minicluster:jar:3.3.4:compile
org.apache.hadoop:hadoop-client-api:jar:3.3.4:compile
Duplicate classes:
org/apache/hadoop/io/serializer/avro/AvroRecord.class
org/apache/hadoop/io/serializer/avro/AvroRecord$Builder.class
org/apache/hadoop/io/serializer/avro/AvroRecord$1.class

[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M1:enforce 
(enforce-banned-dependencies) on project hadoop-client-check-test-invariants: 
Some Enforcer rules have failed. Look above for specific messages explaining 
why the rule failed. -> [Help 1] 
{code}


When building Hadoop, AvroRecord*.class are included in hadoop-client-api jar 
and I think it is wrong.
It is caused by "protobuf-maven-plugin" as a side effect.

https://github.com/apache/hadoop/blob/rel/release-3.3.4/hadoop-common-project/hadoop-common/pom.xml#L1118


{code:xml}
              <execution>
                <id>src-test-compile-protoc-legacy</id>
                <phase>generate-test-sources</phase>
                <goals>
                  <goal>compile</goal>
                </goals>
                <configuration>
                  <skip>false</skip>
                  <!--Generating with old protobuf version for backward 
compatibility-->
                  <protocArtifact>
                    
com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}
                  </protocArtifact>
                  
<includeDependenciesInDescriptorSet>false</includeDependenciesInDescriptorSet>
                  <protoSourceRoot>${basedir}/src/test/proto</protoSourceRoot>
                  
<outputDirectory>${project.build.directory}/generated-test-sources/java</outputDirectory>
                  <clearOutputDirectory>false</clearOutputDirectory>
                  <includes>
                    <include>test_legacy.proto</include>
                    <include>test_rpc_service_legacy.proto</include>
                  </includes>
                </configuration>
              </execution>
{code}

"src-test-compile-protoc-legacy" 's goal is written "compile" wrongly. It makes 
outputDirectory (${project.build.directory}/generated-test-sources/java) to be 
added to "compileSourceRoots" of maven-compiler-plugin.
"src-test-compile-protoc-legacy" 's goal should be "test-compile".




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: common-dev-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-dev-h...@hadoop.apache.org

Reply via email to