Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How to include a core module package from one site in another site's core module?

Avatar

Level 2

I have an AEM project where a certain component uses the following Java class: /core/src/main/java/com/mysite/core/util/MyClass.java.

 

I also have a different site that uses a separate AEM Project Archetype. I would like to use MyClass.java in the core module of the second site, however I'm not sure how to go about adding the dependency. Is there any documentation on this?  

1 Accepted Solution

Avatar

Correct answer by
Level 6

Add a dependency in your core pom of your second site. Something like this:

<dependency>

    <groupId>com.myproject</groupId>

    <artifactId>common-code</artifactId>

    <version>1.0.0</version>

</dependency>

 

The artifactId and groupId should be same as you have defined in your project(first site).

 

Then you can use it in your HTL pretty much same way how you would use when you call it in the same project.

 

May be you can refer this link for more details: https://stackoverflow.com/questions/15383322/how-do-i-add-a-project-as-a-dependency-of-another-proje...

View solution in original post

3 Replies

Avatar

Correct answer by
Level 6

Add a dependency in your core pom of your second site. Something like this:

<dependency>

    <groupId>com.myproject</groupId>

    <artifactId>common-code</artifactId>

    <version>1.0.0</version>

</dependency>

 

The artifactId and groupId should be same as you have defined in your project(first site).

 

Then you can use it in your HTL pretty much same way how you would use when you call it in the same project.

 

May be you can refer this link for more details: https://stackoverflow.com/questions/15383322/how-do-i-add-a-project-as-a-dependency-of-another-proje...

Avatar

Employee Advisor

hi @nydel09 ,

The solution mentioned my @ibishika is perfect, although when you implement these and do deployments - you need to take care of deployment sequence (deploying common code before dependent code) and also since you are using specific version in POM you need to keep updating it with every release.

This sounds like a minor challenge with only one project dependent on another, however when you have multiple projects interdependent on each other - versioning and sequential deployments are going to be an hassle.

thanks.


Avatar

Level 4

Add a dependency in second site so after module compilation classes get availble for use.