Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

mvn clean install -PautoInstallPackage

Avatar

Level 1

Does "mvn clean install -PautoInstallPackage" installs both package and bundle. If not, can I deploy both package and bundle in single command?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 9

Hi @PranavJoshi , please refer the various commands to deploy either bundle or package, or both at time in below document

 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/maven-commands-for-aem-aem...

View solution in original post

4 Replies

Avatar

Level 5

@PranavJoshi 

Yes "mvn clean install -PautoInstallPackage" command installs both package and bundle 

Avatar

Community Advisor

@PranavJoshi  Ideally mvn  -PautoInstallPackage clean install should work. If not try below command 

 

mvn  -PautoInstallPackage -PautoInstallBundle clean install 

Avatar

Correct answer by
Level 9

Hi @PranavJoshi , please refer the various commands to deploy either bundle or package, or both at time in below document

 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/maven-commands-for-aem-aem...

Avatar

Level 9

Hi @PranavJoshi ,

The command mvn clean install -PautoInstallPackage typically builds and installs the AEM package defined in your Maven project into the AEM instance. However, it does not directly handle the deployment of OSGi bundles.

To deploy both an AEM package and OSGi bundles in a single command, you would typically use a tool like Apache Felix File Install, Apache Sling Installer, or Apache Karaf, which can monitor a folder for changes and automatically deploy bundles placed in that folder.

However, if you want to automate the deployment of both the AEM package and OSGi bundles through Maven, you can achieve this by configuring Maven to execute additional deployment steps after installing the package.

Here's a rough example of how you might extend your Maven build to deploy both the package and bundles:

 

<project>
  ...
  <build>
    ...
    <plugins>
      ...
      <!-- Maven Sling Plugin to deploy bundles -->
      <plugin>
        <groupId>org.apache.sling</groupId>
        <artifactId>maven-sling-plugin</artifactId>
        <version>${maven.sling.plugin.version}</version>
        <executions>
          <execution>
            <id>install-bundles</id>
            <goals>
              <goal>install</goal>
            </goals>
            <configuration>
              <bundles>
                <!-- Define your OSGi bundles to deploy -->
                <bundle>
                  <artifactId>your-bundle-artifact-id</artifactId>
                  <groupId>your-bundle-group-id</groupId>
                  <version>your-bundle-version</version>
                  <!-- Optionally, specify start-level, start, and fragment attributes -->
                </bundle>
                <!-- Add more bundle elements for additional bundles -->
              </bundles>
              <startBundles>true</startBundles>
            </configuration>
          </execution>
        </executions>
      </plugin>
      ...
    </plugins>
  </build>
</project>

 

With this configuration, when you run mvn clean install -PautoInstallPackage, Maven will first build and install the AEM package. Then, it will execute the install-bundles execution of the Maven Sling Plugin, which will deploy the specified OSGi bundles to the AEM instance.

Please note that you need to replace your-bundle-artifact-id, your-bundle-group-id, and your-bundle-version with the actual artifact ID, group ID, and version of your OSGi bundles.

This approach allows you to automate the deployment of both AEM packages and OSGi bundles with a single Maven command.