Skip to content

Commit

Permalink
Switch java symlink creation to use CMD to avoid PS upgrade
Browse files Browse the repository at this point in the history
Signed-off-by: Stewart Addison <sxa@uk.ibm.com>
  • Loading branch information
Stewart Addison committed May 29, 2019
1 parent 7946330 commit 2f14d90
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,9 @@
when: (java11_installed.stat.exists == false)
tags: Java11

- name: Test if Java11 symlink is already created
win_stat:
path: 'C:\openjdk\jdk-11'
register: java11_symlink
tags: Java11

- name: Get Java 11 Folder name to create symlink
win_shell: powershell ([Environment]::SetEnvironmentVariable("Java11_Folder", (Get-ChildItem -Path 'C:\Program Files\Java\jdk-11*' | Select-String -Pattern 'C*'), "Machine"))
when: (java11_symlink.stat.exists == false)
tags: Java11

- name: Create symlink to Java 11
win_shell: New-Item -Path 'C:\openjdk\jdk-11' -ItemType SymbolicLink -Value ([Environment]::GetEnvironmentVariable("Java11_Folder", "Machine"))
- name: Create symlink to directory without spaces if not already there
win_shell: for /D %a in ("C:\Program Files\Java\jdk-11*") do IF NOT EXIST "C:\openjdk\jdk-11" MKLINK /D "C:\openjdk\jdk-11" "%a"
args:
executable: powershell
when: (java11_symlink.stat.exists == false)
executable: cmd.exe
creates: 'C:\openjdk\jdk-11'
tags: Java11
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,9 @@
when: (java12_installed.stat.exists == false)
tags: Java12

- name: Test if Java12 symlink is already created
win_stat:
path: 'C:\openjdk\jdk-12'
register: java12_symlink
tags: Java12

- name: Get Java 12 Folder name to create symlink
win_shell: powershell ([Environment]::SetEnvironmentVariable("Java12_Folder", (Get-ChildItem -Path 'C:\Program Files\Java\jdk-12*' | Select-String -Pattern 'C*'), "Machine"))
when: (java12_symlink.stat.exists == false)
tags: Java12

- name: Create symlink to Java 12
win_shell: New-Item -Path 'C:\openjdk\jdk-12' -ItemType SymbolicLink -Value ([Environment]::GetEnvironmentVariable("Java12_Folder", "Machine"))
- name: Create symlink to directory without spaces if not already there
win_shell: for /D %a in ("C:\Program Files\Java\jdk-12*") do IF NOT EXIST "C:\openjdk\jdk-12" MKLINK /D "C:\openjdk\jdk-12" "%a"
args:
executable: powershell
when: (java12_symlink.stat.exists == false)
executable: cmd.exe
creates: 'C:\openjdk\jdk-12'
tags: Java12
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,11 @@
when: (java8_installed.stat.exists == false)
tags: Java8

- name: Test if Java 8 symlink is already created
win_stat:
path: 'C:\openjdk\jdk-8'
register: java8_symlink
tags: Java8

- name: Get Java 8 Folder name to create symlink
win_shell: powershell ([Environment]::SetEnvironmentVariable("Java8_Folder", (Get-ChildItem -Path 'C:\Program Files\Java\jdk8*' | Select-String -Pattern 'C*'), "Machine"))
when: (java8_symlink.stat.exists == false)
tags: Java8

- name: Create symlink to Java 8
win_shell: New-Item -Path 'C:\openjdk\jdk-8' -ItemType SymbolicLink -Value ([Environment]::GetEnvironmentVariable("Java8_Folder", "Machine"))
- name: Create symlink to directory without spaces if not already there
win_shell: for /D %a in ("C:\Program Files\Java\jdk8*") do IF NOT EXIST "C:\openjdk\jdk-8" MKLINK /D "C:\openjdk\jdk-8" "%a"
args:
executable: powershell
when: (java8_symlink.stat.exists == false)
executable: cmd.exe
creates: 'C:\openjdk\jdk-8'
tags: Java8

- name: Set JAVA_HOME to version 8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,9 @@
when: (java9_installed.stat.exists == false)
tags: Java9

- name: Test if Java 9 symlink is already created
win_stat:
path: 'C:\openjdk\jdk-9'
register: java9_symlink
tags: Java9

- name: Get Java 9 Folder name to create symlink
win_shell: powershell ([Environment]::SetEnvironmentVariable("Java9_Folder", (Get-ChildItem -Path 'C:\Program Files\Java\jdk-9*' | Select-String -Pattern 'C*'), "Machine"))
when: (java9_symlink.stat.exists == false)
tags: Java9

- name: Create symlink to Java 9
win_shell: New-Item -Path 'C:\openjdk\jdk-9' -ItemType SymbolicLink -Value ([Environment]::GetEnvironmentVariable("Java9_Folder", "Machine"))
- name: Create symlink to directory without spaces if not already there
win_shell: for /D %a in ("C:\Program Files\Java\jdk-9*") do IF NOT EXIST "C:\openjdk\jdk-9" MKLINK /D "C:\openjdk\jdk-9" "%a"
args:
executable: powershell
when: (java9_symlink.stat.exists == false)
executable: cmd.exe
creates: 'C:\openjdk\jdk-9'
tags: Java9

0 comments on commit 2f14d90

Please sign in to comment.