블로그 이미지
윤영식
Full Stacker, Application Architecter, KnowHow Dispenser and Bike Rider

Publication

Category

Recent Post

2014. 5. 27. 00:15 Study Frameworks/Liferay Portal

Liferay에서 제공하는 포틀릿을 확장하는 방법에 대해 알아본다. 



기존 플러그인 확장 순서 

  - 포틀릿 하나를 만든다 

$ cd ~/liferay_portal/plugins-sdk-6.2/portlets

$ create.sh mobiconsoft_hi "modify portlet"

Buildfile: /liferay_portal/plugins-sdk-6.2/portlets/build.xml


create:

     [copy] Copying 9 files to /liferay_portal/plugins-sdk-6.2/portlets/mobiconsoft_hi-portlet

    [mkdir] Created dir: /liferay_portal/plugins-sdk-6.2/portlets/mobiconsoft_hi-portlet/docroot/WEB-INF/tld

     [copy] Copying 7 files to /liferay_portal/plugins-sdk-6.2/portlets/mobiconsoft_hi-portlet/docroot/WEB-INF/tld


BUILD SUCCESSFUL

Total time: 3 seconds


$ cd mobiconsoft_hi-portlet/

  - portlet 소스 하나를 mobiconsoft_hi-portlet/docroot/ 밑으로 복사

    + https://github.com/liferay/liferay-plugins 에는 CE 관련 소스들이 있다. 로컬로 clone한다

    + portlet 소스는 liferay-plugins/portlet/ 밑에 존재한다

  - ant를 통해서 war파일을 만든다

$ ant war 

수행이 정상적으로 완료되면 

/plugins-sdk-6.2/dist/ 폴더에 mobiconsoft_hi-portlet-6.2.0.2.war 파일이 생성된다 



Eclipse Import 한 후 Mavenization

  - git clone한 소스를 import 하게 되면 ant 기반으로 되어 있다. build.xml을 통하여 ant deploy를 할 수 있다. 

    

  - maven 기반으로 만드는 것은 다음과 같이 해보자

    + 먼저 eclipse에서 liferay plugin을 maven 기반으로 생성한다

    + WEB-INF 소스를 그대로 복사한다. 

    + 단, WEB-INF/**/*.java 소스들은 maven의 src/main/java 로 리소스는 src/main/resources로 패키지 구조에 맞게 복사한다 

  - 다음 pom.xml 에서 다음 부분을 첨부한다 

        <properties>

   <liferay.app.server.deploy.dir>/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42/webapps</liferay.app.server.deploy.dir>

   <liferay.app.server.lib.global.dir>/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42/lib/ext</liferay.app.server.lib.global.dir>

   <liferay.app.server.portal.dir>/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42/webapps/ROOT</liferay.app.server.portal.dir>

   <liferay.auto.deploy.dir>/liferay_portal/portal-6.2-ce-ga2/deploy</liferay.auto.deploy.dir>

   <liferay.maven.plugin.version>6.2.1</liferay.maven.plugin.version>

   <liferay.version>6.2.1</liferay.version>

    </properties>

   

    <repositories>

   <repository>

       <id>liferay-ce</id>

       <name>Liferay CE</name>

       <url>https://repository.liferay.com/nexus/content/groups/liferay-ce</url>

       <releases><enabled>true</enabled></releases>

       <snapshots><enabled>true</enabled></snapshots>

   </repository>

</repositories>

<pluginRepositories>

   <pluginRepository>

       <id>liferay-ce</id>

       <url>https://repository.liferay.com/nexus/content/groups/liferay-ce/</url>

       <releases><enabled>true</enabled></releases>

       <snapshots><enabled>true</enabled></snapshots>

   </pluginRepository>

</pluginRepositories>

<build>

<plugins>

<plugin>

<groupId>com.liferay.maven.plugins</groupId>

<artifactId>liferay-maven-plugin</artifactId>

<version>${liferay.maven.plugin.version}</version>

<executions>

<execution>

<phase>generate-sources</phase>

<goals>

<goal>build-css</goal>

</goals>

</execution>

</executions>

<configuration>

<autoDeployDir>${liferay.auto.deploy.dir}</autoDeployDir>

<appServerDeployDir>${liferay.app.server.deploy.dir}</appServerDeployDir>

<appServerLibGlobalDir>${liferay.app.server.lib.global.dir}</appServerLibGlobalDir>

<appServerPortalDir>${liferay.app.server.portal.dir}</appServerPortalDir>

<liferayVersion>${liferay.version}</liferayVersion>

<pluginType>portlet</pluginType>

</configuration>

</plugin>

<plugin>

<artifactId>maven-compiler-plugin</artifactId>

<version>2.5</version>

<configuration>

<encoding>UTF-8</encoding>

<source>1.6</source>

<target>1.6</target>

</configuration>

</plugin>

<plugin>

<artifactId>maven-resources-plugin</artifactId>

<version>2.5</version>

<configuration>

<encoding>UTF-8</encoding>

</configuration>

</plugin>

</plugins>

</build>


<dependencies> ... 여기는 기존 설정을 그대로 사용함  </dependencies>


pom.xml 파일은 글로벌 settings.xml에 repository에 설정해도 된다. 또한 Nexus가 설치 되어 있다면 설정한다. 계속해서 포틀릿을 만들고 배포를 위해서는 Nexus를 설치하여 운영하는게 좋겠다. 



<참조> 

  - 기존 플러그인 확장하기 

posted by 윤영식