cancel
Showing results for 
Search instead for 
Did you mean: 

How to use custom WAR with Maven SDK 2.0

iblanco
Confirmed Champ
Confirmed Champ
Hello everyone,

I'm investing some time in reading and making some tests with the newish development approach introduced with Maven SDK 2.0.

I have created a new customization project using the all-in-one archetype and it works ok but I can't figure out how to use my own Alfresco 5.0.c WAR file instead of the vanilla one.

I've seen this excerpt in repo-amp's pom file:


    <properties>
        <!– Defines the target WAR artifactId to run this amp, only used with the -Pamp-to-war switch
        .    | Allowed values: alfresco | share. Defaults to a repository AMP, but could point to your custom corporate Alfresco WAR –>
        <alfresco.client.war>alfresco</alfresco.client.war>
    </properties>


So it seems to be possible but not sure how to achieve it, I've tried changing that value for a random text to see if it made any change in the run process but to no avail.

Is it possible at all?
4 REPLIES 4

gravitonian
Star Collaborator
Star Collaborator
Hi,

Not sure I understand the question completely, but anyway, when you run the build as follows for example:

$ mvn install -Prun


This will build a custom alfresco.war including any AMPs that your repo/pom.xml brings in, from the logs:


Assembling webapp [repo] in [/home/martin/src/alfresco-sdk-temp/all-in-one-test/repo/target/repo]
[INFO] Processing war project
[INFO] Processing overlay [ id org.alfresco:alfresco]
[INFO] Processing overlay [ id org.alfresco:repo-amp]


And this custom alfresco.war will be deployed by the embedded Tomcat instance.

Let me know if this helps.

Hi Martin,

First of all thanks for you answer. I'll try to make it clearer because that is not what I'm trying to achieve.

We maintain our own Alfresco code repository so that we can apply patches to the official code. We use git for our repo an a "Vendor Branch" strategy for this in case you are curious about it: http://happygiraffe.net/blog/2008/02/07/vendor-branches-in-git/.

We do this when we discover a bug and we patch it or backport the solution from a newer community version to an older one. Of course if we are the ones that find the error and the possible patch we also report it in issues.alfresco.com but we backport it in our code repository.

So we have our own alfresco.war and share.war and I want to use them, not the vanilla alfresco WARs. I suspect that might be something trivial but I'm still a newbie with Maven and the new SDK and I don't manage to figure it out how to do it.

I've installed my own Nexus repository and even tried mangling the routes to overlay Alfresco's official artifacts with my own but it really seems a very unclean and awful idea to do so.

Thanks.

gravitonian
Star Collaborator
Star Collaborator
Hi,

I see what you mean now. What you need is probably to setup your internal (on premise) Nexus server as a mirror for external repositories. You can configure Maven to use a mirror for Maven central repository, Alfresco Nexus etc. And this will redirect all requests that would normally go to these repos to your internal repository.

In your settings.xml you would add something like the following to set your internal repository as as mirror for external repositories:


<mirrors>
  <mirror>
    <id>mycompany-nexus</id>
    <name>My companies mirror of external repos</name>
    <url>http://path/to/my/repository</url>
    <mirrorOf>*</mirrorOf>
  </mirror>
</mirrors>


You can then setup your internal Nexus repository as a proxy repository for Maven central, Alfresco Nexus etc. So any requests for artifacts not yet in your internal repo would first go to these repos, and subsequent requests are fetched from the internal repository.

Another way is if you are using Maven's release plugin you have the opportunity to use any tagging naming convention you like. So everytime you do mvn prepare and release you could tag the release in such a way so it would not clash with Alfresco's version numbers. Such as for example (in top pom):


<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-release-plugin</artifactId>
  <version>2.5.1</version>
  <configuration>
  <tagNameFormat>@{project.version}-mycompany</tagNameFormat>
  </configuration>
</plugin>


Then specify Alfresco version to bring in as follows:


<alfresco.version>5.0.d-mycompany</alfresco.version>


You would then not have to use the mirroring stuff above.

Thanks Martin, I already have my own Nexus repo up and running but the idea of "shadowing" official packages make me feel uncomfortable so I'll try to work on your second idea and try to publish my own alfresco artifacts with a differente version name.

Thank you very much.