Skip to content

Commit 3bcfaa8

Browse files
authored
Merge pull request #113002 from erikadoyle/sfgradle
Add gradle language identifiers to SF Java app update guide
2 parents d301011 + 9450d64 commit 3bcfaa8

File tree

1 file changed

+30
-12
lines changed

1 file changed

+30
-12
lines changed

articles/service-fabric/service-fabric-migrate-old-javaapp-to-use-maven.md

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,32 @@ ms.date: 08/23/2017
88
ms.author: rapatchi
99
---
1010
# 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 Maven based 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 applications created for the Service Fabric Java SDK using either Yeoman template or Eclipse to be compatible with the Maven-based build.
1212

1313
## Prerequisites
14-
1. First you need to uninstall the existing Java SDK.
14+
15+
1. First, uninstall the existing Java SDK.
1516

1617
```bash
1718
sudo dpkg -r servicefabricsdkjava
1819
```
20+
1921
2. Install the latest Service Fabric CLI following the steps mentioned [here](service-fabric-cli.md).
2022

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 -
2224

2325
```bash
2426
sudo apt-get install openjdk-8-jdk-headless
2527
sudo apt-get install gradle
2628
```
29+
2730
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.
2831

2932
>[!TIP]
3033
> 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.
3134
3235
## Service Fabric Java libraries on Maven
36+
3337
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**.
3438

3539
### Actors
@@ -75,6 +79,7 @@ Service Fabric Stateless Service support for your application.
7579
```
7680

7781
### Others
82+
7883
#### Transport
7984

8085
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
117122
}
118123
```
119124

120-
121125
## Migrating Service Fabric Stateless Service
122126

123127
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 -
124-
```
128+
129+
```gradle
125130
dependencies {
126131
compile fileTree(dir: '/opt/microsoft/sdk/servicefabric/java/packages/lib', include: ['*.jar'])
127132
compile project(':Interface')
@@ -153,8 +158,10 @@ task copyDeps <<{
153158
}
154159
}
155160
```
161+
156162
Now, to fetch the dependencies from Maven, the **updated** ``build.gradle`` would have the corresponding parts as follows -
157-
```
163+
164+
```gradle
158165
repositories {
159166
mavenCentral()
160167
}
@@ -206,11 +213,13 @@ task copyDeps <<{
206213
}
207214
}
208215
```
216+
209217
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.
210218

211219
## Migrating Service Fabric Actor Service
212220

213221
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+
214223
```
215224
./Myactor/build.gradle
216225
./MyactorInterface/build.gradle
@@ -220,15 +229,18 @@ To be able to build your existing Service Fabric Actor Java application using Se
220229
#### Updating build script for the interface project
221230

222231
Previously it used to be like as follows -
223-
```
232+
233+
```gradle
224234
dependencies {
225235
compile fileTree(dir: '/opt/microsoft/sdk/servicefabric/java/packages/lib', include: ['*.jar'])
226236
}
227237
.
228238
.
229239
```
240+
230241
Now, to fetch the dependencies from Maven, the **updated** ``build.gradle`` would have the corresponding parts as follows -
231-
```
242+
243+
```gradle
232244
repositories {
233245
mavenCentral()
234246
}
@@ -261,7 +273,8 @@ compileJava.dependsOn(explodeDeps)
261273
#### Updating build script for the actor project
262274

263275
Previously it used to be like as follows -
264-
```
276+
277+
```gradle
265278
dependencies {
266279
compile fileTree(dir: '/opt/microsoft/sdk/servicefabric/java/packages/lib', include: ['*.jar'])
267280
compile project(':MyactorInterface')
@@ -299,8 +312,10 @@ task copyDeps<< {
299312
}
300313
}
301314
```
315+
302316
Now, to fetch the dependencies from Maven, the **updated** ``build.gradle`` would have the corresponding parts as follows -
303-
```
317+
318+
```gradle
304319
repositories {
305320
mavenCentral()
306321
}
@@ -360,7 +375,8 @@ task copyDeps<< {
360375
#### Updating build script for the test client project
361376

362377
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 -
363-
```
378+
379+
```gradle
364380
dependencies {
365381
compile fileTree(dir: '/opt/microsoft/sdk/servicefabric/java/packages/lib', include: ['*.jar'])
366382
compile project(':MyactorInterface')
@@ -399,8 +415,10 @@ task copyDeps<< {
399415
}
400416
}
401417
```
418+
402419
Now, to fetch the dependencies from Maven, the **updated** ``build.gradle`` would have the corresponding parts as follows -
403-
```
420+
421+
```gradle
404422
repositories {
405423
mavenCentral()
406424
}

0 commit comments

Comments
 (0)