maven-ejb-plugin:包含生成的源

Rém*_*umm 5 maven

我有一个EJB-maven-Project,它有一些生成的类(由JAXB生成).它们生成:target/generated-sources/jaxb/

现在,使用maven-ejb-plugin,我希望它们(即它们的编译类)被包含在client-jar中,类似于:

       <plugin>
            <artifactId>maven-ejb-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <!-- Tell Maven we are using EJB 3.1 -->
                <ejbVersion>3.1</ejbVersion>
                <generateClient>true</generateClient>
                <clientIncludes>
                    <clientInclude>com/bla/ch/authorization/client/**</clientInclude>
                    <clientInclude>target/generated-sources/jaxb/**</clientInclude>
                </clientIncludes>
            </configuration>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

这不起作用,生成的类不是ejb-client-jar的一部分.(虽然他们在ejb-jar中).我该怎么做才能正确?

Jea*_*evy 0

在 jar 中包含源可能不是一个好的解决方案。

您可以在资源位置添加生成的源,然后使用源插件来生成所谓的artifact-sources.jar

<resources>
    <resource>
        <directory>${basedir}/target/generated-sources</directory>
        <filtering>true</filtering>
    </resource>
</resources>
     [...]
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
                <execution>
                    <id>attach-sources</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

这是比用源代码生成 jar 更好的方法。