cancel
Showing results for 
Search instead for 
Did you mean: 

Maven 4 Alfresco

rdanner
Champ in-the-making
Champ in-the-making
At the end of last week we added a Forge Project for Maven Integration with Alfresco.

A plugin is now available that will build an Alfresco AMP file for you in a similar fashion to the way Maven will build a WAR file.  If you're interested, you may download the plug-in here.  http://forge.alfresco.com/frs/download.php/302/alfresco-maven-amp-plugin-1.0.0-RC1.zip

For those not familiar with AMP files, they are the standard way for packaging and deploying custom functionality for Alfresco.  AMP stands for Alfresco Module Package.

This is an example POM file for an AMP project


<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.alfresco.maven.plugins.test</groupId>
  <artifactId>amp-packaging-test</artifactId>
  <packaging>amp</packaging>
  <name>Maven Alfresco AMP Packaging Type Test</name>
  <version>1.0-0</version>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.alfresco.maven.plugin</groupId>
        <artifactId>maven-amp-plugin</artifactId>
        <extensions>true</extensions>
      </plugin>
    </plugins>
  </build>

  <dependencies>

     <!– need to list these as a provided so that Maven doesn't download them
          and include them in the AMP, they are provided by the Alfresco application
     –>
 
    <dependency>
      <groupId>alfresco</groupId>
      <artifactId>repository</artifactId>
      <version>2.1</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring</artifactId>
      <version>2.0.2</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
</project>
11 REPLIES 11

paulhh
Champ in-the-making
Champ in-the-making
Great work, Russ! 

Cheers
Paul.

mindthegab
Champ in-the-making
Champ in-the-making
Hi,
I'm already using maven in a big alfresco project and I created a project on the forge for accomplishing that task (actually with a POM very similar to yours).

Maybe you want to join and contribute to:

http://forge.alfresco.com/projects/m2alfresco/

Shall we merge this two projects? Considering also that:

1. At the moment I'm build with plain mvn war:war with an ad-hoc pom and overlaying my extension with the alfresco war (default behaviour for a war artifact with a war dependency)
2. we have a mvn assembly draft configuration to produce AMP like structure (it seems you address this step with you plugin)
3. I would like to write a maven-alfresco-plugin which basically wraps Module management tool to deploy extensions also to external wars (this can be an extension)
4. Write an archetype to generate extensions skeletons

