Maven編譯時,編譯插件順序問題出錯

本人做kotlin與Java混合項目

 <build>
    <plugins>
      <plugin>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-maven-plugin</artifactId>
        <version>${kotlin.version}</version>
        <executions>
          <execution>
            <id>compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
          <execution>
            <id>test-compile</id>
            <phase>test-compile</phase>
            <goals>
              <goal>test-compile</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <jvmTarget>1.8</jvmTarget>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <executions>
              <execution>
                  <id>compile</id>
                  <phase>compile</phase>
                  <goals>
                      <goal>compile</goal>
                  </goals>
              </execution>
              <execution>
                  <id>testCompile</id>
                  <phase>test-compile</phase>
                  <goals>
                      <goal>testCompile</goal>
                  </goals>
              </execution>
          </executions>
      </plugin>
      <plugin>
        <groupId>org.asciidoctor</groupId>
        <artifactId>asciidoctor-maven-plugin</artifactId>
        <version>1.5.6</version>
        <dependencies>
          <dependency>
            <groupId>org.asciidoctor</groupId>
            <artifactId>asciidoctorj-pdf</artifactId>
            <version>1.5.0-alpha.10.1</version>
          </dependency>
          <dependency>
            <groupId>org.jruby</groupId>
            <artifactId>jruby-complete</artifactId>
            <version>1.7.21</version>
          </dependency>
        </dependencies>
        <configuration>
          <sourceDirectory>src/main/doc/adoc</sourceDirectory>
          <outputDirectory>src/main/doc/pdf</outputDirectory>
          <backend>pdf</backend>
          <sourceHighlighter>coderay</sourceHighlighter>
          <attributes>
            <toc>left</toc>
          </attributes>
        </configuration>
      </plugin>
    </plugins>
  </build>

指定kotlin編譯插件在前,maven編譯插件再後. 編譯出錯。問題分析,maven插件編譯在前。無法識別kotlin代碼。故出錯

問題出在maven <phase>compile</phase> 。編譯階段。

生命週期 總共有 以下。我們可以將kotlin插件生命週期指定爲compile之上一種即可。 goal 綁定到phase(compile) 之上

validate
initialize
generate-sources
process-sources
generate-resources
process-resources
compile
process-classes
generate-test-sources
process-test-sources
generate-test-resources
process-test-resources
test-compile
process-test-classes
test
prepare-package
package
pre-integration-test
integration-test
post-integration-test
verify
install
deploy
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章