这就是我所需要的一切.其他细节:我有一个src/bootstrap/java文件夹和常规的src/main/java文件夹.出于显而易见的原因,每个人都需要去一个单独的罐子.我能够用这个生成一个bootstrap jar :
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>only-bootstrap</id>
<goals><goal>jar</goal></goals>
<phase>package</phase>
<configuration>
<classifier>bootstrap</classifier>
<includes>
<include>sun/**/*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但常规jar仍包含引导类.我正在用这个答案编译bootstrap类.
没有bootstrap类生成myproject.jar的任何灯光?
我正在使用自定义目录结构并在sourcedirectory标记中指定了目录.但我仍然得到消息No sources to compile.虽然构建成功.
我的目录结构:
所以不是src/main/java,我正在使用java.(我有理由这样做,所以现在不可能切换到src/main/java)
这是我的pom.xml:
<artifactId>application</artifactId>
<name>application</name>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.test.skip>true</maven.test.skip>
</properties>
<build>
<sourceDirectory>java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<excludes>
<exclude>**/old/**/*.java</exclude>
</excludes>
<includes>
<include>java/com/**/*.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<excludes>
<exclude>**/old/**/*.java</exclude>
</excludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.start.Start</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
当我运行命令时mvn clean package,我得到以下输出:
源代码未编译,结果jar为空.我提到的使用自定义目录结构与maven的所有来源说使用sourceDirectory应该解决问题.但就我而言,它并没有解决
编辑
我使用自定义目录结构,因为使用标准目录结构对我不起作用.她的问题与此有关: 在eclipse maven中链接源文件夹时出错
EDIT2:
我在java目录中链接源代码.也就是说,在文件系统上,application-> java不存在,但是在eclipse中通过链接源选项,我已经从不同的目录添加了Java源文件夹.因此它出现在日食中.我还使用mvn命令行以及eclipse运行maven命令.
我正在使用maven-jaxb-plugin来生成基于xsd文件的类文件源:
<plugin>
<groupId>com.sun.tools.xjc.maven2</groupId>
<artifactId>maven-jaxb-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>jaxb-xsd-constants</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<generatePackage>com.mypackage</generatePackage>
<schemaDirectory>${basedir}/src/main/resources/xsd/mylist</schemaDirectory>
<includeSchemas>
<includeSchema>mylist.xsd</includeSchema>
</includeSchemas>
<strict>true</strict>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

但是我需要将这些文件夹添加为源文件夹,以便Eclipse加载编译它们:
如何使用插件或其他方法将文件夹添加为源文件夹?而不必手动添加这些文件夹.
我对Maven和tycho的世界还很陌生,因此希望这只是我很想念的东西。我正在尝试使用tycho构建插件,但无法获取tycho-compiler-plugin来识别在构建过程中生成的源代码。
这是我汇总来演示的测试pom的副本:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>rt</groupId>
<artifactId>rt.webservice</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<tycho-version>0.16.0</tycho-version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<verbose>true</verbose>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.12</version>
<executions>
<execution>
<id>generate-ws-code</id>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlDirectory>${basedir}/wsdl</wsdlDirectory>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
我在src文件夹中有一个Java类,它引用一些生成的源代码,然后无法编译。
如果我删除tycho并使用标准的maven-compiler-plugin,它将自动获取在构建过程中生成的代码,并且上述Java类将按预期进行编译。
有人可以告诉我我在做什么错吗?
我正在 Maven 项目中尝试使用 JAXB 进行 xml 映射。我将 JAXB jar 放在一个单独的项目中,并将其作为依赖项添加到我的主项目中。我正在使用 Eclipse。
现在,JAXB 的功能似乎很好,并且从某些 XSD 模式中,在 target/ generated-sources/xjc 文件夹中生成了几个 Java 类。问题是 Eclipse 无法解析主项目中单元测试中的那些类。我什至手动导入这些包名称,但类名称仍然无法解析。我有什么遗漏的吗?