The fact is:
I would like in the end to have alfresco itself modularized with maven (say different artifact per module, e.g. alfresco-repository and alfresco-webclient separata), and in this sense our effort is really important. But we need some validation from Alfresco if this is the way they also envision, in order to have a proper support for this approach (e.g. release of alfresco artifacts on public maven repos, because now i'm building with privately deployed artifacts).

I did not have time to look at the plugin code, but maybe it already covers a lot of what we need. Let join our efforts, as soon as I get permission from my customer, I'll post my results and we can merge it.

How do you see this?

rdanner
Champ in-the-making
Champ in-the-making
Hi,
I'm already using maven in a big alfresco project and I created a project on the forge for accomplishing that task (actually with a POM very similar to yours).

Maybe you want to join and contribute to:

http://forge.alfresco.com/projects/m2alfresco/

Shall we merge this two projects? Considering also that:

1. At the moment I'm build with plain mvn war:war with an ad-hoc pom and overlaying my extension with the alfresco war (default behaviour for a war artifact with a war dependency)
2. we have a mvn assembly draft configuration to produce AMP like structure (it seems you address this step with you plugin)
3. I would like to write a maven-alfresco-plugin which basically wraps Module management tool to deploy extensions also to external wars (this can be an extension)
4. Write an archetype to generate extensions skeletons

The fact is:
I would like in the end to have alfresco itself modularized with maven (say different artifact per module, e.g. alfresco-repository and alfresco-webclient separata), and in this sense our effort is really important. But we need some validation from Alfresco if this is the way they also envision, in order to have a proper support for this approach (e.g. release of alfresco artifacts on public maven repos, because now i'm building with privately deployed artifacts).

I did not have time to look at the plugin code, but maybe it already covers a lot of what we need. Let join our efforts, as soon as I get permission from my customer, I'll post my results and we can merge it.

How do you see this?

Awesome! I didn't mean to duplicate work – I track the forge and forums pretty closely but I missed that project some how.  I'll check out what you have – we should converge things if they are doing the same thing Smiley Wink

Thanks!

mindthegab
Champ in-the-making
Champ in-the-making
Ciao Russ,
as I wrote also in the maven4alfresco forum,
and in case you're still working on it/project is still active/Alfresco can be interested,
we shoud definitely try to merge the efforts.

I see that you're more focused on the AMP part, for which you've released a initial plugin,
while on my side I have a working pom for building extensions against a remote Sourcesense (my company, alfresco gold partners) repository and
manage the whole application lifecycle.

Release is in the forge http://forge.alfresco.com/frs/?group_id=90,
but more info can be found also be found in the documentation website:

http://repository.sourcesense.com/maven2-sites/maven-alfresco-extension-archetype-1.0.0/

The repository we use to support that contains of course only community (redistributable) artifacts, but we use it also with our clients for enterprise builds using a private Sourcesense/client repository with enterprise artifacts: it's such a clean way to keep your code manageable and separate from alfresco deps, I think Alfresco should really evaluate it to me.

But I'm hopeful to get very exciting news in the Barcelona conference, considering rumors of a refactoring of all Alfresco public community model.

As I was thinking of releasing another archetype for building AMP, this could either use assembly (guess it would be nice) or use your plugin, which honestly seems to me too much effort considering that an AMP is just a non standard format (call me pragmatic but to me it should be a jar with some opensource library for reading jsp and resources from inside them, as the rest is all classpath).

WDYT? Any time to spend on it?


Ciao and hope to hear from you soon?

Gabriele

PS:
Will you be in Barcelona at on the 22nd?

mindthegab
Champ in-the-making
Champ in-the-making
To the spare readers of this thread, the full Maven Lifecycle support for Alfresco, based on the conjoined efforts of Maven4Alfresco and m2Alfresco is now documented here:

http://wiki.alfresco.com/wiki/Managing_Alfresco_Lifecyle_with_Maven

and hosted on Google Code :

http://code.google.com/p/maven-alfresco-archetypes/

Have fun and let us know how it goes Smiley Happy

anttis
Champ in-the-making
Champ in-the-making
Hi,

we are building Alfresco - Mule integration in our company (Alfresco java services published via mule) on top of maven-alfresco-amp-archetype. Some things occured:

- We want to build test cases in the same maven amp project (and I guess this is common interest..), but the project/archetype/packaging doesn't seem to support tests (src/test/java). Have we missed something? If not, could something be done with this? We can also contribute on this.

- Dependencies didn't seem to contain config files such as application-context.xml. This also relates to building tests. We need to built tests where alfresco repository is started embedded in the test case..

- Dependencies also didn't seem to contain for example org.alfresco.error.* classes (for example ..AlfrescoRuntimeException)


Antti Salonen
Proactum Oy

mindthegab
Champ in-the-making
Champ in-the-making
Hi Antti,
first of all thanks for the interest in the amp plugin. And for the contributions that you suggest, which I think they make really sense.

My answers interleaved:

> - We want to build test cases in the same maven amp project (and I guess this is common interest..), but the project/archetype/packaging doesn't seem to support tests
>  (src/test/java). Have we missed something? If not, could something be done with this? We can also contribute on this.

I think this is due to the fact that I did not map the <test> phase in the 'amp' artifact packaging type as you can see here [1] in the maven-amp-plugin definition.
I just committed in the last revision in which I add the test phase, you may want to build the trunk and produce a snapshot version before new release.
Provided that I want to move the amp-plugin to Google Code as well (maven4alfresco people are not really answering and there's no activity but mine), when this is done I can do the next release of the maven support.

- Dependencies didn't seem to contain config files such as application-context.xml. This also relates to building tests. We need to built tests where alfresco repository is started embedded in the test case..

Well, dependencies don't ship application-context.xml files because in Alfresco they are not in the JARs while just in the WEB-INF/classes of the WAR file. I believe you could reconfigure the surefire plugin (which I just added to lifecycle as I mentioned above) to point to target/${webapp.name}/WEB-INF/classes (if you need to use Alfresco original default contexts), or add specific src/test/resources/alfresco/* application contexts in order them to put up alfresco embedded.

- Dependencies also didn't seem to contain for example org.alfresco.error.* classes (for example ..AlfrescoRuntimeException)

Did you all alfresco-*.jar dependencies you find the public repo here [2] (for 2.2) or here [3] (for 3.0, I'm migrating to better repo layout using dependency <classifier> tag?

To conclude, I really appreciate your striving for contribution: I warmly suggest you subscribe to the Google Code project [4] and continue this discussion either here on the forum or in the mailing list we set up of the project [5].

Thanks again for the feedback!

Gabriele


[1] https://forge.alfresco.com/plugins/scmsvn/viewcvs.php/amp-plugin/branches/2.0.0/src/main/resources/M...
view=markup
[2] http://repository.sourcesense.com/maven2/alfresco/community/
[3] http://repository.sourcesense.com/maven2/org/alfresco/
[4] http://code.google.com/p/maven-alfresco-archetypes/
[5] http://groups.google.com/group/maven-alfresco

anttis
Champ in-the-making
Champ in-the-making
I'll write a short reply because I'm quite busy right now..

Thanks for fast answer and amp-plugin modification.

You have to also add test-compile phase (I did it locally already).

About org.alfresco.error -package.. I just didn't realize there was alfresco-core dependecy in your repository, I added it and also mbeans.

I had to make manually few dependecies (did it locally) to get tests to work..
-I made a 40meg alfresco-3rd-party-dependecies.jar out of every non-alfresco jar in alfresco webapps lib. Note that adding each dependencies separately might actually not be a good idea, because the classpath must be quite identical to webapp. But of course if and when alfresco moves to maven build the situation is different.
- I added config.jar from Alfresco 2.1 SDK to dependencies
- Also added alfresco-linkvalidation and -deployment deps

Also had to make minor changes to config files to get Alfresco start embedded in my testcase with hsqldb.

But now I have testcases compiling and running with embedded alfresco in maven, and even exposing services via mule seems to work Smiley Happy

-antti

mindthegab
Champ in-the-making
Champ in-the-making
All the Maven efforts around Alfresco are now consolidated on the new Maven Alfresco Community Repository http://maven.alfresco.com and particularly in the project Maven Alfresco Lifecycle http://wiki.alfresco.com/wiki/Managing_Alfresco_Lifecyle_with_Maven. It features archetypes for AMPs, Repository Extensions and Share Web Extensions  http://wiki.alfresco.com/wiki/Managing_Alfresco_Lifecyle_with_Maven#NEW.21.21.21_How_to_manage_Alfre....

Full documentation to be found here http://maven.alfresco.com/nexus/content/repositories/alfresco-docs/maven-alfresco-lifecycle/index.ht....