骡子:Maven排除某些骡子罐,同时创造mule runnable jar

时间:2015-05-30 04:27:58

标签: mule maven-3 mule-studio maven-assembly-plugin mule-component

需要使用maven-assembly插件创建一个可运行的mule服务jar。它创建了一个zip文件,但不包括某些骡子罐。当试图从控制台运行它时获取mule-core jar的classnotfound异常。我如何包括这些罐子以及创建一个罐而不是拉链。使用来自anypoint studio maven插件的maven clean package命令打包时控制台上的消息是

 call<- function(states, output) {
     df1<- data.frame(names=c("a", "b", "c", "d"), states=c("AK", "AL", "AR",   "AZ"), number=1:4)
     df1_state<- split(df1, df1$state)
     df2<- data.frame(names=c("e", "f", "g", "h"), states=c("AK", "AL", "AR", "AZ"), number=9:12)
     df2_state<- split(df2, df2$state)
     df3<- data.frame(names=c("i", "j", "k", "l"), states=c("AK", "AL", "AR", "AZ"), number=14:17)
     df3_state<- split(df3, df3$state)
     for (state in length(df1_state)) {
         if(output== "df1")
             print(b<- subset(df1_state[[states]], select= "names"))
         else if(output== "df2")
             print(c<- subset(df2_state[[states]], select= "names"))
         else
             print(d<- subset(df3_state[[states]], select= "names")) 
     }
 }

的pom.xml

[INFO] Using exclusions definition for Mule ESB Server version 3.6.0
[INFO] Using as WTP server : null
[INFO] excluded: xerces:xercesImpl
[INFO] excluded: xml-apis:xml-apis
[INFO] excluded: commons-codec:commons-codec
[INFO] excluded: org.slf4j:slf4j-api
[INFO] excluded: org.mule:mule-core
[INFO] excluded: commons-cli:commons-cli
[INFO] excluded: com.lmax:disruptor
[INFO] excluded: org.apache.logging.log4j:log4j-api
[INFO] excluded: org.apache.logging.log4j:log4j-core
[INFO] excluded: org.apache.logging.log4j:log4j-slf4j-impl
[INFO] excluded: org.apache.logging.log4j:log4j-1.2-api
[INFO] excluded: org.apache.logging.log4j:log4j-jcl
[INFO] excluded: org.slf4j:jcl-over-slf4j
[INFO] excluded: org.apache.logging.log4j:log4j-jul
[INFO] excluded: org.mule.mvel:mule-mvel2
[INFO] excluded: org.mule.common:mule-common
[INFO] excluded: org.mule.modules:mule-module-client
[INFO] excluded: org.mule.modules:mule-module-spring-config
[INFO] excluded: org.mule.modules:mule-module-annotations
[INFO] excluded: org.mule.modules:mule-module-xml
[INFO] excluded: org.mule.modules:mule-module-cxf
[INFO] excluded: org.mule.modules:mule-module-spring-security
[INFO] excluded: org.mule.transports:mule-transport-http
[INFO] excluded: org.mule.transports:mule-transport-ssl
[INFO] excluded: org.mule.transports:mule-transport-tcp
[INFO] excluded: org.mule.modules:mule-module-http
[INFO] excluded: org.mule.modules:mule-module-spring-extras
[INFO] excluded: org.mule.modules:mule-module-builders
[INFO] excluded: org.mule.modules:mule-module-management
[INFO] excluded: org.mule.modules:mule-module-scripting
[INFO] excluded: org.mule.modules:mule-module-sxc
[INFO] excluded: org.mule.tests:mule-tests-functional
[INFO] excluded: org.mule:mule-core
[INFO] excluded: org.mule.transports:mule-transport-file
[INFO] excluded: org.mule.transports:mule-transport-jdbc
[INFO] excluded: org.mule.transports:mule-transport-jms
[INFO] excluded: org.mule.transports:mule-transport-vm

  Attached is Pom.xml and assembly.xml used for creating runnable jar.

assembly.xml

