Maven SDK

 Details Print

Introduction#

Latest efforts relating Maven and Liferay have been focused in providing official maven artifacts for Liferay as well as porting our plugins sdk to Maven.

Our goal is to provide our CE releases through our own public repository as well as provide means for our EE customers to install the EE versions artifacts to their local maven repository.

If you have ever worked with enterprise projects using maven you already know how important a local maven repository and proxy is. For those not so familiar with Maven a proxy is a server that proxies your requests to public Maven repositories and caches the artifacts locally for faster and more reliable access. Most maven proxies can also host private repositories used for hosting your company's private artifacts. Having a local proxy / repository makes your maven builds much faster and more reliable than accessing remote repositories that might even sometimes be unavailable.

Installing a maven proxy / repository#

First step is to install and setup Nexus. Nexus is a open source maven repository manager that can proxy to other repositories as well as host repositories. If you just want to try things locally you can skip this step.

  1. Download latest Nexus such as nexus-webapp-1.4.0-bundle.zip
  2. Follow the installation directions of the Nexus book http://nexus.sonatype.org/documentation.html
  3. Startup nexus
  4. Open your browser to your newly created nexus (if you installed it locally it could be accessed by opening http://localhost:8080/nexus)
  5. Login as administrator (default login is admin / admin123)
  6. Go to Repositories and click Add -> Hosted Repository
  7. Give the repository following information and click save
Repository ID: liferay-ce-releases
Repostory Name: Liferay CE Release Repository
Provider: Maven2 Repository
Repository Policy: Release
  1. Create another hosted repository with following information
Repository ID: liferay-ce-snapshots
Repository Name: Liferay CE Snapshot Repository
Provider: Maven2 Repository
Repository Policy: Snapshot

Now you have a repository ready for Liferay's Maven artifacts. Next step is to configure your maven to be able to upload artifacts to that repository.

Configuring Maven Settings#

Open your $HOME/.m2/settings.xml (if the file does not exist create it). Add the servers segment to your settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings>
<servers>
<server>
<id>liferay</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
</settings>

You might also want to make your Nexus as your maven proxy. To do that just add following xml segment to your settings.xml right before servers element.

<mirrors>
<mirror>
<id>local</id>
<name>Local mirror repository</name>
<url>http://localhost:8080/nexus/content/groups/public</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>

Installing Liferay Artifacts to Repository#

Next we will install the Liferay Maven artifacts to your repository. First you need to checkout Liferay code from the SVN.

svn --username guest co svn://svn.liferay.com/repos/public/portal/trunk portal-trunk

Guest user does not require password.

Then create a release.${username}.properties file and add

maven.url=http://localhost:8080/nexus/content/repositories/liferay-ce-snapshots

Build Liferay artifacts by running

ant clean start jar

Now you can deploy the Liferay artifacts to your maven repository by running

ant -f build-maven.xml deploy-artifacts

If you only want to have them locally without a maven repository you can run the install task instead of deploy

ant -f build-maven.xml install-artifacts

Now you can add Liferay dependencies to your maven project. Following artifacts are available:

<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-client</artifactId>
<version>6.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-impl</artifactId>
<version>6.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-kernel</artifactId>
<version>6.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
<version>6.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-web</artifactId>
<version>6.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-bridges</artifactId>
<version>6.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-java</artifactId>
<version>6.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-taglib</artifactId>
<version>6.0-SNAPSHOT</version>
</dependency>

NOTE portal-impl and portal-web are provided for maven plugins and should never be added as dependency to your Liferay plugins.

Installing the Liferay Maven SDK#

To take full advantage of Maven we are porting the functionality of out ant based Plugins SDK to Maven. To use it you need to install it locally. To install the Liferay maven plugins and archetypes go into support-maven folder and run

mvn install

Now the Liferay Maven SDK is installed and ready to use. We've implemented a portlet archetype and deployer plugin.

Creating a Portlet Plugin#

Move to the folder where you want to create your portlet and run

mvn archetype:generate

From the list select liferay-portlet-archetype and provide your project groupId, artifactId and version for the portlet project.

You're portlet project's pom.xml has two properties liferay.auto.deploy.dir and liferay.version. These properties are usually moved to your parent pom.xml or settings.xml so that you don't have to adjust them for every single plugin you create. Set the liferay.auto.deploy.dir to point to the Liferay autodeploy directory of your Liferay bundle. This is where the deploy plugin will copy your portlet. Now you are ready deploy your newly created portlet. You can deploy it by running

mvn liferay:deploy

Maven SDK的更多相关文章

  1. SDKMAN一个基于命令行界面的SDK用户环境管理程序

    1.背景 使用过Python开发的朋友,应该了解到Python2和Python3语法的差异,有时候从网上下载了基于不同解释器的代码,要来回切换版本, 使用起来不是很方便,有时候甚至很麻烦.于是有人发明 ...

  2. Java VS .NET:Java与.NET的特点对比

    一.前言 为什么要写Java跟.NET对比? .NET出生之后就带着Java的影子.从模仿到创新,.NET平台也越来越成熟.他们不同的支持者也经常因为孰弱孰强的问题争论不休.但是本文并不是为了一分高下 ...

  3. 大同世界的Java 和.NET 开发

    1.作为一个科班出生的根正苗红的软件开发人员,我认为现在的一群年轻的程序员总是在讨论JAVA  好还是.NET 好的同时,我作为一个做4年开发的.NET 程序员中间穿插了1年JAVA 开发的来说更加的 ...

  4. Java VS .NET:Java与.NET的特点对比 单点登录(SSO)的设计

    一.前言 为什么要写Java跟.NET对比? .NET出生之后就带着Java的影子.从模仿到创新,.NET平台也越来越成熟.他们不同的支持者也经常因为孰弱孰强的问题争论不休.但是本文并不是为了一分高下 ...

  5. 跟我一起安装jenkins

    查看java版本 查看brew版本 升级 java brew cask install java 安装 jenkins brew install jenkins 执行 java -jar /usr/l ...

  6. eclipse 配置android sdk和maven

    首先下载 ADT-22.2.0.rar eclipse-jee-kepler-R-win32-x86_64.zip android SDK4.2.zip 分别解压在一个盘 将ADT里面的两个目录内容相 ...

  7. 使用语音识别JAVA SDK 的MAVEN源代码制作语音控制智能家居Java APP-------MAVEN工程加载问题解决

    一直想做一个可以录音的可执行JAVA APP,实现自然语言对话. 第一步就是实现把录音转成语义,比如你对着话筒说"你好",你获取回答相应的回复.你对着话筒说"今天的天气& ...

  8. 开发常用镜像资源替换为国内开源镜像(yum,compose,maven,docker,android sdk,npm,国内开源镜像汇总)

    一.国内开源镜像站点汇总 阿里云开源镜像站 (http://mirrors.aliyun.com/)网易开源镜像站 (http://mirrors.163.com/)中国科学技术大学开源镜像站 (ht ...

  9. MAC上使用maven打android的包,报错:No Android SDK path could be found. 解决办法

    对android工程运行mvn compile出现如下信息: No Android SDK path could be found. You may configure it in the pom u ...

随机推荐

  1. 关于JAVA System常见类的一些总结

    一.JAVA System类概述 1.概述: System 类是一个抽象类,所有的字段和方法都是静态的,即不能被实例化.其中包含一些有用的类字段和方法,它不能被实例化.在 System 类提供的设施中 ...

  2. JavaScript--面向对象与原型(15)

    // ECMAScript有两种开发模式:1.函数式(过程化);2.面向对象(OOP); 一 创建对象 1.普通的创建对象 1 // 创建一个对象,然后给这个对象新的属性和方法; 2 var box ...

  3. C++运用SDK截屏

    引言 最近有一个需要截取当前屏幕,并保存成BMP文件的需求.整个需求,拆分成三步:1.截取屏幕,获得位图数据.2.配合bmp文件结构信息,将数据整合.3.对整合后的数据做操作,如保存在本地.通过网络传 ...

  4. c#中的枚举

    1.枚举概念:枚举是用户定义的整型类型,在声明一个枚举时,要指定该枚举的实例可以包含的一组可接受的值,还可以给值指定易于记忆的名称.如果在代码的某个地方,要试图把一个不可接受范围内的值赋予枚举的一个实 ...

  5. H5全景视频VR视频

    公司的有个专题页面涉及到全景视频展示这个技术点,找到一个相关的库. http://www.utovr.com/sdk/download  这里有个免费的SDK可以下载. 里面也有案例可以看,代码就照着 ...

  6. 代码分享:php判断数组是否有序

    发布:脚本学堂/PHP编程  编辑:JB02   2013-12-17 14:59:02  [大 中 小] 转自:http://www.jbxue.com/article/14723.html如何判断 ...

  7. Oracle 监听动态注册与静态注册

    静态注册 静态注册是在启动listener时,listener会从listener.ora文件中获取服务名及相关信息.信息包括:实例名和服务名等. --静态注册时,listener.ora中的内容如下 ...

  8. linux 输入子系统(2)----简单实例分析系统结构(input_dev层)

    实例代码如下: #include <linux/input.h> #include <linux/module.h> #include <linux/init.h> ...

  9. 爬虫学习之基于Scrapy的网络爬虫

    ###概述 在上一篇文章<爬虫学习之一个简单的网络爬虫>中我们对爬虫的概念有了一个初步的认识,并且通过Python的一些第三方库很方便的提取了我们想要的内容,但是通常面对工作当作复杂的需求 ...

  10. zhuan:ubuntu下安装Apache2+php+Mysql

    from: http://www.cnblogs.com/lynch_world/archive/2012/01/06/2314717.html ubuntu下安装Apache+PHP+Mysql 转 ...