You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/service-fabric/service-fabric-migrate-old-javaapp-to-use-maven.md
+30-12Lines changed: 30 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,28 +8,32 @@ ms.date: 08/23/2017
8
8
ms.author: rapatchi
9
9
---
10
10
# Update your previous Java Service Fabric application to fetch Java libraries from Maven
11
-
We have recently moved Service Fabric Java binaries from the Service Fabric Java SDK to Maven hosting. Now you can use **mavencentral** to fetch the latest Service Fabric Java dependencies. This quick-start helps you update your existing Java applications, which you earlier created to be used with Service Fabric Java SDK, using either Yeoman template or Eclipse, to be compatible with the Mavenbased build.
11
+
Service Fabric Java binaries have moved from the Service Fabric Java SDK to Maven hosting. You can use **mavencentral** to fetch the latest Service Fabric Java dependencies. This guide will help you update existing Java applicationscreated for the Service Fabric Java SDK using either Yeoman template or Eclipse to be compatible with the Maven-based build.
12
12
13
13
## Prerequisites
14
-
1. First you need to uninstall the existing Java SDK.
14
+
15
+
1. First, uninstall the existing Java SDK.
15
16
16
17
```bash
17
18
sudo dpkg -r servicefabricsdkjava
18
19
```
20
+
19
21
2. Install the latest Service Fabric CLI following the steps mentioned [here](service-fabric-cli.md).
20
22
21
-
3. To build and work on the Service Fabric Java applications, you need to ensure that you have JDK 1.8 and Gradle installed. If not yet installed, you can run the following to install JDK 1.8 (openjdk-8-jdk) and Gradle -
23
+
3. To build and work on the Service Fabric Java applications, ensure that you have JDK 1.8 and Gradle installed. If not yet installed, you can run the following to install JDK 1.8 (openjdk-8-jdk) and Gradle -
22
24
23
25
```bash
24
26
sudo apt-get install openjdk-8-jdk-headless
25
27
sudo apt-get install gradle
26
28
```
29
+
27
30
4. Update the install/uninstall scripts of your application to use the new Service Fabric CLI following the steps mentioned [here](service-fabric-application-lifecycle-sfctl.md). You can refer to our getting-started [examples](https://github.com/Azure-Samples/service-fabric-java-getting-started) for reference.
28
31
29
32
>[!TIP]
30
33
> After uninstalling the Service Fabric Java SDK, Yeoman will not work. Follow the Prerequisites mentioned [here](service-fabric-create-your-first-linux-application-with-java.md) to have Service Fabric Yeoman Java template generator up and working.
31
34
32
35
## Service Fabric Java libraries on Maven
36
+
33
37
Service Fabric Java libraries have been hosted in Maven. You can add the dependencies in the ``pom.xml`` or ``build.gradle`` of your projects to use Service Fabric Java libraries from **mavenCentral**.
34
38
35
39
### Actors
@@ -75,6 +79,7 @@ Service Fabric Stateless Service support for your application.
75
79
```
76
80
77
81
### Others
82
+
78
83
#### Transport
79
84
80
85
Transport layer support for Service Fabric Java application. You do not need to explicitly add this dependency to your Reliable Actor or Service applications, unless you program at the transport layer.
@@ -117,11 +122,11 @@ System level support for Service Fabric, which talks to native Service Fabric ru
117
122
}
118
123
```
119
124
120
-
121
125
## Migrating Service Fabric Stateless Service
122
126
123
127
To be able to build your existing Service Fabric stateless Java service using Service Fabric dependencies fetched from Maven, you need to update the ``build.gradle`` file inside the Service. Previously it used to be like as follows -
Now, to fetch the dependencies from Maven, the **updated**``build.gradle`` would have the corresponding parts as follows -
157
-
```
163
+
164
+
```gradle
158
165
repositories {
159
166
mavenCentral()
160
167
}
@@ -206,11 +213,13 @@ task copyDeps <<{
206
213
}
207
214
}
208
215
```
216
+
209
217
In general, to get an overall idea about how the build script would look like for a Service Fabric stateless Java service, you can refer to any sample from our getting-started examples. Here is the [build.gradle](https://github.com/Azure-Samples/service-fabric-java-getting-started/blob/master/reliable-services-actor-sample/build.gradle) for the EchoServer sample.
210
218
211
219
## Migrating Service Fabric Actor Service
212
220
213
221
To be able to build your existing Service Fabric Actor Java application using Service Fabric dependencies fetched from Maven, you need to update the ``build.gradle`` file inside the interface package and in the Service package. If you have a TestClient package, you need to update that as well. So, for your actor ``Myactor``, the following would be the places where you need to update -
222
+
214
223
```
215
224
./Myactor/build.gradle
216
225
./MyactorInterface/build.gradle
@@ -220,15 +229,18 @@ To be able to build your existing Service Fabric Actor Java application using Se
220
229
#### Updating build script for the interface project
Now, to fetch the dependencies from Maven, the **updated**``build.gradle`` would have the corresponding parts as follows -
303
-
```
317
+
318
+
```gradle
304
319
repositories {
305
320
mavenCentral()
306
321
}
@@ -360,7 +375,8 @@ task copyDeps<< {
360
375
#### Updating build script for the test client project
361
376
362
377
Changes here are similar to the changes discussed in previous section, that is, the actor project. Previously the Gradle script used to be like as follows -
0 commit comments