Skip to content

Commit 6197c2e

Browse files
gosurya-oraclejshum2479
authored andcommitted
Installer
1 parent f9074e5 commit 6197c2e

File tree

15 files changed

+220
-66
lines changed

15 files changed

+220
-66
lines changed

README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,16 @@ applying selected patches).
3333

3434
## Setup
3535

36-
- Build the project (`mvn clean package`) to generate artifacts `imagebuilder-0.1-SNAPSHOT.jar` and `imagebuilder_completion.sh`.
37-
- The JAR is an uber-JAR containing all the required packages to run the tool.
38-
- If running an OS with bash, then use the commands below to set up the tool with the tab complete feature:
39-
```bash
40-
#!/usr/bin/env bash
41-
unalias imagebuilder 2> /dev/null
42-
alias imagebuilder='java -cp "./imagebuilder-0.1-SNAPSHOT.jar" com.oracle.weblogicx.imagebuilder.cli.CLIDriver'
43-
source ./imagebuilder_completion.sh
44-
```
36+
- Build the project (`mvn clean package`) to generate artifacts `imagebuilder-0.1-SNAPSHOT.zip`.
37+
- Unzip to a desired location. This action should create lib, bin directories and LICENSE.txt.
38+
- If running an OS with bash, run `cd your_unzipped_location/bin` and `source setup.sh`.
4539
- On Windows, set up with `imagebuilder.cmd` or the `imagebuilder.bat` script:
4640
```cmd
4741
@ECHO OFF
48-
java -cp "./imagebuilder-0.1-SNAPSHOT.jar" com.oracle.weblogicx.imagebuilder.cli.CLIDriver %*
42+
java -cp "your_unzipped_folder/lib" com.oracle.weblogicx.imagebuilder.cli.CLIDriver %*
4943
```
5044
- Then, execute `imagebuilder help` to get the help screen.
51-
- You can execute the JAR directly using the command `java -cp "./imagebuilder-0.1-SNAPSHOT.jar" com.oracle.weblogicx.imagebuilder.cli.CLIDriver help`.
45+
- You can execute the JAR directly using the command `java -cp "your_unzipped_folder/lib" com.oracle.weblogicx.imagebuilder.cli.CLIDriver help`.
5246
- After you are familiar with the commands, you will be able to create and update WebLogic Docker images.
5347
5448
## Copyright

pom.xml

Lines changed: 84 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
<maven.compiler.source>1.8</maven.compiler.source>
1414
<maven.compiler.target>1.8</maven.compiler.target>
1515
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
16-
<shade-plugin-version>3.2.1</shade-plugin-version>
16+
<jar-plugin-version>3.1.1</jar-plugin-version>
17+
<jgit-plugin-version>1.2.10</jgit-plugin-version>
1718
</properties>
1819

1920
<dependencies>
@@ -40,7 +41,45 @@
4041
</dependencies>
4142

