Skip to content

Commit 793cd17

Browse files
authored
code cleanup from static code checks (#157)
* code cleanup from static code checks * removed exception eaters from FileCacheStore * moved integration tests to its own module, and added Jacoco code coverage plugin * change logging format of integration tests to match operator tests * force sync local and remote repos * move copyright check inline to the checkstyle rules * moved installer creation to its own module * enforce user credentials for verify phase where integration tests are run * separate artifacts from same groupId as WDT * remove flatten-pom plugin
1 parent 8b8f1a5 commit 793cd17

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+837
-594
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@
66
!.idea/codeStyles/codeStyleConfig.xml
77
**/target
88
**/.DS_Store
9-
.flattened-pom.xml

.mvn/maven.config-template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Dtest.dependency.dir=/some/folder/with/installers

Jenkinsfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ pipeline {
99
}
1010

1111
environment {
12-
WLSIMG_BLDDIR = "${env.WORKSPACE}/imagetool/target/build"
13-
WLSIMG_CACHEDIR = "${env.WORKSPACE}/imagetool/target/cache"
12+
STAGING_DIR = "/scratch/artifacts/imagetool"
1413
}
1514

1615
stages {
@@ -25,7 +24,7 @@ pipeline {
2524
}
2625
stage ('Build') {
2726
steps {
28-
sh 'mvn -B -DskipTests clean package'
27+
sh 'mvn -B -DskipTests -DskipITs clean install'
2928
}
3029
}
3130
stage ('Test') {
@@ -44,12 +43,12 @@ pipeline {
4443
}
4544
steps {
4645
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'otn-cred', passwordVariable: 'ORACLE_SUPPORT_PASSWORD', usernameVariable: 'ORACLE_SUPPORT_USERNAME']]) {
47-
sh 'mvn verify'
46+
sh 'mvn verify -Dtest.staging.dir=${STAGING_DIR}'
4847
}
4948
}
5049
post {
5150
always {
52-
junit 'imagetool/target/failsafe-reports/*.xml'
51+
junit 'tests/target/failsafe-reports/*.xml'
5352
}
5453
}
5554
}

build-tools/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<project>
55
<modelVersion>4.0.0</modelVersion>
66

7-
<groupId>com.oracle.weblogic.lifecycle</groupId>
7+
<groupId>com.oracle.weblogic.lifecycle.imagetool</groupId>
88
<artifactId>build-tools</artifactId>
99
<version>1.2</version>
1010
<name>Build Tools</name>

build-tools/src/main/resources/weblogic-image-tool/checkstyle/customized_google_checks.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</module>
4242

4343
<module name="RegexpHeader">
44-
<property name="headerFile" value="build-tools/src/main/resources/weblogic-image-tool/checkstyle/java.header"/>
44+
<property name="header" value="^// Copyright \(c\) (\d\d\d\d, )+Oracle Corporation and\/or its affiliates\.$\n^// Licensed under the Universal Permissive License v 1\.0 as shown at https://oss\.oracle\.com/licenses/upl\.$"/>
4545
<property name="fileExtensions" value="java"/>
4646
</module>
4747

build-tools/src/main/resources/weblogic-image-tool/checkstyle/java.header

Lines changed: 0 additions & 2 deletions
This file was deleted.

imagetool/pom.xml

Lines changed: 18 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@
88
<modelVersion>4.0.0</modelVersion>
99

1010
<artifactId>imagetool</artifactId>
11-
<name>WebLogic Image Tool</name>
11+
<name>Image Tool Core</name>
1212

1313
<parent>
1414
<artifactId>imagetool-parent</artifactId>
15-
<groupId>com.oracle.weblogic.lifecycle</groupId>
15+
<groupId>com.oracle.weblogic.lifecycle.imagetool</groupId>
1616
<version>1.8.5-SNAPSHOT</version>
1717
<relativePath>../pom.xml</relativePath>
1818
</parent>
1919

