Maven 2 为什么maven编译没有';“我不能和”一起工作;pom“;包装类型

Maven 2 为什么maven编译没有';“我不能和”一起工作;pom“;包装类型,maven-2,target,maven-assembly-plugin,maven-compiler-plugin,Maven 2,Target,Maven Assembly Plugin,Maven Compiler Plugin,我不知道为什么我的maven build在当前pom设置中没有生成目标/类,在我的情况下,打包类型必须是“pom”,请告知有什么问题。。。谢谢 <?xml version="1.0" encoding="UTF-8" standalone="no"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:s

我不知道为什么我的maven build在当前pom设置中没有生成目标/类,在我的情况下,打包类型必须是“pom”,请告知有什么问题。。。谢谢

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.abc.sm.doctor</groupId>
<artifactId>smdoctor</artifactId>
<packaging>pom</packaging>
<version>${SMDOCTOR_VERSION}</version>
<name>sm doctor</name>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
    <plugins>   
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
                <debug>true</debug>
                <debuglevel>source,lines</debuglevel>
                <showDeprecation>true</showDeprecation>
                <archive>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <appendAssemblyId>false</appendAssemblyId>         
                <finalName>smdoctor</finalName> 
                <descriptors>
                    <descriptor>dist.xml</descriptor>
                    <descriptor>zip.xml</descriptor>
                </descriptors>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>1.7</version>
    <executions>
      <execution>
        <id>attach-artifacts</id>
        <phase>package</phase>
        <goals>
          <goal>attach-artifact</goal>
        </goals>
        <configuration>
          <artifacts>
            <artifact>
              <file>target/smdoctor.zip</file>
              <type>zip</type>
            </artifact>
          </artifacts>
        </configuration>
      </execution>
    </executions>
  </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <classpathPrefix>lib/</classpathPrefix>
                        <mainClass>...</mainClass>
                    </manifest>
                </archive>
            </configuration>
            <version>2.3.1</version>
        </plugin>
    </plugins>
</build>
<dependencies>
    ... 
     </dependencies>

4.0.0
com.abc.sm.doctor
smdoctor
聚甲醛
${SMDOCTOR_版本}
sm医生
UTF-8
org.apache.maven.plugins
maven编译器插件
1.5
1.5
真的
来源,行
真的
maven汇编插件
假的
smdoctor
dist.xml
zip.xml
组装
包裹
单一的
org.codehaus.mojo
构建助手maven插件
1.7
附加工件
包裹
附加工件
target/smdoctor.zip
拉链
org.apache.maven.plugins
maven jar插件
真的
解放党/
...
2.3.1
... 

编译器插件没有绑定到maven生命周期的任何阶段,而是打包pom。您必须像为assemby插件所做的那样,配置
执行

<executions>
    <execution>
        <id>compile</id>
        <phase>compile</phase>
        <goals>
             <goal>compile</goal>
        </goals>
    </execution>
</executions>

编译
编译
编译
如果源代码位于src/main/java以外的文件夹中,则必须在pom的build部分配置此文件夹:

<build>
    <sourceDirectory>${basedir}/path/to/sources</sourceDirectory>
    <!-- plugins and other configuration -->
</build>

${basedir}/path/to/sources

通过将打包类型设置为
pom
,可以指定不应编译任何内容。也许
pom
毕竟不是这个工件的正确包装类型?看起来您的脚本可以正常运行,因为pom打包只是为了让其他模块继承子模块的常见和常规配置,例如插件、依赖项、贡献者、开发人员等等。请记住,它不会超出验证阶段

这个包是逻辑的,不是真实的,所以您不应该在那个级别放置任何真实的代码或资源。如果您在5个子模块中使用junit,那么您不必在5个pom文件中定义依赖项,而只需在父pom中使用pom打包即可,如果您希望覆盖父pom中的内容,您仍然可以在模块中指定特定版本。当您运行父pom时,pom的执行从父到子开始,然后从上到下检索所有依赖项


这就是我对pom包装的理解。因此,如果您有这样的打包代码,这意味着您的maven项目结构需要修改。仅将打包pom用作多个模块之间的通用配置

仍然不走运,得到这个:[INFO][compiler:compile{execution:compile}][INFO]没有要编译的源代码,究竟为什么没有要编译的源代码?您的源代码位于
src/main/java
?另一方面,您必须将
build
下的
sourceDirectory
元素设置为正确的目录。您是对的,jar作为打包类型没有问题,但不知何故,我需要使用pom,我能不能以某种方式强制编译??听起来您在Maven中做错了事情,因为如果您需要打包pom,这意味着通常在根目录中有多模块构建,但根目录不应该生成jar。如果您需要创建一个jar而不是使用包装类型jar。。。