如何做一个插件状架构的运行?

0

的问题

我们有几个遗留Java项目,这是我们转变为行项目/模块。 以前,所有项目//需要将物品寄项目并没有真正的依赖关系的管理。 外部的依赖性上存在的公司网络驱动器以及直接包括为瓶中的内容项目的各个模块。 内部依赖性的、简单的项目参考使用。 这是一个痛苦构建的一切,因为该程序必须建立的一切正确的顺序。

现在,我们的位置,我们可以打开所有的家模块在IDEA和演讲视频。 然而,我遇到麻烦找出最佳的方式,结合不同的模块和外部的依赖在一个特定的方式,符合内部插件状结构。 特别是随//需要将物品寄(发展与IDEs必须是可能的)。

这里是如何从初的储存库/项目的结构大致看起来像。 该文件夹结构的模块是默认的专家的结构为每个模块。 所列特性这个网站是太笨拙了,所以我把它作为截图...

Structure Git Repos

我们有一个内部专家库的材料和建筑专家等等。 是的工作。 为IDEA,我可以运行调试的终端产品对customer1通过一个定制的运行配置,其副本必要的文件所需的结构:

enter image description here

与IDEA,我可以试的软件,但我认为,这种办法(定义用浏览器运行配置我创造的,指的所有需要的罐子和文件直接)是很丑陋的,并且象偷我找不到一个类似的"运行配置"的机制。

所以我试图实现这种构建进程,通过创建一个新的"Customer1Runnable"家的项目作为一种建立的描述,这点向所有需要的家模块。 在此基础上,我相信我可以实现的和全自动创造所需的软件结构。 因此复制所有模块成为一个插件,文件夹和所有依赖性的模块进入一个lib文件夹内Customer1Runnable项目,利用专家组-插件。

首先,是我的假设正确,这是一个可能的使用情况的专家组-插件?

该项目本身不具有任何源文件,它是唯一一个pom.xml 和assembly-config.xml 描述符。 我附上会插件包阶段。 当跑的 mvn package 命令所有连接的模块建造的,但是为执行大会的插件,我得到以下产出:

Windows CMD output of Customer1Runnable maven project

对于初学者来说,我只是试图包括一个模块组装的描述符。 这是XML(opicom-assembly.xml):

<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
    <id>opicom-assembly</id>
    <formats>
        <format>dir</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <moduleSets>
        <moduleSet>
            <useAllReactorProjects>true</useAllReactorProjects>
                <includes>
                    <include>my.company.reporting:module1</include>
                </includes>
        </moduleSet>
    </moduleSets>
</assembly>

pom.xml 的项目Customer1Runnable

 <?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>
    <version>1.6</version>
    <groupId>my.company.customer1</groupId>
    <artifactId>OpicomRunnable</artifactId>
    <packaging>pom</packaging>
    <name>OpicomRunnable</name>
    
    <repositories>
        <repository>
            <id>Company-Maven-Repo</id>
            <url>file:\\\\MyCompany\TFSDrop\MavenRepo</url>
        </repository>
    </repositories>
    
    <modules>
        <module>../my.company.customer1.module1</module>
        <module>../my.company.customer1.module2</module>
        .
        .
        .
        <module>../../MyCompany_Common/Report/my.company.reporting.module1</module>
    </modules>  
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.3.0</version>
                <inherited>true</inherited>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <descriptors>
                        <descriptor>opicom-assembly.xml</descriptor>
                    </descriptors>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Pom的一个模块是这样的:

<?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>

    <parent>
        <groupId>my.company</groupId>
        <artifactId>reporting</artifactId>
        <version>1.3</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>module1</artifactId>
    <version>1.3</version>
    <packaging>jar</packaging>



    <dependencies>
        <!-- external dependencies -->
        <dependency>
            <groupId>commons-pool</groupId>
            <artifactId>commons-pool</artifactId>
            <version>1.6</version>
        </dependency>
        <dependency>
            <groupId>com.oracle.database.jdbc</groupId>
            <artifactId>ojdbc8</artifactId>
            <version>21.1.0.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <finalName>my-company-${project.artifactId}</finalName>
                    <appendAssemblyId>false</appendAssemblyId>
                    <outputDirectory>../build</outputDirectory>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

谢谢你的任何输入关于什么我做错了这里如何实现这种与家.

编辑: 作为请求,这里的一个例子项目作为拉链文件。 https://drive.google.com/drive/folders/1ilJeTrOPgYgUTdOP0J4BQcBnPT5fls0k?usp=sharing 父目录ModuleGroupCustomer和ModuleGroupCommon做的代表git仓库中的现实情况。 相对模块的路径造成的,因为家项目,该项目应该是我的"运行配置"指向家项目在这两个仓库。

也许我误会专家在一般? 我认为它在使用条款的情况下对于依赖管理类似。净nuget包,但也作为"项目的构成"普通//需要将物品寄/架构来达成这项目。

它是更好地简单地坚持现有的//需要将物品寄项目的日常发展?

1

最好的答案

0

经过一个漫长而繁琐的过程的试验和错误,我已经找到一个解决方案,这是为我工作。 所以我决定来分享在线解决方案,在情况下其他人到一个类似的问题。 这里是一个链接到最终zip archive含工作的例子项目=>文件CustomerRunnable_RunningAssemblyPluginStackoverflowExample.zip https://drive.google.com/drive/u/0/folders/1ilJeTrOPgYgUTdOP0J4BQcBnPT5fls0k

我的错误是,我误会了如何装配件的工作。 这种方法,执行我插在我的聚合pom(CustommerRunnable)是错误的,因为这个家的项目只有在存在作为父pom。

该CustommerRunnable pom.xml 引用的所有客户的插件作为模块。 这些模块已经不CustommerRunnable作为父母,但不同pom。 然后我创造了一个独立的专家项目"的分销"。 的pom.xml 分布的定义的所有插件(根据需要客户的家模块)的依赖关系。 它也有CustommerRunnable pom.xml 作为父母。 因此,当我运行中的项目//需要将物品寄,连接所有模块也是建立(如果必要)。

它也配置的组件。 大会插件附于家包阶段,因此执行它。 它还使用一定会符,这份所有先前定义的插件进入正确的文件夹。 这是通过使用dependencySets与包括和排斥的模式。 看看 https://maven.apache.org/plugins/maven-assembly-plugin/advanced-descriptor-topics.html 详细信息,这一点。 因此,一个dependencySet副本所有的罐子文件的所有插件a/插文件夹,通过使用一个包括模式。 然后这个方法反转到复制的罐子文件的所有外部的依赖,a/lib文件夹。

描述还定义了一些额外的文件复制到一个特定的位置。 exec-玛文件,因此我可以轻松开始的客户软件库的. 我没有尚未管理配置执行的插件正确的关于需要类路径参数。

Endresult看起来是这样的: Assembly folder after building

这也是值得注意的配置的"建设项目的"、"运行"项目和"调试项目的"内//需要将物品寄需要一个小小的修改。 (右击模块"布"->"属性"->点"行动"

2021-11-25 17:07:28

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................