我在这个问题上进行了搜索,遇到了This question,但是我已经做了上面提到的所有事情,并且仍然给我错误。
这是完整的错误:
Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.1.1:shade (default) on project b1_sync_master: Failed to create shaded artifact, project main artifact does not exist.
这是完整的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.mycompany</groupId>
<artifactId>b1_sync_master</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>mule</packaging>
<name>Mule b1_sync_master Application</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<mule.version>3.9.0</mule.version>
<mule.tools.version>1.7</mule.tools.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.kordamp.shade</groupId>
<artifactId>maven-shade-ext-transformers</artifactId>
<version>1.0.3</version>
</dependency>
</dependencies>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
</transformers>
<minimizeJar>false</minimizeJar>
<artifactSet>
<includes>
<include>com.sap.jdbc:sap-jdbc</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>com.sap.db.annotations</pattern>
<shadedPattern>com.shadeSync.sap.db.annotations</shadedPattern>
</relocation>
<relocation>
<pattern>com.sap.db.jdbc</pattern>
<shadedPattern>com.shadeSync.sap.db.jdbc</shadedPattern>
</relocation>
<relocation>
<pattern>com.sap.db.jdbc.converters</pattern>
<shadedPattern>com.shadeSync.sap.db.jdbc.converters</shadedPattern>
</relocation>
<relocation>
<pattern>com.sap.db.jdbc.exceptions</pattern>
<shadedPattern>com.shadeSync.sap.db.jdbc.exceptions</shadedPattern>
</relocation>
<relocation>
<pattern>com.sap.db.jdbc.packet</pattern>
<shadedPattern>com.shadeSync.sap.db.jdbc.packet</shadedPattern>
</relocation>
<relocation>
<pattern>com.sap.db.jdbc.trace</pattern>
<shadedPattern>com.shadeSync.sap.db.jdbc.trace</shadedPattern>
</relocation>
<relocation>
<pattern>com.sap.db.jdbcext</pattern>
<shadedPattern>com.shadeSync.sap.db.jdbcext</shadedPattern>
</relocation>
<relocation>
<pattern>com.sap.db.jdbc.wrapper</pattern>
<shadedPattern>com.shadeSync.sap.db.jdbc.wrapper</shadedPattern>
</relocation>
<relocation>
<pattern>com.sap.db.util</pattern>
<shadedPattern>com.shadeSync.sap.db.util</shadedPattern>
</relocation>
<relocation>
<pattern>com.sap.db.util.security</pattern>
<shadedPattern>com.shadeSync.sap.db.util.security</shadedPattern>
</relocation>
<relocation>
<pattern>net.jpountz.lz4</pattern>
<shadedPattern>net.shadeSync.jpountz.lz4</shadedPattern>
</relocation>
<relocation>
<pattern>net.jpountz.util</pattern>
<shadedPattern>net.shadeSync.jpountz.util</shadedPattern>
</relocation>
<relocation>
<pattern>org.java_websocket</pattern>
<shadedPattern>org.shadeSync.java_websocket</shadedPattern>
</relocation>
<relocation>
<pattern>org.java_websocket.client</pattern>
<shadedPattern>org.shadeSync.java_websocket.client</shadedPattern>
</relocation>
<relocation>
<pattern>org.java_websocket.drafts</pattern>
<shadedPattern>org.shadeSync.java_websocket.drafts</shadedPattern>
</relocation>
<relocation>
<pattern>org.java_websocket.exceptions</pattern>
<shadedPattern>org.shadeSync.java_websocket.exceptions</shadedPattern>
</relocation>
<relocation>
<pattern>org.java_websocket.extensions</pattern>
<shadedPattern>org.shadeSync.java_websocket.extensions</shadedPattern>
</relocation>
<relocation>
<pattern>org.java_websocket.framing</pattern>
<shadedPattern>org.shadeSync.java_websocket.framing</shadedPattern>
</relocation>
<relocation>
<pattern>org.java_websocket.handshake</pattern>
<shadedPattern>org.shadeSync.java_websocket.handshake</shadedPattern>
</relocation>
<relocation>
<pattern>org.java_websocket.util</pattern>
<shadedPattern>org.shadeSync.java_websocket.util</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-app-maven-plugin</artifactId>
<version>${mule.tools.version}</version>
<extensions>true</extensions>
<configuration>
<copyToAppsDirectory>true</copyToAppsDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-resource</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/main/app/</directory>
</resource>
<resource>
<directory>src/main/api/</directory>
</resource>
<resource>
<directory>mappings/</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-- Mule Dependencies -->
<dependencies>
<!-- SAP HANA JDBC DRIVER -->
<dependency>
<groupId>com.sap.jdbc</groupId>
<artifactId>sap-jdbc</artifactId>
<version>1.0</version>
</dependency>
<!-- JODA TIME -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.6</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.6</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.6</version>
</dependency>
<!-- Xml configuration -->
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-spring-config</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<!-- Mule Transports -->
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-file</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-http</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-jdbc</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-jms</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-vm</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<!-- Mule Modules -->
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-scripting</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-xml</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<!-- for testing -->
<dependency>
<groupId>org.mule.tests</groupId>
<artifactId>mule-tests-functional</artifactId>
<version>${mule.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.activemq/activemq-all -->
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.15.7</version>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-schedulers</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-http</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-email</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-db</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>Central</id>
<name>Central</name>
<url>http://repo1.maven.org/maven2/</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Releases Repository</name>
<url>http://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>mulesoft-release</id>
<name>mulesoft release repository</name>
<layout>default</layout>
<url>http://repository.mulesoft.org/releases/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
我正在运行mvn软件包,但是它仍然可以正常工作。这是mvn package -e
的输出:
C:\workspace\b1_sync_master>mvn package -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< com.mycompany:b1_sync_master >--------------------
[INFO] Building Mule b1_sync_master Application 1.0.0-SNAPSHOT
[INFO] --------------------------------[ mule ]--------------------------------
[INFO]
[INFO] --- mule-app-maven-plugin:1.7:attach-test-resources (default-attach-test-
resources) @ b1_sync_master ---
[INFO] attaching test resource C:\workspace\b1_sync_master\src\main\app
[INFO]
[INFO] --- build-helper-maven-plugin:1.7:add-resource (add-resource) @ b1_sync_m
aster ---
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ b1_sync_
master ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Copying 6 resources
[INFO] Copying 1 resource
[INFO] skip non existing resourceDirectory C:\workspace\b1_sync_master\mappings
[INFO]
[INFO] --- mule-app-maven-plugin:1.7:filter-resources (default-filter-resources)
@ b1_sync_master ---
[INFO]
[INFO] --- mule-app-maven-plugin:1.7:process-resources (default-process-resource
s) @ b1_sync_master ---
[INFO] attachMuleSources default value is false, skipping process-resources goal
...
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ b1_sync_maste
r ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 18 source files to C:\workspace\b1_sync_master\target\classes
[INFO] /C:/workspace/b1_sync_master/src/main/java/sapb1masterpoll/JSONCleaner.ja
va: C:\workspace\b1_sync_master\src\main\java\sapb1masterpoll\JSONCleaner.java u
ses unchecked or unsafe operations.
[INFO] /C:/workspace/b1_sync_master/src/main/java/sapb1masterpoll/JSONCleaner.ja
va: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @
b1_sync_master ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 6 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ b1_sy
nc_master ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:3.0.0-M3:test (default-test) @ b1_sync_master -
--
[INFO]
[INFO] --- mule-app-maven-plugin:1.7:mule (default-mule) @ b1_sync_master ---
[INFO] Copying classes directly
[INFO] Copying api directly
[INFO] Adding <com.sap.jdbc:sap-jdbc:jar:1.0> as a lib
[INFO] Adding <com.fasterxml.jackson.core:jackson-core:jar:2.9.6> as a lib
[INFO] Adding <com.fasterxml.jackson.core:jackson-databind:jar:2.9.6> as a lib
[INFO] Adding <com.google.code.gson:gson:jar:2.8.5> as a lib
[INFO] Adding <joda-time:joda-time:jar:2.10.1> as a lib
[INFO] Adding <com.fasterxml.jackson.core:jackson-annotations:jar:2.9.6> as a li
b
[INFO] Adding <org.apache.activemq:activemq-all:jar:5.15.7> as a lib
[INFO] C:\workspace\b1_sync_master\mappings does not exist, skipping
[INFO] C:\workspace\b1_sync_master\target\META-INF does not exist, skipping
[INFO] Building zip: C:\workspace\b1_sync_master\target\b1_sync_master-1.0.0-SNA
PSHOT.zip
[INFO]
[INFO] --- maven-shade-plugin:3.1.1:shade (default) @ b1_sync_master ---
[ERROR] The project main artifact does not exist. This could have the following
[ERROR] reasons:
[ERROR] - You have invoked the goal directly from the command line. This is not
[ERROR] supported. Please add the goal to the default lifecycle via an
[ERROR] <execution> element in your POM and use "mvn package" to have it run.
[ERROR] - You have bound the goal to a lifecycle phase before "package". Please
[ERROR] remove this binding from your POM such that the goal will be run in
[ERROR] the proper phase.
[ERROR] - You removed the configuration of the maven-jar-plugin that produces th
e main artifact.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.190 s
[INFO] Finished at: 2019-10-01T10:54:48-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.1.1
:shade (default) on project b1_sync_master: Failed to create shaded artifact, pr
oject main artifact does not exist. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.apache.maven.plugins:maven-shade-plugin:3.1.1:shade (default) on project b1_s
ync_master: Failed to create shaded artifact, project main artifact does not exi
st.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja
va:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja
va:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja
va:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (
LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (
LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreaded
Builder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleSt
arter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.jav
a:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessor
Impl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launche
r.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:2
29)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launc
her.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356
)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to create shad
ed artifact, project main artifact does not exist.
at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute (ShadeMojo.java:400
)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBui
ldPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja
va:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja
va:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja
va:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (
LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (
LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreaded
Builder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleSt
arter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.jav
a:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessor
Impl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launche
r.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:2
29)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launc
her.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356
)
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception
致谢
答案 0 :(得分:0)
问题似乎是您正在尝试在Mule项目而不是Java项目中使用shade插件。因此,它可能找不到主要的工件。一种替代方法是创建一个Java jar项目,在其中进行阴影处理,然后将生成的jar作为Mule项目中的依赖项。