Hello guys,
Please refer Liferay Mobile SDK + Custom Services part-1 for getting idea of what this post is all about.
Now we have our service running on our local server and also we have Liferay mobile SDK for building custom jar.
Lets see how to do it,
1) Go to downloaded Liferay Mobile SDK folder (picture shown below)
2) This project already ships the Gradle Wrapper (gradlew) with it, you don't need to install Gradle's command line tool (gradle).
Now you have to set some properties before building
"custom-mob-app-service-portlet" is our deployed portlet on local server.Filter is empty because we want all other default services.
Save it.
3.To build the service related source files for your Liferay Android SDK, run the following command from the
ANDDD Done...
Now you can use that custom services of "custom-mob-app-service-portlet" in your android app without knowing any Liferay side coding ;)
Please note that the custom service name would be the name of the entity defined in service.xml file which we have seen in 1st Part of the POST.
Still yes still ....In the next post we are going to see how you can do Async call of Liferay services in android app.
see you soon...:D
NEXT
Please refer Liferay Mobile SDK + Custom Services part-1 for getting idea of what this post is all about.
Now we have our service running on our local server and also we have Liferay mobile SDK for building custom jar.
Lets see how to do it,
1) Go to downloaded Liferay Mobile SDK folder (picture shown below)
2) This project already ships the Gradle Wrapper (gradlew) with it, you don't need to install Gradle's command line tool (gradle).
Now you have to set some properties before building
- Edit
gradle.properties
, if you don't want to change that file directly, you can also copy it to~/.gradle
and modify it there. Alternatively, you can also edit thegradle.properties
inside each platform folder (ios/ or android/). - Here are the important properties to set:
url
- The URL to your Liferay instance.context
- Your portlet's web context. Say for example you are generating an SDK for Liferay's Calendar portlet, which is generally deployed to thecalendar-portlet
context, then you should set your context value tocontext=calendar-portlet
. Under the hood, the SDK Builder will try to accesshttp://localhost:8080/calendar-portlet/api/jsonws?discover
to find out which services are available for this portlet. Check in a browser if this URL is working before running the SDK. If it's not running, you may have forgotten to runant build-wsdd
on the portlet.filter
- Specifies your portlet's entities whose services to access; a blank value indicates the services of all of the portlet's entities. For example, the Calendar portlet has entities such asCalendarBooking
andCalendarResource
. To generate an SDK for only theCalendarBooking
entity, set the filter's value tocalendarbooking
, all in lowercase. The SDK Builder will then make requests to thehttp://localhost:8080/calendar-portlet/api/jsonws?discover=/calendarbooking/*
. If you setfilter=
, specifying no filter value, the remote services of all of the portlet's entities will be made available to your mobile SDK.package
- On Android, this is the package to which your SDK's classes are written. The iOS platform does not use packages. Note, that the Liferay Portal version is appended to the end of the package name. So, if you specifiedcom.liferay.mobile.android
as your package, the SDK Builder appends the Liferay Portal version (e.g.,v62
) to it, likecom.liferay.mobile.android.v62
. Appending the Liferay Portal version prevents collisions between classes with the same names written for different versions of Liferay Portal.destination
- Specifies the root folder in which to save your generated files. On Android, by default, the files are saved toandroid/src/gen/java
. On iOS, the files are saved by default toios/src/gen
.version
- The version number is appended to the jar and zip file names, see more about that in the following sections.
Example file for our portlet is given below:
##
## SDK Builder
##
url=http://localhost:8080
context=custom-mob-app-service-portlet
filter=
packageName=com.liferay.mobile.android//you can provide custom name
destination=gen
##
## Build
##
version=6.2.0.1
"custom-mob-app-service-portlet" is our deployed portlet on local server.Filter is empty because we want all other default services.
Save it.
3.To build the service related source files for your Liferay Android SDK, run the following command from the
android/
folder:gradlew buildService
The source files are written to the
android/src/gen/java
folder by default.
To build a
.jar
file containing the generated service and utility classes, run the following command:gradlew jar
The
4. Within your Android project, drop the JAR into the liferay-android-sdk-[version].jar
file is written to your android/build/libs
folder. You're ready to use the liferay-android-sdk-[version].jar
in your Android project, there are no external dependencies./libs
folder. Android Developer Tools should automatically add this JAR to your classpath. If you are using a different IDE, make sure this JAR is added to the project classpath.ANDDD Done...
Now you can use that custom services of "custom-mob-app-service-portlet" in your android app without knowing any Liferay side coding ;)
Please note that the custom service name would be the name of the entity defined in service.xml file which we have seen in 1st Part of the POST.
Still yes still ....In the next post we are going to see how you can do Async call of Liferay services in android app.
see you soon...:D
NEXT
No comments:
Post a Comment