20+
<properties>
21+
<sonar.coverage.jacoco.xmlReportPaths>${basedir}/../${aggregate.report.dir}</sonar.coverage.jacoco.xmlReportPaths>
22+
</properties>
23+
2024
<dependencies>
2125
<dependency>
2226
<groupId>org.apache.httpcomponents</groupId>
@@ -73,6 +77,18 @@
7377
</resource>
7478
</resources>
7579
<plugins>
80+
<plugin>
81+
<groupId>org.jacoco</groupId>
82+
<artifactId>jacoco-maven-plugin</artifactId>
83+
<executions>
84+
<execution>
85+
<id>prepare-agent</id>
86+
<goals>
87+
<goal>prepare-agent</goal>
88+
</goals>
89+
</execution>
90+
</executions>
91+
</plugin>
7692
<plugin>
7793
<groupId>org.apache.maven.plugins</groupId>
7894
<artifactId>maven-jar-plugin</artifactId>
@@ -102,73 +118,10 @@
102118
</arguments>
103119
</configuration>
104120
</plugin>
105-
<plugin>
106-
<groupId>org.codehaus.mojo</groupId>
107-
<artifactId>flatten-maven-plugin</artifactId>
108-
</plugin>
109-
<plugin>
110-
<groupId>org.apache.maven.plugins</groupId>
111-
<artifactId>maven-assembly-plugin</artifactId>
112-
<executions>
113-
<execution>
114-
<id>build-zip-installer</id>
115-
<phase>package</phase>
116-
<goals>
117-
<goal>single</goal>
118-
</goals>
119-
<configuration>
120-
<finalName>${installer-name}</finalName>
121-
<descriptors>
122-
<descriptor>src/assembly/zip.xml</descriptor>
123-
</descriptors>
124-
<archiveBaseDirectory>${project.basedir}</archiveBaseDirectory>
125-
<appendAssemblyId>false</appendAssemblyId>
126-
<archiverConfig>
127-
<directoryMode>0750</directoryMode>
128-
<defaultDirectoryMode>0750</defaultDirectoryMode>
129-
<fileMode>0640</fileMode>
130-
</archiverConfig>
131-
</configuration>
132-
</execution>
133-
</executions>
134-
</plugin>
135121
<plugin>
136122
<groupId>org.apache.maven.plugins</groupId>
137123
<artifactId>maven-checkstyle-plugin</artifactId>
138124
</plugin>
139-
<plugin>
140-
<groupId>org.apache.maven.plugins</groupId>
141-
<artifactId>maven-failsafe-plugin</artifactId>
142-
<configuration>
143-
<encoding>UTF-8</encoding>
144-
<failIfNoTests>false</failIfNoTests>
145-
<argLine>
146-
-Xmx1024m -XX:MaxPermSize=256m
147-
</argLine>
148-
<systemProperties>
149-
<property>
150-
<name>imagetoolversion</name>
151-
<value>${project.version}</value>
152-
</property>
153-
</systemProperties>
154-
</configuration>
155-
<executions>
156-
<execution>
157-
<id>integration-tests</id>
158-
<goals>
159-
<goal>integration-test</goal>
160-
<goal>verify</goal>
161-
</goals>
162-
<phase>integration-test</phase>
163-
<configuration>
164-
<systemPropertyVariables>
165-
<java.util.logging.SimpleFormatter.format>%1$tm-%1$td-%1$tY %1$tH:%1$tM:%1$tS %4$-6s %2$s %5$s%6$s%n</java.util.logging.SimpleFormatter.format>
166-
</systemPropertyVariables>
167-
<trimStackTrace>false</trimStackTrace>
168-
</configuration>
169-
</execution>
170-
</executions>
171-
</plugin>
172125
</plugins>
173126
</build>
174127
</project>

imagetool/src/main/java/com/oracle/weblogic/imagetool/api/model/CachedFile.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ public Path copyFile(CacheStore cacheStore, String buildContextDir) throws IOExc
112112
try {
113113
result = Files.copy(Paths.get(sourceFile), Paths.get(buildContextDir, targetFilename));
114114
} catch (Exception ee) {
115-
ee.printStackTrace();
115+
String msg = Utils.getMessage("IMG-0064", sourceFile, buildContextDir);
116+
logger.severe(msg);
117+
logger.fine(msg, ee);
118+
throw ee;
116119
}
117120
logger.exiting(result);
118121
return result;

imagetool/src/main/java/com/oracle/weblogic/imagetool/api/model/CommandResponse.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ public class CommandResponse {
99

1010
private int status;
1111
private String message;
12-
private Object result;
1312
private Object[] messageParams;
1413

1514
/**

imagetool/src/main/java/com/oracle/weblogic/imagetool/cachestore/CacheStore.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,21 @@ public interface CacheStore {
4545
*
4646
* @param key artifact identifier
4747
* @param value a file path
48-
* @return true if add is successful
4948
*/
50-
boolean addToCache(String key, String value);
49+
void addToCache(String key, String value) throws CacheStoreException;
5150

5251
/**
5352
* Delete an entry from the cache.
5453
*
5554
* @param key key corresponding to an entry in the cache
5655
* @return value or null
5756
*/
58-
String deleteFromCache(String key);
57+
String deleteFromCache(String key) throws CacheStoreException;
58+
59+
/**
60+
* Delete all entries from the cache.
61+
*/
62+
void clearCache() throws CacheStoreException;
5963

6064
/**
6165
* Returns a map of current items in the cache.

0 commit comments

Comments
 (0)