Use CQ5 as maven repository

Use a local CQ5 instance as a maven repository source for development, instead of using Day maven repository.

Примечание.

This method isn't officially supported.

Solution

  1. Install the cq5-archiva-servlet-1.6.zip. (It may fail to load on CQ 5.2.1, but ignore the message then install.)

  2. Configure your project pom.xml to use your local CQ5 instance as a maven repository

    <repositories>
            <repository>
                <id>localinstance</id>
                <name>CQ 5.x localinstance</name>
                <url>http://localhost:4502/maven/repository</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
     </repositories>
     <pluginRepositories>
            <pluginRepository>
                <id>localinstance</id>
                <name>CQ 5.x localinstance</name>
                <url>http://localhost:4502/maven/repository</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </pluginRepository>
     </pluginRepositories>

     

  3. Additionally, you can use as parent dependency the following:

        <parent>
            <groupId>com.day</groupId>
            <artifactId>cq5-parent</artifactId>
            <version>5.6.0</version> (if for example your instance is a 5.6.0)
        </parent>

    The groupId/artifactId is configurable with Sling configuration, and the version is not important. (But make sense to use according to target, such as 5.2.1/5.3/5.4).

  4. In your .m2/settings.xml, add the following lines to define the login/password:

    <server>
          <id>localinstance</id>
          <username>admin</username>
          <password>admin</password>
    </server>

  5. Additionally, you can add your jar/pom in the "/var/maven/repository" (using same structure as maven store it usually)

    Notes:

    • You can't really browse through the maven repository with your browser with that servlet, it returns a valid response at the moment.
    • Additional libraries like maven-sling-plugin and maven-packutil-plugin are also already present so accessing day repo is not required for them anymore.
    • The "/var/maven/tpl/archiva-parent.pom" includes apache people repository and ibliblio mirror automatically so that other dependencies can be found there, you can customize it if necessary.
    • You can also get a generated pom file that includes all the existing dependencies so you can easily copy/paste those you need for your maven module if you don't want to use the above parent dependency. For example using the URL: http://localhost:4502/maven/dependencies.
    • You can use a maven archive as proxy so that if your cq5 instance is not running, it can still serve the files.

Quick help for the maven-packutil-plugin (which is not currently an official plug-in, but useful)

<plugin>
 <groupId>com.day.cq.tools</groupId>
 <artifactId>maven-packutil-plugin</artifactId>
 <version>0.0.1</version>
 <configuration>
   <targetURL>http://localhost:4502</targetURL>
   <user>admin</user>
   <password>admin</password>
   <workspace>crx.default</workspace>
 </configuration>
 <executions>
   <execution>
    <id>install-package</id>
    <goals>
      <goal>install</goal>
    </goals>
   </execution>
 </executions>
</plugin>

Загрузить

Загрузить

 Adobe

Получайте помощь быстрее и проще

Новый пользователь?

Adobe MAX 2024

Adobe MAX
— творческая конференция

С 14 по 16 октября очно в Майами-Бич и онлайн

Adobe MAX

Творческая конференция

С 14 по 16 октября очно в Майами-Бич и онлайн

Adobe MAX 2024

Adobe MAX
— творческая конференция

С 14 по 16 октября очно в Майами-Бич и онлайн

Adobe MAX

Творческая конференция

С 14 по 16 октября очно в Майами-Бич и онлайн