16 Replies Latest reply on Oct 24, 2012 7:44 AM by cqlearner

    Maven plugin for managing CQ5 packages

    Scott Brodersen Adobe Employee

      Hi,

       

      Here's some new documentation that explains how to use the Content Package Maven plugin. You can package and install content from your maven build...for example, in your POM, add goals for package creation and installation to automatically deploy the OSGi bundle that was built. You can perform other package management tasks on remote servers, like rebuild packages,  and list, uninstall, and remove them.

       

      http://dev.day.com/docs/en/cq/current/core/how_to/how_to_use_the_vlttool/vlt-mavenplugin.h tml

       

      scott

        • 1. Re: Maven plugin for managing CQ5 packages
          Scott Brodersen Adobe Employee

          I added a section about embedding OSGi bundles in the conent package....scroll to the bottom (Embedding OSGi Bundles in a Content Package)

           

          thanks Justin

          • 2. Re: Maven plugin for managing CQ5 packages
            cqlearner

            When I build my pom as mvn content-package:build, I get following error:

             

            [ERROR] No plugin found for prefix 'content-package' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [

            local (C:\Users\gxoshre\.m2\repository), internal (http://localhost:9090/archiva/repository/internal/)] -> [Help 1]

             

            I have also uploaded the plug in as in my local Archiva:

             

            Repository      internal

            Group ID      com.day.jcr.vault

            Artifact ID      content-package-maven-plugin

            Version      0.0.18

            Packaging      maven-plugin

            POM Snippet

             

                <plugin>

                  <groupId>com.day.jcr.vault</groupId>

                  <artifactId>content-package-maven-plugin</artifactId>

                  <version>0.0.18</version>

                </plugin>

             

             

            Any pointers? Thanks in advance.

            • 3. Re: Maven plugin for managing CQ5 packages
              justin_at_adobe Adobe Employee

              cqlearner-

              It is more typical to attach the Content Package Maven plugin to the Maven lifecycle and then use 'mvn package'.

               

              If you want to use the plugin from the command line without prefix, you need to add the groupId com.day.jcr.vault to your settings.xml file. See http://maven.apache.org/settings.html#Plugin_Groups

               

              Regards,
              Justin

              • 4. Re: Maven plugin for managing CQ5 packages
                cqlearner Level 1

                Thank you so much for prompt reply!!

                I am new to this so I am bit confused.
                Would it be possible for you to check my pom file? And let me know if the configuration looks Ok?

                Command used: mvn clean package content-package:install -P felix-deploy

                Setting.xml
                -----------------

                <?xml version="1.0" encoding="UTF-8"?>

                <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"

                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

                    <pluginGroups>

                        <pluginGroup>content-package-maven-plugin</pluginGroup>

                    </pluginGroups>

                    <proxies />

                 

                    <servers>

                        <server>

                            <id>snapshots</id>

                            <username>cqadmin</username>

                            <password>internal1</password>

                        </server>

                        <server>

                            <id>internal</id>

                            <username>cqadmin</username>

                            <password>internal1</password>

                        </server>

                    </servers>

                    <mirrors>

                        <mirror>

                            <id>internal</id>

                            <url>http://localhost:9090/archiva/repository/internal/</url>

                            <mirrorOf>*</mirrorOf>

                        </mirror>

                    </mirrors>

                 

                    <profiles>

                        <profile>

                            <id>adobe-public</id>

                 

                            <activation>

                                <activeByDefault>false</activeByDefault>

                            </activation>

                 

                            <properties>

                                <releaseRepository-Id>adobe-public-releases</releaseRepository-Id>

                                <releaseRepository-Name>Adobe Public Releases</releaseRepository-Name>

                                <releaseRepository-URL>

                                    http://repo.adobe.com/nexus/content/groups/public/com/day/cq/wcm/cq-content/</releaseRepository-URL>

                            </properties>

                            <repositories>

                                <repository>

                                    <id>adobe-public-releases</id>

                                    <name>Adobe Public Repository</name>

                                    <url>http://repo.adobe.com/nexus/content/groups/public</url>

                                    <releases>

                                        <enabled>true</enabled>

                                        <updatePolicy>never</updatePolicy>

                                    </releases>

                                    <snapshots>

                                        <enabled>false</enabled>

                                    </snapshots>

                                </repository>

                            </repositories>

                 

                            <pluginRepositories>

                                <pluginRepository>

                                    <id>adobe-public-releases</id>

                                    <name>Adobe Public Repository</name>

                                    <url> http://repo.adobe.com/nexus/content/groups/public/com/day/cq/wcm/cq-content/</url>

                                    <releases>

                                        <enabled>true</enabled>

                                        <updatePolicy>never</updatePolicy>

                                    </releases>

                                    <snapshots>

                                        <enabled>false</enabled>

                                    </snapshots>

                                </pluginRepository>

                            </pluginRepositories>

                        </profile>

                    </profiles>

                </settings>

                 

                POM.xml

                -----------

                <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>common</groupId>

                    <artifactId>common-ui</artifactId>

                    <version>0.0.1</version>

                    <name>common-ui</name>

                    <properties>

                        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

                        <!-- timestamp property used when filtering files from META-INF path -->

                        <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss.SZ</maven.build.timestamp.format>

                        <timestamp>${maven.build.timestamp}</timestamp>

                        <cq5.package.group>Common UI</cq5.package.group>

                        <cq5.app.name>common-ui</cq5.app.name>

                    </properties>

                    <profiles>

                        <profile>

                            <id>felix-deploy</id>

                            <build>

                                <plugins>

                                    <plugin>

                                        <groupId>com.day.jcr.vault</groupId>

                                        <artifactId>content-package-maven-plugin</artifactId>

                                        <version>0.0.19</version>

                                        <configuration>

                                            <name>common-ui</name>

                                            <failOnError>true</failOnError>

                                            <packageFile>

                                                ${project.artifactId}-${project.version}-cq5-package.zip

                                            </packageFile>

                                            <targetURL>http://localhost:4502/crx/packmgr/service.jsp</targetURL>

                                        </configuration>

                                        <executions>

                                            <execution>

                                                <goals>

                                                    <goal>package</goal>

                                                </goals>

                                            </execution>

                                        </executions>

                                    </plugin>

                                </plugins>

                            </build>

                        </profile>

                    </profiles>

                    <build>

                        <plugins>

                            <plugin>

                                <!-- Assembly plugin used to make cq5 package zip file -->

                                <artifactId>maven-assembly-plugin</artifactId>

                                <version>2.3</version>

                                <configuration>

                                    <builtContentDirectory>jcr_root</builtContentDirectory>

                                    <targetURL>http://localhost:4502/crx/packmgr/service.jsp</targetURL>

                                </configuration>

                                <executions>

                                    <execution>

                                        <id>make-assembly</id>

                                        <phase>package</phase>

                                        <goals>

                                            <goal>single</goal>

                                        </goals>

                                    </execution>

                                </executions>

                            </plugin>

                        </plugins>

                        <resources>

                            <resource>

                                <directory>src/main/content</directory>

                                <includes>

                                    <include>**/*.*</include>

                                </includes>

                            </resource>

                        </resources>

                    </build>

                </project>

                 

                ERROR:

                C:\workspace-aaa-eris\wms-cms-common-ui>mvn clean package content-package:install -P felix-deploy

                [INFO] Scanning for projects...

                [WARNING] Failed to retrieve plugin descriptor for com.day.jcr.vault:content-package-maven-plugin:0.0.19: Invalid plugin descriptor for com.day.jcr.vault:content-package-maven-plug

                in:0.0.19  (C:\Users\gxoshre\.m2\repository\com\day\jcr\vault\content-package-maven-plugin\0.0.19\co ntent-package-maven-plugin-0.0.19.jar), Plugin's descriptor contains the wrong ve

                rsion: 0.0.16

                Downloading: http://localhost:9090/archiva/repository/internal/org/codehaus/mojo/maven-metadata.xml

                Downloading: http://localhost:9090/archiva/repository/internal/content-package-maven-plugin/maven-metad ata.xml

                Downloading: http://localhost:9090/archiva/repository/internal/org/apache/maven/plugins/maven-metadata. xml

                Downloaded: http://localhost:9090/archiva/repository/internal/org/apache/maven/plugins/maven-metadata. xml (11 KB at 0.7 KB/sec)

                Downloaded: http://localhost:9090/archiva/repository/internal/org/codehaus/mojo/maven-metadata.xml (21 KB at 1.4 KB/sec)

                [INFO] ------------------------------------------------------------------------

                [INFO] BUILD FAILURE

                [INFO] ------------------------------------------------------------------------

                [INFO] Total time: 15.148s

                [INFO] Finished at: Wed Oct 03 12:34:25 MST 2012

                [INFO] Final Memory: 4M/15M

                [INFO] ------------------------------------------------------------------------

                [ERROR] No plugin found for prefix 'content-package' in the current project and in the plugin groups [content-package-maven-plugin, org.apache.maven.plugins, org.codehaus.mojo] ava

                ilable from the repositories [local (C:\Users\gxoshre\.m2\repository), internal (http://localhost:9090/archiva/repository/internal/)] -> [Help 1]

                [ERROR]

                [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

                [ERROR] Re-run Maven using the -X switch to enable full debug logging.

                [ERROR]

                [ERROR] For more information about the errors and possible solutions, please read the following articles:

                [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException

                C:\workspace-aaa-eris\wms-cms-common-ui

                • 5. Re: Maven plugin for managing CQ5 packages
                  justin_at_adobe Adobe Employee

                  As I said, you need to add the groupId com.day.jcr.vault to your settings.xml file. See http://maven.apache.org/settings.html#Plugin_Groups

                   

                  I would recommend using the content-package-maven-plugin to build your project rather that just deploy it. I see you are using the assembly plugin now. This will work, but the content-package-maven-plugin is designed for this specific use case whereas the assembly plugin is a generalized tool.

                   

                  Check out http://dev.day.com/docs/en/cq/current/core/how_to/how_to_use_the_vlttool/vlt-mavenplugin.h tml#Using%20Archetypes%20To%20Generate%20CQ%20Projects for some sample project setups.

                  • 6. Re: Maven plugin for managing CQ5 packages
                    cqlearner Level 1

                    Hi Justin,

                     

                    I am still stuck

                     

                    I am following the documentation and couldn't even complete this section (http://dev.day.com/docs/en/cq/current/core/how_to/how_to_use_the_vlttool/vlt-mavenplugin.h tml#ls)

                     

                    When I run mvn content-package:ls I get this error:

                     

                    [ERROR] No plugin found for prefix 'content-package' in the current project and in the plugin groups [content-package-maven-plugin, com.day.jcr.vault, maven-assembly-plugin, org.ap

                    ache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\gxoshre\.m2\repository), internal (http://localhost:9090/archiva/repository/internal/)] -> [

                     

                    I have the plugin in local directory as well as in archiva:

                    C:\Documents and Settings\gxoe\.m2\repository\com\day\jcr\vault\content-package-maven-plugin\0.0.16\conten t-package-maven-plugin-0.0.16.jar

                     

                     

                    Repositoryinternal
                    Group IDcom.day.jcr.vault
                    Artifact IDcontent-package-maven-plugin
                    Version0.0.16
                    Packagingmaven-plugin

                    POM Snippet

                        <plugin> <groupId>com.day.jcr.vault</groupId> <artifactId>content-package-maven-plugin</artifactId> <version>0.0.16</version> </plugin> 
                    • 7. Re: Maven plugin for managing CQ5 packages
                      reusr1 Level 2

                      you may want to check out the maven archetype for cq on cqblueprints at

                      http://www.cqblueprints.com/xwiki/bin/view/BluePrints/TheCQProjectMaven+Archetype

                      for your project setup. There are subprojects for services, packages,

                      etc available. There is also a maven setup somewhere on the adobe site

                      available.

                       

                      Ruben

                      • 8. Re: Maven plugin for managing CQ5 packages
                        justin_at_adobe Adobe Employee

                        Hi,

                        content-package-maven-plugin and org.apache.maven.plugins are not groupIds and do not belong in the list of pluginGroups.

                         

                        If that doesn't resolve the issue, I don't know what it could be offhand. You may need to fully qualify the plugin:

                         

                        mvn com.day.jcr.vault:content-package-maven-plugin:ls

                         

                        Regards,
                        Justin

                        • 9. Re: Maven plugin for managing CQ5 packages
                          cqlearner Level 1

                          Finally figured it out. I had the configuration correctly but when I uploaded the "content-package-maven-plugin-0.0.16.jar" to archiva I didnot upload the .pom file. Everything works now !!  Special thanks to you.

                          • 10. Re: Maven plugin for managing CQ5 packages
                            cqlearner Level 1

                            Hi Justin,

                             

                            Can content-package-maven-plugin support multile targetURL deployment? I would like to deploy the zip file to author and publish instance at the same time.

                             

                            <plugin>

                                            <groupId>com.day.jcr.vault</groupId>

                                            <artifactId>content-package-maven-plugin</artifactId>

                                            <version>0.0.19</version>

                                            <configuration>

                                                <name>test</name>

                                                <failOnError>true</failOnError>

                                                <filterSource>

                                                    src/main/content/META-INF/vault/filter.xml

                                                </filterSource>

                                               <targetURL>http://localhost:4502/crx/packmgr/service.jsp</targetURL>

                                            </configuration>

                                             <executions>

                                                <execution>

                                                    <goals>

                                                        <goal>package</goal>

                                                    </goals>

                                                </execution>

                                            </executions>

                                        </plugin>

                            • 11. Re: Maven plugin for managing CQ5 packages
                              justin_at_adobe Adobe Employee

                              You need to define multiple executions of the plugin.

                              • 12. Re: Maven plugin for managing CQ5 packages
                                cqlearner Level 1

                                Sorry I am new to maven, do you have example?  I tried following and it only executed 1st one.

                                 

                                Thanks in advance

                                 

                                <plugins>

                                            <plugin>

                                                <groupId>com.day.jcr.vault</groupId>

                                                <artifactId>content-package-maven-plugin</artifactId>

                                                <version>0.0.19</version>

                                                <executions>

                                                    <execution>

                                                        <goals>

                                                            <goal>package</goal>

                                                        </goals>

                                                        <configuration>

                                                            <name>b2c-ui</name>

                                                            <failOnError>true</failOnError>

                                                            <filterSource>

                                                                src/main/content/META-INF/vault/filter.xml

                                                            </filterSource>

                                                           <targetURL>http://localhost:4502/crx/packmgr/service.jsp</targetURL>

                                                        </configuration>

                                                    </execution>

                                                    <execution>

                                                        <goals>

                                                            <goal>package</goal>

                                                        </goals>

                                                        <configuration>

                                                            <name>b2c-ui</name>

                                                            <failOnError>true</failOnError>

                                                            <filterSource>

                                                                src/main/content/META-INF/vault/filter.xml

                                                            </filterSource>

                                                           <targetURL>http://localhost:4503/crx/packmgr/service.jsp</targetURL>

                                                        </configuration>

                                                    </execution>

                                                </executions>

                                            </plugin>

                                        </plugins>

                                • 14. Re: Maven plugin for managing CQ5 packages
                                  cqlearner Level 1

                                  Thank you for the prompt respose.

                                   

                                  I did what you suggested following the link you provided but it only executes once.

                                   

                                  >mvn clean package content-package:install

                                   

                                  <plugin>

                                                  <groupId>com.day.jcr.vault</groupId>

                                                  <artifactId>content-package-maven-plugin</artifactId>

                                                  <version>0.0.19</version>

                                                  <executions>

                                                      <execution>

                                                      <id>execution1</id>

                                                       <phase>package</phase>

                                                          <goals>

                                                              <goal>package</goal>

                                                          </goals>

                                                          <configuration>

                                                              <name>b2c-ui</name>

                                                              <failOnError>true</failOnError>

                                                              <filterSource>

                                                                  src/main/content/META-INF/vault/filter.xml

                                                              </filterSource>

                                                              <targetURL>http://localhost:4502/crx/packmgr/service.jsp</targetURL>

                                                          </configuration>

                                                      </execution>

                                                      <execution>

                                                       <id>execution2</id>

                                                        <phase>package</phase>

                                                          <goals>

                                                              <goal>package</goal>

                                                          </goals>

                                                          <configuration>

                                                              <name>b2c-ui</name>

                                                              <failOnError>true</failOnError>

                                                              <filterSource>

                                                                  src/main/content/META-INF/vault/filter.xml

                                                              </filterSource>

                                                              <targetURL>http://localhost:4503/crx/packmgr/service.jsp</targetURL>

                                                          </configuration>

                                                      </execution>

                                                  </executions>

                                              </plugin>

                                  • 15. Re: Maven plugin for managing CQ5 packages
                                    justin_at_adobe Adobe Employee

                                    What the configuration above says is that during the package phase, execute the package goal twice.

                                     

                                    In general, you would be best served by binding the install goal of the content-package-maven-plugin to the install phase and then executing

                                    mvn clean install

                                     

                                    I actually prefer to do this with profiles. See https://gist.github.com/3942776 for an example syntax.

                                     

                                    Using this, if I want to install just to author, I do

                                    mvn -PautoInstallPackageAuthor clean install

                                     

                                    Just publish:

                                    mvn -PautoInstallPackagePublish clean install

                                     

                                    Both:

                                    mvn -PautoInstallPackageAuthor,autoInstallPackagePublish clean install

                                    • 16. Re: Maven plugin for managing CQ5 packages
                                      cqlearner Level 1

                                      Awesome!! Thanks so much.