Maven编译插件未将生成的类复制到测试源代码。

huangapple go评论71阅读模式
英文:

Maven compiler plugin not copying generated classes to test-sources

问题

以下是您要翻译的内容:

Maven编译插件未将生成的类(来自mapstruct的映射器)复制到target\generated-test-sources\test-annotations目录中。该目录已创建,但为空。生成的类只复制到target\generated-sources\annotations目录中。

这是我的maven-compiler插件配置:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
    <configuration>
        <release>11</release>
        <annotationProcessorPaths>
            <path>
                <groupId>org.mapstruct</groupId>
                <artifactId>mapstruct-processor</artifactId>
                <version>${org.mapstruct.version}</version>
            </path>
            <path>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>${org.lombok.version}</version>
            </path>
        </annotationProcessorPaths>
    </configuration>
</plugin>

谢谢!

英文:

Maven compiler plugin is not copying the generated classes(mappers from mapstruct) to target\generated-test-sources\test-annotations. The directory is created but it's empty. The generated classes are copied to target\generated-sources\annotations only.

This is my maven-compiler plugin configuration:

&lt;plugin&gt;
			&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
			&lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
			&lt;version&gt;3.8.1&lt;/version&gt;
			&lt;configuration&gt;
				&lt;release&gt;11&lt;/release&gt;
				&lt;annotationProcessorPaths&gt;
					&lt;path&gt;
						&lt;groupId&gt;org.mapstruct&lt;/groupId&gt;
						&lt;artifactId&gt;mapstruct-processor&lt;/artifactId&gt;
						&lt;version&gt;${org.mapstruct.version}&lt;/version&gt;
					&lt;/path&gt;
					&lt;path&gt;
						&lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
						&lt;artifactId&gt;lombok&lt;/artifactId&gt;
						&lt;version&gt;${org.lombok.version}&lt;/version&gt;
					&lt;/path&gt;
				&lt;/annotationProcessorPaths&gt;
			&lt;/configuration&gt;
		&lt;/plugin&gt;

Thank you!

答案1

得分: 1

生成的源代码位置由maven-compiler-plugin定义。

默认情况下,它会将注解处理器生成的类放在:

  • target/generated-sources/annotations - 当从src/main/java位置编译类时
  • target/generated-test-sources/test-annotations - 当从src/test/java位置编译类时

为了使您能够在target/generated-test-sources/test-annotations下看到类,您的映射器应该位于src/test/java下。

英文:

The location of the generated source is defined by the maven-compiler-plugin.

By default it will put classes generated by annotation processor in:

  • target/generated-sources/annotations - When compiling classes from the src/main/java location
  • target/generated-test-sources/test-annotations - When compiling clases from the src/test/java location

In order for you to see the classes under target/generated-test-sources/test-annotations then your mappers should be under src/test/java.

huangapple
  • 本文由 发表于 2020年9月16日 16:09:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/63915747.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定