部署到 cloudhub 的 Maven 脚本

Maven script to deploy to cloudhub

我正在按照此文档将 mule 应用程序部署到 cloudhub --> https://docs.mulesoft.com/mule-user-guide/v/3.8/mule-maven-plugin

当我 运行 "mvn package deploy" 时,出现以下错误:

[ERROR] 无法执行目标 org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project myapplication: Deployment failed: repository element was not在 distributionManagement 元素内的 POM 或 -DaltDeploymentRepository=id::layout::url 参数 -> [Help 1]

中指定

pom.xml

<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>myapplication</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>mule</packaging>
<name>Mule myapplication Application</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <mule.version>3.8.1</mule.version>
    <mule.tools.version>1.2</mule.tools.version>
    <munit.version>1.2.1</munit.version>
    <mule.munit.support.version>3.8.0</mule.munit.support.version>
    <!-- This is the domain where the app will be 
    deployed: i.e. mydomain.cloudhub.io -->
    <cloudhub.domain>mydomain</cloudhub.domain>
</properties>

<build>
    <plugins>
    <plugin>
      <groupId>org.mule.tools.maven</groupId>
      <artifactId>mule-maven-plugin</artifactId>
      <version>2.1.1</version>
      <!-- <configuration>
            <deploymentType>standalone</deploymentType>
            <muleVersion>${mule.version}</muleVersion>
        </configuration> -->
        <configuration>
            <deploymentType>cloudhub</deploymentType>
            <muleVersion>3.8.2</muleVersion>
            <username>username</username>
            <password>mypassword</password>
             <applicationName>myapplication-maven-1.0</applicationName>
             <!-- <businessGroup>engineering\devops</businessGroup> -->
            <target>CloudHub</target>
            <!-- One of: server, serverGroup, cluster -->
            <domain>${cloudhub.domain}</domain>
            <targetType>server</targetType>
            <environment>DEVELOPMENT</environment>
        </configuration>
        <executions>
            <execution>
                <id>deploy</id>
                <phase>deploy</phase>
                <goals>
                    <goal>deploy</goal>
                </goals>
            </execution>
        </executions>
    </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>mappings/</directory>
                            </resource>
                        <resource>
                                <directory>src/main/api/</directory>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    <!-- <plugin>
            <groupId>com.mulesoft.munit.tools</groupId>
            <artifactId>munit-maven-plugin</artifactId>
            <version>${munit.version}</version>
            <executions>
                <execution>
                    <id>test</id>
                    <phase>test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <coverage>
                    <runCoverage>true</runCoverage>
                    <formats>
                        <format>html</format>
                    </formats>
                </coverage>
            </configuration>
        </plugin> -->
    </plugins>
    <testResources>
        <testResource>
            <directory>src/test/munit</directory>
        </testResource>
    <testResource>
            <directory>src/test/resources</directory>
        </testResource>
    </testResources>
</build>

<!-- Mule Dependencies -->
<dependencies>
    <!-- Xml configuration -->
    <dependency>
        <groupId>com.mulesoft.muleesb</groupId>
        <artifactId>mule-core-ee</artifactId>
        <version>${mule.version}</version>
        <scope>provided</scope>
    </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-http</artifactId>
        <version>${mule.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.mulesoft.muleesb.transports</groupId>
        <artifactId>mule-transport-jdbc-ee</artifactId>
        <version>${mule.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.mulesoft.muleesb.transports</groupId>
        <artifactId>mule-transport-jms-ee</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> -->
<dependency>
        <groupId>org.mule.modules</groupId>
        <artifactId>mule-module-apikit</artifactId>
        <version>${mule.version}</version>
        <scope>provided</scope>
    </dependency>
<!-- <dependency>
        <groupId>com.mulesoft.munit</groupId>
        <artifactId>mule-munit-support</artifactId>
        <version>${mule.munit.support.version}</version>
        <scope>test</scope>
    </dependency> -->
<!-- <dependency>
        <groupId>com.mulesoft.munit</groupId>
        <artifactId>munit-runner</artifactId>
        <version>${munit.version}</version>
        <scope>test</scope>
    </dependency> -->
<!-- <dependency>
    <groupId>org.mule.modules</groupId>
    <artifactId>mule-module-objectstore</artifactId>
    <version>${mule.version}</version>
</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>

我也看到这个警告:

[INFO] --- mule-app-maven-plugin:1.2:install (default-install) @myapplication ---[WARNING] MULE_HOME 未设置,不是复制 myapplication-1.0.0-SNAPSHOT.zip

请告诉我如何修复此错误。

谢谢

根据plugin documentation

This will also trigger the default deploy goal of the maven-deploy-plugin. If you are not deploying to a Maven repository as part of your build, you can prevent the plugin execution by using:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-deploy-plugin</artifactId>
  <configuration>
    <skip>true</skip>
  </configuration>
</plugin>

关于另一条消息,这是 mule-app-maven-plugin 的一项功能,它允许您将生成的工件复制到本地 Mule 服务器。如果您使用 mule-maven-plugin 部署您的应用程序,则不必担心。