<?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>in.gov.uidai</groupId>
    <artifactId>uidprnlettergenerator</artifactId>
    <packaging>mule</packaging> 
    <version>1.0.0-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <mule.version>3.6.0</mule.version>
        <eclipsePluginVersion>2.8</eclipsePluginVersion>
        <jdkName>JavaSE-1.6</jdkName>
        <jdk.version>1.6</jdk.version>
        <junit.version>4.9</junit.version>
        <uidpersistentmodel.version>3.5.14</uidpersistentmodel.version>
    </properties>

    <build>
        <!-- Use a newer version of the install plugin than what your Maven uses 
            by default. The older version failed to install the project if there was 
            no target/classes folder. Since we use mule packaging on the project we actually 
            create and attach the zip that must be installed. -->
        <pluginManagement>
            <plugins>
                <!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> 
                    <version>2.3.1</version> </plugin> This plugin's configuration is used to 
                    store Eclipse m2e settings only. It has no influence on the Maven build itself. 
                    <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> 
                    <version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> 
                    <pluginExecution> <pluginExecutionFilter> <groupId>org.mule.tools</groupId> 
                    <artifactId>maven-mule-plugin</artifactId> <versionRange>[1.6,)</versionRange> 
                    <goals> <goal>attach-test-resources</goal> <goal>filter-resources </goal> 
                    </goals> </pluginExecutionFilter> <action> <ignore /> </action> </pluginExecution> 
                    </pluginExecutions> </lifecycleMappingMetadata> </configuration> </plugin> -->
            </plugins>
        </pluginManagement>
        <plugins>
              <plugin>
                <groupId>org.mule.tools</groupId>
                <artifactId>maven-mule-plugin</artifactId>
                <version>1.9</version>
                <extensions>true</extensions>
                <configuration>
                    <copyToAppsDirectory>true</copyToAppsDirectory>
                    <inclusions>
                        <inclusion>
                            <groupId>org.mule.transports</groupId>
                            <artifactId>mule-transport-amqp</artifactId>
                        </inclusion>
                        <inclusion>
                            <groupId>org.mule.modules</groupId>
                            <artifactId>mule-module-objectstore</artifactId>
                        </inclusion>
                        <inclusion>
                            <groupId>org.mule</groupId>
                            <artifactId>mule-core</artifactId>
                        </inclusion>
                    </inclusions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                    <encoding>ISO-8859-1</encoding>
                </configuration>
            </plugin>
            <!-- <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.2.1</version> 
                <configuration> <descriptorRefs> <descriptorRef>project</descriptorRef> </descriptorRefs> 
                </configuration> </plugin> -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>${eclipsePluginVersion}</version>
                <configuration>
                    <!-- by default download all sources when generating project files -->
                    <downloadSources>true</downloadSources>
                </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>
                    </execution>
                </executions>
                <configuration>
                    <resources>
                        <resource>
                            <directory>src/main/app/</directory>
                        </resource>
                        <resource>
                            <directory>src/main/api/</directory>
                        </resource>
                    </resources>
                </configuration>
            </plugin>
            <!--  <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>org.mule.MuleServer</mainClass>
                    <arguments>
                        <argument>-config</argument>
                        <argument>src/main/app/mule-config.xml</argument>
                    </arguments>
                    <classpathScope>compile</classpathScope>
                </configuration>
            </plugin>-->

            <!--Install clover-plugins -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.4</version>
                <!-- <executions> <execution> <id>copy-clover-plugins</id> <phase>validate</phase> 
                    <goals> <goal>copy</goal> </goals> <configuration> <overWriteReleases>true</overWriteReleases> 
                    <overWriteSnapshots>true</overWriteSnapshots> <overWriteIfNewer>true</overWriteIfNewer> 
                    <stripVersion>true</stripVersion> <outputDirectory>${project.build.testOutputDirectory}</outputDirectory> 
                    <artifactItems> <artifactItem> <groupId>com.cloveretl</groupId> <artifactId>cloveretl-engine</artifactId> 
                    <version>${mule.version}</version> <type>zip</type> </artifactItem> </artifactItems> 
                    </configuration> </execution> </executions> -->
            </plugin>
            <!-- <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.7</version> 
                <executions> <execution> <phase>compile</phase> <configuration> <tasks> Using 
                an ant task to deflate cloveretl-engine.zip <unzip dest="${project.build.testOutputDirectory}" 
                src="${project.build.testOutputDirectory}/cloveretl-engine.zip" /> </tasks> 
                </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> 
                </plugin> -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <id>xjc</id>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <schemaDirectory default-value="${project.basedir}/src/main/resources/schema" />
                    <bindingDirectory>${project.basedir}/src/main/resources/schema</bindingDirectory>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.5.4</version>
                <configuration>
                    <descriptors>
                        <descriptor>assembly.xml</descriptor>
                    </descriptors>
                    <archive>
                        <manifest>
                            <mainClass>in.gov.uidai.loader.PrintLetterGeneratorLoader</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id> <!-- this is used for inheritance merges -->
                        <phase>package</phase> <!-- bind to the packaging phase -->
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <!-- plugins for creating site reports -->
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.4.2</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <configLocation>http://mulesoft.org/download/attachments/92/checkstyle.xml?version=1</configLocation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <targetJdk>${jdk.version}</targetJdk>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.5</version>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>taglist-maven-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <tags>
                        <tag>TODO</tag>
                        <tag>@todo</tag>
                        <tag>FIXME</tag>
                        <tag>@fixme</tag>
                        <tag>@deprecated</tag>
                    </tags>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>2.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <source>${jdk.version}</source>
                    <links>
                        <link>http://java.sun.com/j2ee/1.4/docs/api</link>
                        <link>http://java.sun.com/j2se/1.4.2/docs/api</link>
                        <link>http://java.sun.com/j2se/1.5.0/docs/api</link>
                    </links>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jdepend-maven-plugin</artifactId>
                <version>2.0-beta-2</version>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>2.3.2</version>
            </plugin>
        </plugins>
    </reporting>

    <!-- Third Party dependency <dependencies> <dependency> <groupId>com.sun.jersey</groupId> 
        <artifactId>jersey-client</artifactId> <version>1.19</version> </dependency> 
        </dependencies> -->


    <dependencies>
        <!-- Third Party dependency -->
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-client</artifactId>
            <version>1.19</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
        </dependency>
        <dependency>
            <groupId>org.mule.modules</groupId>
            <artifactId>mule-module-objectstore</artifactId>
            <version>1.3.1</version>
        </dependency>
        <!-- Mule Dependencies -->
        <dependency>
            <groupId>org.mule</groupId>
            <artifactId>mule-core</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- Xml configuration <dependency> <groupId>com.mulesoft.muleesb.modules</groupId> 
            <artifactId>mule-module-boot-ee</artifactId> <version>${mule.version}</version> 
            <scope>provided</scope> </dependency> -->
        <!-- Xml configuration -->
        <dependency>
            <groupId>org.mule.modules</groupId>
            <artifactId>mule-module-spring-config</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- Xml configuration <dependency> <groupId>com.mulesoft.muleesb</groupId> 
            <artifactId>mule-core-ee</artifactId> <version>${mule.version}</version> 
            <scope>provided</scope> </dependency> <dependency> <groupId>com.mulesoft.muleesb.modules</groupId> 
            <artifactId>mule-module-data-mapper</artifactId> <version>${mule.version}</version> 
            </dependency> Xml configuration <dependency> <groupId>com.mulesoft.muleesb.modules</groupId> 
            <artifactId>mule-module-spring-config-ee</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-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-client</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.mule.modules</groupId>
            <artifactId>mule-module-cxf</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.mule.modules</groupId>
            <artifactId>mule-module-management</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
        <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-sxc</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>
        <dependency>
            <groupId>mockobjects</groupId>
            <artifactId>mockobjects-core</artifactId>
            <version>0.09</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <!-- <dependency> <groupId>com.cloveretl</groupId> <artifactId>cloveretl-engine</artifactId> 
            <version>3.5.2</version> <scope>test</scope> </dependency> -->
        <dependency>
            <groupId>org.mule.transports</groupId>
            <artifactId>mule-transport-amqp</artifactId>
            <version>3.4.4</version>
        </dependency>
        <!-- Other UIDAI project dependencies -->
        <dependency>
            <groupId>in.gov.uidai</groupId>
            <artifactId>uidpersistentmodel</artifactId>
            <version>${uidpersistentmodel.version}</version>
        </dependency>
        <dependency>
            <groupId>in.gov.uidai</groupId>
            <artifactId>uidplatform</artifactId>
            <version>3.5.17</version>
        </dependency>
        <dependency>
            <groupId>in.gov.uidai</groupId>
            <artifactId>uidplatformmodel</artifactId>
            <version>3.5.17</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.2.0.Final</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>mulesoft-releases</id>
            <name>MuleSoft Releases Repository</name>
            <url>http://repository.mulesoft.org/releases/</url>
            <layout>default</layout>
        </repository>
        <repository>
            <id>mulesoft-snapshots</id>
            <name>MuleSoft Snapshots Repository</name>
            <url>http://repository.mulesoft.org/snapshots/</url>
            <layout>default</layout>
        </repository>
        <repository>
            <id>muleforge-releases</id>
            <name>MuleForge Snapshot Repository</name>
            <url>http://repository-master.mulesoft.org/releases/</url>
        </repository>
        <repository>
            <id>Central</id>
            <name>Central</name>
            <url>http://repo1.maven.org/maven2/</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>

1 个答案:

答案 0 :(得分:1)

Mule应用程序打包为zip而不是jar档案。它们被设计为部署在Mule Standalone服务器上,该服务器提供所有Mule直接和传递依赖性。这就是为什么没有Mule jar应该进入应用程序zip的原因。事实上,如果你只使用核心传输和模块,那么Mule应用程序非常小:它只包含配置文件和Java类(如果有的话)。

要生成不需要在Mule Standalone上部署的可执行jar,请使用jar-with-dependencies配置中的标准maven-assembly-plugin,即。替换这个:

<descriptors>
    <descriptor>assembly.xml</descriptor>
</descriptors>

与此:

<descriptorRefs>
    <descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>

您还需要从provided中的Mule依赖项中删除pom.xml范围。