4243
<build>
44+
<resources>
45+
<resource>
46+
<directory>src/main/resources</directory>
47+
<filtering>true</filtering>
48+
<includes>
49+
<include>version-info.properties</include>
50+
</includes>
51+
</resource>
52+
<resource>
53+
<directory>src/main/resources</directory>
54+
<filtering>false</filtering>
55+
<excludes>
56+
<exclude>version-info.properties</exclude>
57+
</excludes>
58+
</resource>
59+
</resources>
4360
<plugins>
61+
<!--<plugin>-->
62+
<!--<groupId>org.apache.maven.plugins</groupId>-->
63+
<!--<artifactId>maven-resources-plugin</artifactId>-->
64+
<!--<version>3.1.0</version>-->
65+
<!--</plugin>-->
66+
<plugin>
67+
<groupId>org.apache.maven.plugins</groupId>
68+
<artifactId>maven-jar-plugin</artifactId>
69+
<version>${jar-plugin-version}</version>
70+
<configuration>
71+
<finalName>${project.artifactId}</finalName>
72+
<archive>
73+
<manifest>
74+
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
75+
</manifest>
76+
<manifestEntries>
77+
<project-name>${project.artifactId}</project-name>
78+
<project-version>${project.version}</project-version>
79+
</manifestEntries>
80+
</archive>
81+
</configuration>
82+
</plugin>
4483
<plugin>
4584
<groupId>org.codehaus.mojo</groupId>
4685
<artifactId>exec-maven-plugin</artifactId>
@@ -57,40 +96,68 @@
5796
<configuration>
5897
<executable>java</executable>
5998
<arguments>
60-
<!--<argument>-Dpicocli.autocomplete.systemExitOnError</argument>-->
6199
<argument>-cp</argument>
62100
<classpath/>
63101
<argument>picocli.AutoComplete</argument>
64102
<argument>--force</argument><!-- overwrite if exists -->
65-
<!--<argument>&#45;&#45;writeCommandScript</argument>-->
66103
<argument>--completionScript</argument>
67104
<argument>${project.build.directory}/imagebuilder_completion.sh</argument>
68105
<argument>com.oracle.weblogicx.imagebuilder.cli.CLIDriver</argument>
69-
<!-- replace with your class -->
70106
</arguments>
71107
</configuration>
72108
</plugin>
109+
<plugin>
110+
<groupId>org.codehaus.mojo</groupId>
111+
<artifactId>flatten-maven-plugin</artifactId>
112+
<version>1.1.0</version>
113+
<configuration>
114+
<!-- Override parent POM configuration and flatten the POM published for the zip installer -->
115+
<updatePomFile>true</updatePomFile>
116+
<pomElements>
117+
<repositories>flatten</repositories>
118+
<dependencies>remove</dependencies>
119+
</pomElements>
120+
</configuration>
121+
<executions>
122+
<!-- enable flattening -->
123+
<execution>
124+
<id>flatten</id>
125+
<phase>process-resources</phase>
126+
<goals>
127+
<goal>flatten</goal>
128+
</goals>
129+
</execution>
130+
<!-- ensure proper cleanup -->
131+
<execution>
132+
<id>flatten.clean</id>
133+
<phase>clean</phase>
134+
<goals>
135+
<goal>clean</goal>
136+
</goals>
137+
</execution>
138+
</executions>
139+
</plugin>
73140
<plugin>
74141
<groupId>org.apache.maven.plugins</groupId>
75-
<artifactId>maven-shade-plugin</artifactId>
76-
<version>${shade-plugin-version}</version>
142+
<artifactId>maven-assembly-plugin</artifactId>
77143
<executions>
78144
<execution>
145+
<id>build-zip-installer</id>
79146
<phase>package</phase>
80147
<goals>
81-
<goal>shade</goal>
148+
<goal>single</goal>
82149
</goals>
83150
<configuration>
84-
<!--<artifactSet>-->
85-
<!--<excludes>-->
86-
<!--<exclude>classworlds:classworlds</exclude>-->
87-
<!--<exclude>junit:junit</exclude>-->
88-
<!--<exclude>jmock:*</exclude>-->
89-
<!--<exclude>*:xml-apis</exclude>-->
90-
<!--<exclude>org.apache.maven:lib:tests</exclude>-->
91-
<!--<exclude>log4j:log4j:jar:</exclude>-->
92-
<!--</excludes>-->
93-
<!--</artifactSet>-->
151+
<descriptors>
152+
<descriptor>src/assembly/zip.xml</descriptor>
153+
</descriptors>
154+
<archiveBaseDirectory>${project.basedir}</archiveBaseDirectory>
155+
<appendAssemblyId>false</appendAssemblyId>
156+
<archiverConfig>
157+
<directoryMode>0750</directoryMode>
158+
<defaultDirectoryMode>0750</defaultDirectoryMode>
159+
<fileMode>0640</fileMode>
160+
</archiverConfig>
94161
</configuration>
95162
</execution>
96163
</executions>

