google / closure-templates

A client- and server-side templating system that helps you dynamically build reusable HTML and UI elements
Apache License 2.0
640 stars 194 forks source link

running mvn compile twice without a clean causing duplicate classes #46

Open jmhodges opened 9 years ago

jmhodges commented 9 years ago

The current build breaks when mvn compile is run twice with no mvn clean between. I've not been able to figure out what is going wrong. I did find a hack that works where you add -proc:none to the javac compiler arguments and also add an old maven-processor-plugin to the pom, but that seems.. well, silly.

Here's the errors:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project soy: Compilation failure: Compilation failure:
[ERROR] /Users/jmhodges/src/github.com/google/closure-templates/target/generated-sources/annotations/com/google/template/soy/shared/AutoValue_SoyAstCache_VersionedFile.java:[9,7] duplicate class: com.google.template.soy.shared.AutoValue_SoyAstCache_VersionedFile
[ERROR] /Users/jmhodges/src/github.com/google/closure-templates/target/generated-sources/annotations/com/google/template/soy/jbcsrc/AutoValue_ControlFlow_IfBlock.java:[7,7] duplicate class: com.google.template.soy.jbcsrc.AutoValue_ControlFlow_IfBlock
[ERROR] /Users/jmhodges/src/github.com/google/closure-templates/target/generated-sources/annotations/com/google/template/soy/jbcsrc/AutoValue_FieldRef.java:[8,7] duplicate class: com.google.template.soy.jbcsrc.AutoValue_FieldRef
[ERROR] /Users/jmhodges/src/github.com/google/closure-templates/target/generated-sources/annotations/com/google/template/soy/jssrc/internal/AutoValue_HelperFunctions_FieldAccessStrategy.java:[7,7] duplicate class: com.google.template.soy.jssrc.internal.AutoValue_HelperFunctions_FieldAccessStrategy
[ERROR] /Users/jmhodges/src/github.com/google/closure-templates/target/generated-sources/annotations/com/google/template/soy/soytree/AutoValue_ForNode_RangeArgs.java:[9,7] duplicate class: com.google.template.soy.soytree.AutoValue_ForNode_RangeArgs
[ERROR] /Users/jmhodges/src/github.com/google/closure-templates/target/generated-sources/annotations/com/google/template/soy/soytree/AutoValue_TemplateDelegateNode_DelTemplateKey.java:[7,7] duplicate class: com.google.template.soy.soytree.AutoValue_TemplateDelegateNode_DelTemplateKey
[ERROR] /Users/jmhodges/src/github.com/google/closure-templates/target/generated-sources/annotations/com/google/template/soy/soytree/AutoValue_CallNode_DataAttribute.java:[8,7] duplicate class: com.google.template.soy.soytree.AutoValue_CallNode_DataAttribute
[ERROR] /Users/jmhodges/src/github.com/google/closure-templates/target/generated-sources/annotations/com/google/template/soy/jbcsrc/AutoValue_ConstructorRef.java:[10,7] duplicate class: com.google.template.soy.jbcsrc.AutoValue_ConstructorRef
[ERROR] /Users/jmhodges/src/github.com/google/closure-templates/target/generated-sources/annotations/com/google/template/soy/jbcsrc/AutoValue_MethodRef.java:[10,7] duplicate class: com.google.template.soy.jbcsrc.AutoValue_MethodRef
[ERROR] /Users/jmhodges/src/github.com/google/closure-templates/target/generated-sources/annotations/com/google/template/soy/msgs/restricted/AutoValue_SoyMsgPart_Case.java:[8,7] duplicate class: com.google.template.soy.msgs.restricted.AutoValue_SoyMsgPart_Case
[ERROR] /Users/jmhodges/src/github.com/google/closure-templates/target/generated-sources/annotations/com/google/template/soy/conformance/AutoValue_ConformanceInput.java:[10,7] duplicate class: com.google.template.soy.conformance.AutoValue_ConformanceInput
[ERROR] /Users/jmhodges/src/github.com/google/closure-templates/target/generated-sources/annotations/com/google/template/soy/jbcsrc/AutoValue_TypeInfo.java:[8,7] duplicate class: com.google.template.soy.jbcsrc.AutoValue_TypeInfo
[ERROR] /Users/jmhodges/src/github.com/google/closure-templates/target/generated-sources/annotations/com/google/template/soy/jbcsrc/AutoValue_ClassData.java:[8,7] duplicate class: com.google.template.soy.jbcsrc.AutoValue_ClassData
[ERROR] /Users/jmhodges/src/github.com/google/closure-templates/target/generated-sources/annotations/com/google/template/soy/jbcsrc/AutoValue_CompiledTemplateMetadata.java:[8,7] duplicate class: com.google.template.soy.jbcsrc.AutoValue_CompiledTemplateMetadata
[ERROR] /Users/jmhodges/src/github.com/google/closure-templates/target/generated-sources/annotations/com/google/template/soy/jbcsrc/AutoValue_DetachState_ReattachState.java:[8,7] duplicate class: com.google.template.soy.jbcsrc.AutoValue_DetachState_ReattachState
[ERROR] /Users/jmhodges/src/github.com/google/closure-templates/target/generated-sources/annotations/com/google/template/soy/jbcsrc/AutoValue_VariableSet_VarKey.java:[7,7] duplicate class: com.google.template.soy.jbcsrc.AutoValue_VariableSet_VarKey
[ERROR] /Users/jmhodges/src/github.com/google/closure-templates/target/generated-sources/annotations/com/google/template/soy/jbcsrc/AutoValue_VariableSet_SaveRestoreState.java:[7,7] duplicate class: com.google.template.soy.jbcsrc.AutoValue_VariableSet_SaveRestoreState
[ERROR] /Users/jmhodges/src/github.com/google/closure-templates/target/generated-sources/annotations/com/google/template/soy/jbcsrc/AutoValue_SoyNodeCompiler_CompiledRangeArgs.java:[8,7] duplicate class: com.google.template.soy.jbcsrc.AutoValue_SoyNodeCompiler_CompiledRangeArgs
[ERROR] /Users/jmhodges/src/github.com/google/closure-templates/target/generated-sources/annotations/com/google/template/soy/jbcsrc/AutoValue_LazyClosureCompiler_ParentCapture.java:[7,7] duplicate class: com.google.template.soy.jbcsrc.AutoValue_LazyClosureCompiler_ParentCapture
jmhodges commented 9 years ago

The hack I found is in the "Maven" section at the bottom of this blog post. I'm not sure what is colliding with AutoValue here. http://dresscode.renttherunway.com/blog/718

jmhodges commented 9 years ago

This seems to be straight up bug in maven 3.2 and 3.3. Related tickets: https://issues.apache.org/jira/browse/MCOMPILER-235 and https://issues.apache.org/jira/browse/MCOMPILER-236

A workaround is to add "false" to the maven-compiler-plugin. (This seems to currently turn on Maven's maybe-not-so bright incremental compiler. See the if-statement here and specifically the "stale sources" code.

The ticket has been open for a while.

jmhodges commented 9 years ago

The other workaround available is using maven-compiler-plugin 3.1.

mikesamuel commented 8 years ago

The next POM release will use

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <source>${java.version}</source>
          <target>${java.version}</target>
          <debug>true</debug>
          <debuglevel>lines,vars,source</debuglevel>
          <compilerArgument>-Werror</compilerArgument>
          <compilerArgument>-Xlint:deprecation</compilerArgument>
        </configuration>
      </plugin>

and the properties section has been changed to update java.version to 1.7.

mikesamuel commented 8 years ago

Upgrading to maven-compiler-plugin:3.5.1 fixes this.