我想與他的Maven着色器插件構建一個胖罐子。我正在修復maven並打破IntelliJ構建,反之亦然。IntelliJ和Maven的着色器插件與多個模塊
我的項目是如下(我離開了插件的部分,包含着色器插件):
- 模塊一 - 主體工程模塊,包含主類
- 模塊-B - 模塊,使用由A
- 模塊-C - 模塊,由A
模塊中使用的聚甲醛:
http://maven.apache.org/xsd/maven-4.0.0.xsd「> 4.0.0
<groupId>com.my</groupId>
<artifactId>module-a</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>../module-b</module>
<module>../module-c</module>
</modules>
<dependencies>
<dependency>
<groupId>com.my</groupId>
<artifactId>module-b</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.my</groupId>
<artifactId>module-c</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.clapper</groupId>
<artifactId>grizzled-slf4j_2.11</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-http-experimental_2.11</artifactId>
<version>2.0.3</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-http-core-experimental_2.11</artifactId>
<version>2.0.3</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-stream-experimental_2.11</artifactId>
<version>2.0.3</version>
</dependency>
<dependency>
<groupId>net.ceedubs</groupId>
<artifactId>ficus_2.11</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.11</artifactId>
<version>2.4.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>allinone</shadedClassifierName>
<artifactSet>
<includes>
<include>*:*</include>
</includes>
</artifactSet>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>reference.conf</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.my.Service</Main-Class>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
模塊B和C POMS是相似的(除模塊名稱)
<?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.my</groupId>
<artifactId>module-b</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.11</artifactId>
<version>2.4.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
所有模塊位於相同級別的同一目錄中。儘管我可以通過IntelliJ構建,但我無法通過maven構建模塊,因爲它找不到模塊-b和-c。所以一般來說,我不能構建引用本地項目的任何東西,因爲Maven不會找到它們。如果我在IDE或命令行中嘗試它,無所謂。
建築模塊,一個我得到:
[錯誤]未能就項目的執行目標模塊一:無法解析 依賴項目com.my:module-a:pom:1.0-SNAPSHOT : 以下工件無法解析: com.my:module-b:jar:1.0-SNAPSHOT,com.my:module-c:jar:1.0-SNAPSHOT: 無法找到工件com.my:module- c:jar:1.0-SNAPSHOT - > [Help 1]
我意識到我可能搞砸了這些poms,嘗試玩與依賴關係與模塊引用,但什麼是正確的方式來引用一個本地模塊在pom文件,而不必將模塊安裝在存儲庫?
我讀到我應該創建一個第四個父項目,其中有一個模塊a作爲父項,並使用該項目創建陰影的jar,但即使採用這種方法,我也無法使其找到模塊同一個項目,它只解析回購模塊。
它看起來像你有模塊A取決於你自己的依賴列表。看看模塊A的pom中的第一個依賴關係的artifactId - 它是「模塊-a」。我認爲它應該是「模塊-C」? – adammtlx
是的你是對的,當我簡化發佈時,我搞砸了。我糾正了這個帖子,謝謝。 –