src/assembly/zip.xml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!--
2+
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
3+
The Universal Permissive License (UPL), Version 1.0
4+
-->
5+
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
6+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7+
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
8+
<id>zip</id>
9+
<formats>
10+
<format>zip</format>
11+
</formats>
12+
13+
<fileSets>
14+
<fileSet>
15+
<directory>src/main/bin</directory>
16+
<outputDirectory>bin</outputDirectory>
17+
<includes>
18+
<include>*.sh</include>
19+
</includes>
20+
<fileMode>0750</fileMode>
21+
<lineEnding>unix</lineEnding>
22+
</fileSet>
23+
<fileSet>
24+
<directory>..</directory>
25+
<outputDirectory>.</outputDirectory>
26+
<includes>
27+
<include>LICENSE.txt</include>
28+
</includes>
29+
</fileSet>
30+
<fileSet>
31+
<directory>target</directory>
32+
<outputDirectory>lib</outputDirectory>
33+
<includes>
34+
<include>*.jar</include>
35+
<include>*.sh</include>
36+
</includes>
37+
</fileSet>
38+
</fileSets>
39+
<dependencySets>
40+
<dependencySet>
41+
<outputDirectory>lib</outputDirectory>
42+
<unpack>false</unpack>
43+
<excludes>
44+
<exclude>${artifact}</exclude>
45+
</excludes>
46+
</dependencySet>
47+
</dependencySets>
48+
</assembly>

src/main/bin/setup.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
umask 27
3+
#
4+
# Make sure that the JAVA_HOME environment variable is set to point to a
5+
# JDK 8 or higher JVM (and that it isn't OpenJDK).
6+
#
7+
if [ "${JAVA_HOME}" = "" ]; then
8+
echo "Please set the JAVA_HOME environment variable to point to a Java 8 installation" >&2
9+
exit 2
10+
elif [ ! -d "${JAVA_HOME}" ]; then
11+
echo "Your JAVA_HOME environment variable to points to a non-existent directory: ${JAVA_HOME}" >&2
12+
exit 2
13+
fi
14+
15+
if [ -x "${JAVA_HOME}/bin/java" ]; then
16+
JAVA_EXE=${JAVA_HOME}/bin/java
17+
else
18+
echo "Java executable at ${JAVA_HOME}/bin/java either does not exist or is not executable" >&2
19+
exit 2
20+
fi
21+
22+
JVM_OUTPUT=`${JAVA_EXE} -version 2>&1`
23+
case "${JVM_OUTPUT}" in
24+
*OpenJDK*)
25+
echo "JAVA_HOME ${JAVA_HOME} contains OpenJDK, which is not supported" >&2
26+
exit 2
27+
;;
28+
esac
29+
30+
function read_link() {
31+
PREV_DIR=`pwd`
32+
CHASE_LINK=$1
33+
cd `dirname $CHASE_LINK`
34+
CHASE_LINK=`basename $CHASE_LINK`
35+
while [ -L "$CHASE_LINK" ]
36+
do
37+
CHASE_LINK=`readlink $CHASE_LINK`
38+
cd `dirname $CHASE_LINK`
39+
CHASE_LINK=`basename $CHASE_LINK`
40+
done
41+
_DIR=`pwd -P`
42+
RESULT_PATH=$_DIR/$CHASE_LINK
43+
cd $PREV_DIR
44+
echo $RESULT_PATH
45+
}
46+
47+
unalias imagebuilder 2> /dev/null
48+
script_dir=$( dirname "$( read_link "${BASH_SOURCE[-1]}" )" )
49+
IMAGEBUILDER_HOME=`cd "${script_dir}/.." ; pwd`
50+
export IMAGEBUILDER_HOME
51+
alias imagebuilder="${JAVA_HOME}/bin/java -cp \"${IMAGEBUILDER_HOME}/lib/*\" com.oracle.weblogicx.imagebuilder.cli.CLIDriver"
52+
source ${IMAGEBUILDER_HOME}/lib/imagebuilder_completion.sh

