mvn clean编译软件包在构建中不包括src / main / java文件

时间:2018-08-05 14:39:31

标签: java maven

我以前使用maven生成过jar文件,却从未遇到过我当前项目遇到的这个奇怪问题。

这是一个春季项目,其中包含以下pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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>com.example</groupId>
    <artifactId>SAMPLE_AOP</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>SAMPLE_AOP</name>
    <description>Spring boot project using AspectJ library for adding behavior without modifying existing caps backend micro-services.</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.3.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <log4j.version>1.2.17</log4j.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>


            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <!-- Full configuration to configure each friendly parameters -->
                <configuration>
                    <complianceLevel>1.8</complianceLevel>
                    <source>1.8</source>
                    <target>1.8</target>
                    <showWeaveInfo>true</showWeaveInfo>
                    <verbose>true</verbose>
                    <Xlint>ignore</Xlint>
                    <encoding>UTF-8 </encoding>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <!-- use this goal to weave all your main classes -->
                            <goal>compile</goal>
                            <!-- use this goal to weave all your test classes -->
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>


</project>

我正在使用以下命令进行构建:

mvn clean compile package

其中仅包含一些其他依赖项,而没有src/main/java下的实际代码。

请忽略pom.xml的jar-with-dependencies部分,我不希望将依赖关系打包在我的jar中。我不确定我在这里缺少什么,您能指出吗?

此外,我检查了项目的构建路径,可以看到src / main / java被识别为源文件夹,并且在pom.xml的<sourceDirectory/>标记中也明确提到了它。

Maven输出:

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.example:SAMPLE_AOP:jar:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:aspectj-maven-plugin is missing. @ line 71, column 12
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] ----------------------< com.example:SAMPLE_AOP >----------------------
[INFO] Building SAMPLE_AOP 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ SAMPLE_AOP ---
[INFO] Deleting C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\target
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ SAMPLE_AOP ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ SAMPLE_AOP ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\target\classes
[INFO] /C:/Users/user/Documents/workspace-sts-3.9.5.RELEASE/SAMPLE_AOP/src/main/java/com.sample/AnnotationHelper.java: C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\src\main\java\com.sample\AnnotationHelper.java uses unchecked or unsafe operations.
[INFO] /C:/Users/user/Documents/workspace-sts-3.9.5.RELEASE/SAMPLE_AOP/src/main/java/com.sample/AnnotationHelper.java: Recompile with -Xlint:unchecked for details.
[INFO] 
[INFO] --- aspectj-maven-plugin:1.11:compile (default) @ SAMPLE_AOP ---
[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[INFO] Join point 'method-execution(void com.sample.Application.testing())' in Type 'com.sample.Application' (Application.java:13) advised by around advice from 'com.sample.aspect.LoggingAspect' (LoggingAspect.java:43)
[INFO] Join point 'method-execution(void com.sample.Application.testString())' in Type 'com.sample.Application' (Application.java:20) advised by around advice from 'com.sample.aspect.LoggingAspect' (LoggingAspect.java:43)
[INFO] Join point 'method-call(void com.sample.Application.testing())' in Type 'com.sample.Application' (Application.java:27) advised by around advice from 'com.sample.aspect.LoggingAspect' (LoggingAspect.java:43)
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ SAMPLE_AOP ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ SAMPLE_AOP ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\target\classes
[INFO] /C:/Users/user/Documents/workspace-sts-3.9.5.RELEASE/SAMPLE_AOP/src/main/java/com.sample/AnnotationHelper.java: C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\src\main\java\com.sample\AnnotationHelper.java uses unchecked or unsafe operations.
[INFO] /C:/Users/user/Documents/workspace-sts-3.9.5.RELEASE/SAMPLE_AOP/src/main/java/com.sample/AnnotationHelper.java: Recompile with -Xlint:unchecked for details.
[INFO] 
[INFO] --- aspectj-maven-plugin:1.11:compile (default) @ SAMPLE_AOP ---
[INFO] No modifications found skipping aspectJ compile
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ SAMPLE_AOP ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ SAMPLE_AOP ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- aspectj-maven-plugin:1.11:test-compile (default) @ SAMPLE_AOP ---
[WARNING] No sources found skipping aspectJ compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ SAMPLE_AOP ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ SAMPLE_AOP ---
[INFO] Building jar: C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\target\SAMPLE_AOP-0.0.1-SNAPSHOT.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.0.3.RELEASE:repackage (default) @ SAMPLE_AOP ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:04 min
[INFO] Finished at: 2018-08-05T21:48:14+05:30
[INFO] ------------------------------------------------------------------------

0 个答案:

没有答案