Maven building a jar, not an AMP

cancel
Showing results for 
Search instead for 
Did you mean: 
mangar
Established Member II

Maven building a jar, not an AMP

Jump to solution

I am using alfresco 6.2 community.  I used the AIO archtype.  But when I "mvn clean install -DskipTests"   All I get is a .jar file in the target directory,  not an AMP.   How do I fix this?

<?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>
    <artifactId>eisenhour-alfresco-extensions</artifactId>
    <name>Alfresco Platform/Repository JAR Module</name>
    <description>Platform/Repo JAR Module (to be included in the alfresco.war) - part of AIO - SDK 4.0
    </description>

    <parent>
        <groupId>com.elpsolutions</groupId>
        <artifactId>alfresco</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <properties>
    </properties>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.2.18</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
1 Solution

Accepted Solutions
abhinavmishra14
Advanced

Re: Maven building a jar, not an AMP

Jump to solution

By default jar based extensions are built. In order to get amps along with jars, you need to uncomment the "maven-assembly-plugin" plugin. Take a look at the parent pom.xml in your project and find the below given plug-in. 

Example for your reference: https://github.com/abhinavmishra14/alfresco-mimetype-blocker/blob/master/pom.xml#L125

              <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>2.6</version>
                    <executions>
                        <execution>
                            <id>build-amp-file</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                            <configuration>
                                <appendAssemblyId>false</appendAssemblyId>
                                <descriptor>src/main/assembly/amp.xml</descriptor>
                            </configuration>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>org.alfresco.maven.plugin</groupId>
                            <artifactId>alfresco-maven-plugin</artifactId>
                            <version>${alfresco.sdk.version}</version>
                        </dependency>
                    </dependencies>
               </plugin>

When using any external or different amp module in your project you need to add the dependency with following:

<exclusions>
       <exclusion>
         <groupId>*</groupId>
         <artifactId>*</artifactId>
       </exclusion>
 </exclusions>

You can find a note in the platform-docker and share-docker projects about this. Example of adding an amp based dependency, note the exclusions part.

 

               <dependency>
			<groupId>de.fmaul</groupId>
			<artifactId>javascript-console-repo</artifactId>
			<type>amp</type>
			<version>0.6</version>
			<exclusions>
				<exclusion>
					<groupId>*</groupId>
					<artifactId>*</artifactId>
				</exclusion>
			</exclusions>
             </dependency>

 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

View solution in original post

5 Replies
abhinavmishra14
Advanced

Re: Maven building a jar, not an AMP

Jump to solution

By default jar based extensions are built. In order to get amps along with jars, you need to uncomment the "maven-assembly-plugin" plugin. Take a look at the parent pom.xml in your project and find the below given plug-in. 

Example for your reference: https://github.com/abhinavmishra14/alfresco-mimetype-blocker/blob/master/pom.xml#L125

              <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>2.6</version>
                    <executions>
                        <execution>
                            <id>build-amp-file</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                            <configuration>
                                <appendAssemblyId>false</appendAssemblyId>
                                <descriptor>src/main/assembly/amp.xml</descriptor>
                            </configuration>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>org.alfresco.maven.plugin</groupId>
                            <artifactId>alfresco-maven-plugin</artifactId>
                            <version>${alfresco.sdk.version}</version>
                        </dependency>
                    </dependencies>
               </plugin>

When using any external or different amp module in your project you need to add the dependency with following:

<exclusions>
       <exclusion>
         <groupId>*</groupId>
         <artifactId>*</artifactId>
       </exclusion>
 </exclusions>

You can find a note in the platform-docker and share-docker projects about this. Example of adding an amp based dependency, note the exclusions part.

 

               <dependency>
			<groupId>de.fmaul</groupId>
			<artifactId>javascript-console-repo</artifactId>
			<type>amp</type>
			<version>0.6</version>
			<exclusions>
				<exclusion>
					<groupId>*</groupId>
					<artifactId>*</artifactId>
				</exclusion>
			</exclusions>
             </dependency>

 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)
mangar
Established Member II

Re: Maven building a jar, not an AMP

Jump to solution

Ahh,  so obvious,  the PARENT pom.  I was just building the alfresco-platform.  But you are saying that if I add the exclusions to say alfresco-share, It would create an AMP?

abhinavmishra14
Advanced

Re: Maven building a jar, not an AMP

Jump to solution

Uncommenting the "maven-assembly-plugin" would start creating amps along with jars as well. Even if you build alfresco-platform sub-project, and if "maven-assembly-plugin" is enabled, you would get jar and amp both for that sub-project.

~Abhinav
(ACSCE, AWS SAA, Azure Admin)
EddieMay
Alfresco Employee

Re: Maven building a jar, not an AMP

Jump to solution

Hi @mangar 

Glad you got it resolved & thanks for accepting the solution - that's helpful to other users.

Kind regards,

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!
maksym
Member II

Re: Maven building a jar, not an AMP

Jump to solution

Hi, Abhinav!
1) Can you explain please why it is required to add <exclusions>?

<exclusions>
       <exclusion>
         <groupId>*</groupId>
         <artifactId>*</artifactId>
       </exclusion>
 </exclusions>

What is it required for?
It is really not obvious - I tried with and without and did not notice any difference.

2) Also pom contains comment:

If using amp extensions only, add <includeTypes>amp</includeTypes> to the "collect-extensions" execution below.

Can you explain also this - in what cases it is used?

Thanks in advance.