As we know old Ant based SDK has been replaced with Maven based SDK in Alfresco 5.0.x.
Here, we will see How to get started with Alfresco development using Alfresco Maven SDK.
Need to follow below steps to create Maven based project. Here we will use Enterprise artifacts.
I am assuming you already have JDK 1.7 and Maven 3.2.5 installed.
- You need to have enterprise credential to access Alfresco Private Repository. Enterprise artifacts are stored in Alfresco Private Repository and it can be accessed only by Enterprise users.
- Edit settings.xml under your .m2 directory. .m2 folder is generally located at C:\Users\<UserName>\.m2 in windows. Add following server configurations under <servers>
- Create a directory where you want to create new maven based project
- You can create three types of Project based on archtypes. For details of this archtypes please check- http://docs.alfresco.com/5.0/concepts/alfresco-sdk-usage.html
- Switch to new directory and run following command
- Next you need to choose archtype. Here I would select alfresco-amp-archetype
- Next to choose an archetype version. I would select 2.0.0
- Then, You will be prompted to enter a value of groupId. Its like package name. You can enter any. I will enter com.alfresco.test
- Then you will be asked to define artifactId. It can be like your project name. I will enter test-repo-project
- Next, You will be prompted to enter a value for the Alfresco version you wish to develop against - currently the default is 5.0.c. Hit the Enter key to accept the default value. Later we will change it.
- You will get log as below and your new project test-repo-project is created with required folders and configuration files.
- To understand project structure please check - http://docs.alfresco.com/5.0/concepts/alfresco-sdk-project-structure.html
- Once project is created you can start your development. Before that you can build and verify your project.
- We want to use enterprise artifact so we need to modify pom.xml of test-repo-project
- Go to test-repo-project and edit pom.xml and change the values of alfresco.groupId and alfresco.version to specify Enterprise artifacts.
Please check this http://docs.alfresco.com/5.0/concepts/alfresco-sdk-tutorials-alfresco-enterprise.html to select correct value of both properties. Here I will set it as below. - Go to cmd and change your current directory to - test-repo-project and type following command. It will download enterprise artifact to build your project and it will also run the project. For first time it may take time to build as it’s downloading all required dependencies.
- Once build is successful login to Share and verify if you have any custom changes.
<server>
<id>alfresco-private-repository</id>
<username>TestUser</username>
<password>MyPwd</password>
</server>
a. Alfresco AMP archetype
b. Alfresco Share AMP archetype
c. Alfresco all-in-one archtype (AIO)
mvn archetype:generate -Dfilter=org.alfresco.maven.archetype:
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: alfresco-amp-archetype:2.0.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.alfresco.test
[INFO] Parameter: artifactId, Value: test-repo-project
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: (not used)
[INFO] Parameter: packageInPathFormat, Value: (not used)
[INFO] Parameter: package, Value: (not used)
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: com.alfresco.test
[INFO] Parameter: alfresco_target_version, Value: 5.0.c
[INFO] Parameter: artifactId, Value: test-repo-project
[INFO] Parameter: alfresco_target_groupId, Value: org.alfresco
[INFO] project created from Archetype in dir: D:\alfrescoMVNWorkspace\test-repo-project
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 06:28 min
[INFO] Finished at: 2015-03-12T15:39:22+05:30
[INFO] Final Memory: 16M/121M
[INFO] ------------------------------------------------------------------------
<alfresco.groupId>org.alfresco</alfresco.groupId>
<alfresco.version>5.0.0</alfresco.version>
mvn install -Prun,enterprise
ISSUE: You might face this unauthorized error message issue while downloading enterprise artifact. To solve it add <server> configuration in your settings.xml as below
<server>
<id>alfresco-internal</id>
<username>TestUser</username>
<password>MyPwd</password>
</server>
Issue detail: https://issues.alfresco.com/jira/browse/MNT-13406
Other useful commands:
To build project:
mvn package
Install amp in your local repo:
mvn install
By default, build includes to run test, If you want to skip test cases
mvn install -DskipTests=true
To delete all compiles artifacts
mvn clean