cancel
Showing results for 
Search instead for 
Did you mean: 

Package java backed webscript as JAR instead of AMP file

aditya_chaudhar
Champ on-the-rise
Champ on-the-rise
Hi ALl,
I have written simple java backed webscript using maven following below tut
http://www.dedunu.info/2015/03/alfresco-how-to-write-simple-java-based.html

However i test using AMP and it works good.
But , to be more loosely coupled i need to package repository customization in JAR file using maven .
below is my POM file

<?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>com.alfrescoblog</groupId>
    <artifactId>alfrescoblogrepoarch</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>alfrescoblogrepoarch AMP project</name>
    <packaging>amp</packaging>
    <description>Manages the lifecycle of the alfrescoblogrepoarch AMP (Alfresco Module Package)</description>

    <parent>
        <groupId>org.alfresco.maven</groupId>
        <artifactId>alfresco-sdk-parent</artifactId>
        <version>1.1.1</version>
    </parent>

    <!–
       | SDK properties have sensible defaults in the SDK parent,
       | but you can override the properties below to use another version.
       | For more available properties see the alfresco-sdk-parent POM.
       –>
    <properties>
        <!– Defines the alfresco edition to compile against. Allowed values are [org.alfresco|org.alfresco.enterprise]–>
        <alfresco.groupId>org.alfresco</alfresco.groupId>
        <!– Defines the alfresco version to compile against –>
        <alfresco.version>4.2.e</alfresco.version>
        <app.log.root.level>WARN</app.log.root.level>
        <alfresco.data.location>alf_data_dev</alfresco.data.location>
        <!– 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 foundation WAR –>
        <alfresco.client.war>alfresco</alfresco.client.war>
        <!– Defines the target WAR groupId to run this amp, only used with the -Pamp-to-war switch
        .    | Could be org.alfresco | org.alfresco.enterprise or your corporate groupId –>
        <alfresco.client.war.groupId>org.alfresco</alfresco.client.war.groupId>
        <!– Defines the target WAR version to run this amp, only used with the -Pamp-to-war switch –>
        <alfresco.client.war.version>4.2.e</alfresco.client.war.version>
        <!– This controls which properties will be picked in src/test/properties for embedded run –>
        <env>local</env>
    </properties>

    <!– Here we realize the connection with the Alfresco selected platform
        (e.g.version and edition) –>
    <dependencyManagement>
        <dependencies>
            <!– This will import the dependencyManagement for all artifacts in the selected Alfresco version/edition
                (see http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Depe...)
                NOTE: You still need to define dependencies in your POM, but you can omit version as it's enforced by this dependencyManagement. NOTE: It defaults
                to the latest version this SDK pom has been tested with, but alfresco version can/should be overridden in your project's pom –>
            <dependency>
                <groupId>${alfresco.groupId}</groupId>
                <artifactId>alfresco-platform-distribution</artifactId>
                <version>${alfresco.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <!– Following dependencies are needed for compiling Java code in src/main/java;
         <scope>provided</scope> is inherited for each of the following;
         for more info, please refer to alfresco-platform-distribution POM –>
    <dependencies>
        <dependency>
            <groupId>${alfresco.groupId}</groupId>
            <artifactId>alfresco-repository</artifactId>
        </dependency>
        <!– Test dependencies –>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <!– This repository is only needed to retrieve Alfresco parent POM.
        NOTE: This can be removed when/if Alfresco will be on Maven Central
       
        NOTE: The repository to be used for Alfresco Enterprise artifacts is
        https://artifacts.alfresco.com/nexus/content/groups/private/. Please check
        with Alfresco Support to get credentials to add to your ~/.m2/settings.xml
        if you are a Enterprise customer or Partner 
        –>
    <repositories>
        <repository>
            <id>alfresco-public</id>
            <url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
        </repository>
        <repository>
            <id>alfresco-public-snapshots</id>
            <url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>daily</updatePolicy>
            </snapshots>
        </repository>
    </repositories>
    <build>
       <pluginManagement>
          <plugins>
             <!–This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.–>
             <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                   <lifecycleMappingMetadata>
                      <pluginExecutions>
                         <pluginExecution>
                            <pluginExecutionFilter>
                               <groupId>
                                  org.alfresco.maven.plugin
                               </groupId>
                               <artifactId>
                                  alfresco-maven-plugin
                               </artifactId>
                               <versionRange>
                                  [1.1.1,)
                               </versionRange>
                               <goals>
                                  <goal>set-version</goal>
                               </goals>
                            </pluginExecutionFilter>
                            <action>
                               <ignore></ignore>
                            </action>
                         </pluginExecution>
                      </pluginExecutions>
                   </lifecycleMappingMetadata>
                </configuration>
             </plugin>
          </plugins>
       </pluginManagement>
    </build>
</project>



is it possible as we package in AMP to create JAR  for repository customization using maven?

Please help me hoe can i achieve this also please let me know if you required any other information is needed.
5 REPLIES 5

malliswar
Champ in-the-making
Champ in-the-making
hii aditya_chaudhari,

                       i am not able understand what you are asking for
but you can do customizations and add extra modules to alfresco by packaging java-backed webscripts as a jar


here is a link that i think will help you –

http://aboutalfresco.blogspot.in/2010/07/java-backed-web-scripts.html

HI mailliswar ,
Thank you fro your reply,

I gone through URL you mentioned in that ANT build tool is used.
however i want to know how can i export project in JAR extension instead of AMP which is developed in eclipse using maven.


there is some information is given in below link
http://www.marversolutions.com/wordpress/2015/01/28/alfresco5-maven-sdk-2/
but i am not able to understand which changes are needed to do in POM.xml.

Please let me know if anyone needs more information.

Hi,

If you want to package your Web Script as a JAR you can pretty much copy this project from the article you refer to:

https://github.com/gravitonian/alfresco-maven-sdk2-test/tree/master/component-a-repo-jar

It actually has a Web Script already that us Java-backed so you can see where different things go.

Thanks for this thread, I am trying to build uploader-plus (by Paolo: https://github.com/softwareloop/uploader-plus ) as a jar and trying to use your pom.xml.

It capture javabased classess but skip all other customization under "config" folder.
Here is my pom.xml. please let me know if i am missing anything. I have copied dependencis from the uploader-plus's pom.xml to your suggested file.

thanks
sumit

<blockcode>
<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>com.softwareloop</groupId>
<artifactId>uploader-plus-repo</artifactId>

<packaging>jar</packaging>
<name>uploader-plus-repo</name>
<description>This is a sample Alfresco Repo JAR extension called Component A</description>

<!– Setup the parent extension project, which contain all the Alfresco Maven SDK stuff –>
    <parent>
        <groupId>com.softwareloop</groupId>
        <artifactId>uploader-plus</artifactId>
        <version>1.4</version>
    </parent>

   
     <properties>
        <!– The following are default values for data location and Alfresco Community version.
             Uncomment if you need to change (Note. current default version for Enterprise edition is 5.1)
          <alfresco.version>5.1.e</alfresco.version>
          <alfresco.data.location>/absolute/path/to/alf_data_dev</alfresco.data.location> –>

        <!– This control the root logging level for all apps uncomment and change, defaults to WARN
            <app.log.root.level>WARN</app.log.root.level>
        –>


        <!– Set the enviroment to use, this controls which properties will be picked in src/test/properties
             for embedded run, defaults to the 'local' environment. See SDK Parent POM for more info.
        <env>local</env>
        –>
    </properties>
     <dependencyManagement>
        <dependencies>
            <!– Setup what versions of the different Alfresco artifacts that will be used (depends on alfresco.version),
                 so we don't have to specify version in any of the dependency definitions in our POM.
                 For more info see:
                    http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Depe...
            –>
            <dependency>
                <groupId>${alfresco.groupId}</groupId>
                <artifactId>alfresco-platform-distribution</artifactId>
                <version>${alfresco.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>  
   
<dependencies>
<!– Bring in the Spring Surf framework so we can compile the Web Script's Java controller,
alfresco-platform-distribution-5.0.c.pom has dependencyManagement definition with version –>
<dependency>
<groupId>org.springframework.extensions.surf</groupId>
<artifactId>spring-surf</artifactId>
<scope>provided</scope>
</dependency>
<!– Mock objects during Unit testing, alfresco-parent-5.0.c.pom has dependencyManagement definition with version –>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
</dependency>

        <dependency>
            <groupId>${alfresco.groupId}</groupId>
            <artifactId>alfresco-repository</artifactId>
        </dependency>

        <!– If we are running tests then make the H2 Scripts available
             Note. tests are skipped when you are running -Pamp-to-war –>
        <dependency>
            <groupId>${alfresco.groupId}</groupId>
            <artifactId>alfresco-repository</artifactId>
            <version>${alfresco.version}</version>
            <classifier>h2scripts</classifier>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>*</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>


</dependencies>
</project>

</blockcode>

kaynezhang
World-Class Innovator
World-Class Innovator
In maven's conventions,by default java source directories are src/main/java and src/test/java ,resource directories are src/main/resources and src/test/resources.If you want to use other source directories and resource directories ,please customize pom file and modify following element:
<sourceDirectory>,<resources>,<testResources> which are under build element.