src/main/java/com/oracle/weblogicx/imagebuilder/api/model/DomainType.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@ public enum DomainType {
1919
this.value = value;
2020
}
2121

22-
/*
23-
@Override
24-
public String toString() {
25-
return value;
26-
}
27-
*/
28-
2922
public static DomainType fromValue(String value) {
3023
for (DomainType eachType : DomainType.values()) {
3124
if (eachType.value.equalsIgnoreCase(value)) {

src/main/java/com/oracle/weblogicx/imagebuilder/cli/CLIDriver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
mixinStandardHelpOptions = true,
2121
description = "%nA tool to build docker images of WebLogic with selected " +
2222
"patches and/or psu(s) applied.%n",
23-
version = "1.0",
23+
versionProvider = HelpVersionProvider.class,
2424
sortOptions = false,
2525
subcommands = {
2626
CacheCLI.class,
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.oracle.weblogicx.imagebuilder.cli;
2+
3+
import picocli.CommandLine.IVersionProvider;
4+
5+
import java.io.InputStream;
6+
import java.util.ArrayList;
7+
import java.util.List;
8+
import java.util.Properties;
9+
10+
public class HelpVersionProvider implements IVersionProvider {
11+
12+
@Override
13+
public String[] getVersion() throws Exception {
14+
List<String> retList = new ArrayList<>();
15+
try (InputStream versionInfoStream = this.getClass().getResourceAsStream("/version-info.properties")) {
16+
if (versionInfoStream != null) {
17+
Properties versionProps = new Properties();
18+
versionProps.load(versionInfoStream);
19+
retList.add(String.format("%s:%s", versionProps.getProperty("project_name", "imagebuilder"),
20+
versionProps.getProperty("project_version", "0.0")));
21+
}
22+
}
23+
return retList.toArray(new String[0]);
24+
}
25+
}

src/main/java/com/oracle/weblogicx/imagebuilder/cli/cache/AddInstallerEntry.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import com.oracle.weblogicx.imagebuilder.api.model.CommandResponse;
88
import com.oracle.weblogicx.imagebuilder.api.model.InstallerType;
9-
import com.oracle.weblogicx.imagebuilder.util.Constants;
109
import com.oracle.weblogicx.imagebuilder.util.Utils;
1110
import picocli.CommandLine.Command;
1211
import picocli.CommandLine.Option;

src/main/java/com/oracle/weblogicx/imagebuilder/cli/cache/CacheCLI.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package com.oracle.weblogicx.imagebuilder.cli.cache;
66

77
import com.oracle.weblogicx.imagebuilder.api.model.CommandResponse;
8+
import com.oracle.weblogicx.imagebuilder.cli.HelpVersionProvider;
89
import picocli.CommandLine.Command;
910
import picocli.CommandLine.HelpCommand;
1011
import picocli.CommandLine.Model.CommandSpec;
@@ -17,6 +18,7 @@
1718
@Command(
1819
name = "cache",
1920
description = "List and set cache options",
21+
versionProvider = HelpVersionProvider.class,
2022
commandListHeading = "%nCommands:%n%n",
2123
subcommands = {
2224
ListCacheItems.class,

src/main/java/com/oracle/weblogicx/imagebuilder/cli/cache/CacheOperation.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ public abstract class CacheOperation implements Callable<CommandResponse> {
2626
this.isCLIMode = isCLIMode;
2727
}
2828

29-
// @Option(
30-
// names = {"--cacheStoreType"},
31-
// description = "Whether to use file backed cache store or preferences backed cache store. Ex: file or pref",
32-
// hidden = true,
33-
// defaultValue = "file"
34-
// )
3529
protected CacheStore cacheStore = new CacheStoreFactory().get();
3630

3731
@Unmatched

0 commit comments

Comments
 (0)