Skip to content

Commit f89e7f7

Browse files
committed
Fix validation failures when building silversetup
1 parent f3881d2 commit f89e7f7

19 files changed

+85
-79
lines changed

src/main/groovy/org/silverpeas/setup/SilverpeasSetupExtension.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class SilverpeasSetupExtension {
9595
* Some of them are computed from the properties in the file <code>config.properties</code>.
9696
* Tasks can overwrite some of the settings as well as add their own properties.
9797
*/
98-
final Map settings = [:]
98+
final Map<String, String> settings = [:]
9999

100100
/**
101101
* Constructs a new silverpeas configuration extension. It checks the environment variables
@@ -129,7 +129,7 @@ class SilverpeasSetupExtension {
129129
settings.context = config.context.properties()
130130
}
131131

132-
void setSettings(final Map configProperties) {
132+
void setSettings(final Map<String, String> configProperties) {
133133
this.settings.putAll(configProperties)
134134
}
135135

src/main/groovy/org/silverpeas/setup/SilverpeasSetupPlugin.groovy

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ class SilverpeasSetupPlugin implements Plugin<Project> {
8181
Task jbossConf = project.tasks.create(CONFIGURE_JBOSS.name, JBossConfigurationTask) {
8282
it.driversDir = extension.installation.dsDriversDir.get()
8383
it.config = extension.config
84-
it.jboss = jBossServer
85-
it.settings = extension.settings
84+
it.jboss = jBossServer
85+
it.settings = extension.settings
8686
}
8787

8888
Task silverpeasConf = project.tasks.create(CONFIGURE_SILVERPEAS.name, SilverpeasConfigurationTask) {
8989
it.silverpeasHome = extension.silverpeasHome
90-
it.config = extension.config
91-
it.settings = extension.settings
90+
it.config = extension.config
91+
it.settings = extension.settings
9292
}.dependsOn(construction)
9393

9494
Task configuration = project.tasks.create(CONFIGURE.name) {
@@ -101,8 +101,8 @@ class SilverpeasSetupPlugin implements Plugin<Project> {
101101
}.dependsOn(construction)
102102

103103
Task migration = project.tasks.create(MIGRATE.name, SilverpeasMigrationTask) {
104-
it.migration = extension.migration
105-
it.settings = extension.settings
104+
it.migration = extension.migration
105+
it.settings = extension.settings
106106
}.dependsOn(configuration)
107107

108108
project.tasks.create(INSTALL.name, SilverpeasInstallationTask) {
@@ -121,30 +121,32 @@ class SilverpeasSetupPlugin implements Plugin<Project> {
121121
* @param project the Gradle project that uses the plugin
122122
* @param extension the project extension of the plugin
123123
*/
124-
private void setUpGradleAssemblingTaskForThisPlugin(Project project,
125-
SilverpeasSetupExtension extension) {
124+
private static void setUpGradleAssemblingTaskForThisPlugin(Project project,
125+
SilverpeasSetupExtension extension) {
126126
try {
127127
Task assemble = project.tasks.getByName(ASSEMBLE.name).doLast {
128128
if (!extension.installation.distDir.get().exists()) {
129129
extension.installation.distDir.get().mkdirs()
130130
}
131131
SilverpeasBuilder builder = new SilverpeasBuilder(project, FileLogger.getLogger(delegate.name))
132132
builder.driversDir = extension.installation.dsDriversDir.get()
133-
builder.silverpeasHome = extension.silverpeasHome
133+
builder.silverpeasHome = extension.silverpeasHome.get()
134134
builder.settings = extension.settings
135135
builder.extractSoftwareBundles(extension.installation.bundles,
136136
extension.installation.distDir.get())
137137
}
138138
assemble.description = 'Assemble all the software bundles that made Silverpeas'
139-
assemble.onlyIf { !extension.installation.distDir.get().exists() &&
140-
!extension.installation.dsDriversDir.get().exists()
139+
assemble.onlyIf {
140+
!extension.installation.distDir.get().exists() &&
141+
!extension.installation.dsDriversDir.get().exists()
141142
}
142143
assemble.outputs.upToDateWhen {
143144
extension.installation.distDir.get().exists() &&
144145
extension.installation.dsDriversDir.get().exists()
145146
}
146147
} catch (UnknownTaskException e) {
147148
// nothing to do
149+
println e.message
148150
}
149151
}
150152

@@ -155,12 +157,12 @@ class SilverpeasSetupPlugin implements Plugin<Project> {
155157
* @param project the Gradle project
156158
* @param extension the project extension of the plugin
157159
*/
158-
private void setUpGradleBuildTaskForThisPlugin(Project project,
159-
SilverpeasSetupExtension extension) {
160+
private static void setUpGradleBuildTaskForThisPlugin(Project project,
161+
SilverpeasSetupExtension extension) {
160162
try {
161163
Task build = project.tasks.getByName(BUILD.name).doLast {
162164
SilverpeasBuilder builder = new SilverpeasBuilder(project, FileLogger.getLogger(delegate.name))
163-
builder.silverpeasHome = extension.silverpeasHome
165+
builder.silverpeasHome = extension.silverpeasHome.get()
164166
builder.settings = extension.settings
165167
builder.developmentMode = extension.installation.developmentMode.get()
166168
builder.generateSilverpeasApplication(extension.installation.distDir.get())
@@ -180,6 +182,7 @@ class SilverpeasSetupPlugin implements Plugin<Project> {
180182
}
181183
} catch (UnknownTaskException e) {
182184
// nothing to do
185+
println e.message
183186
}
184187
}
185188

@@ -190,7 +193,7 @@ class SilverpeasSetupPlugin implements Plugin<Project> {
190193
* @return the project extension of the plugin
191194
*/
192195
private SilverpeasSetupExtension createSilverpeasSetupExtention(Project project) {
193-
def extension = project.extensions.create(EXTENSION, SilverpeasSetupExtension, project)
196+
SilverpeasSetupExtension extension = project.extensions.create(EXTENSION, SilverpeasSetupExtension, project)
194197
extension.settings = loadConfigurationProperties(extension.config.configurationHome.get())
195198
completeSettings(extension.settings, extension)
196199
encryptAdminPassword(extension.settings)
@@ -205,8 +208,8 @@ class SilverpeasSetupPlugin implements Plugin<Project> {
205208
* @param jBossServer the JBoss server wrapper to initialize with some of the plugin's input
206209
* properties exposed to the project.
207210
*/
208-
private void initializePluginParameters(Project project,
209-
JBossServer jBossServer) {
211+
private static void initializePluginParameters(Project project,
212+
JBossServer jBossServer) {
210213
project.afterEvaluate { Project currentProject, ProjectState state ->
211214
SilverpeasSetupExtension extension =
212215
(SilverpeasSetupExtension) currentProject.extensions.getByName(EXTENSION)
@@ -228,7 +231,7 @@ class SilverpeasSetupPlugin implements Plugin<Project> {
228231
* the String value.
229232
* @param extension the project extension of the plugin
230233
*/
231-
private void registerManagedBeansForScripts(SilverpeasSetupExtension extension) {
234+
private static void registerManagedBeansForScripts(SilverpeasSetupExtension extension) {
232235
SilverpeasSetupService setupService = new SilverpeasSetupService(extension.settings)
233236
String.metaClass.asPath = { Paths.get(setupService.expanseVariables(delegate.toString())) }
234237
ManagedBeanContainer.registry()
@@ -266,7 +269,7 @@ class SilverpeasSetupPlugin implements Plugin<Project> {
266269
* @param settings the settings to complete/
267270
* @param extension the project extension of the plugin
268271
*/
269-
private void completeSettings(Map settings, SilverpeasSetupExtension extension) {
272+
private static void completeSettings(Map<String, String> settings, SilverpeasSetupExtension extension) {
270273
settings.SILVERPEAS_HOME = normalizePath(extension.silverpeasHome.path)
271274
settings.MIGRATION_HOME = normalizePath(extension.migration.homeDir.get().path)
272275
settings.CONFIGURATION_HOME = normalizePath(extension.config.configurationHome.get().path)
@@ -320,7 +323,7 @@ class SilverpeasSetupPlugin implements Plugin<Project> {
320323
* Replaces the administrator password set in the specified settings by its encrypted counterpart.
321324
* @param settings the settings with the administrator password.
322325
*/
323-
private void encryptAdminPassword(Map settings) {
326+
private static void encryptAdminPassword(Map<String, String> settings) {
324327
Encryption encryption = EncryptionFactory.instance.createDefaultEncryption()
325328
settings.SILVERPEAS_ADMIN_PASSWORD = encryption.encrypt(settings.SILVERPEAS_ADMIN_PASSWORD)
326329
}
@@ -330,7 +333,7 @@ class SilverpeasSetupPlugin implements Plugin<Project> {
330333
* @param project the Gradle project
331334
* @param loggingProperties the logging properties.
332335
*/
333-
private void initLogging(Project project, SilverpeasLoggingProperties loggingProperties) {
336+
private static void initLogging(Project project, SilverpeasLoggingProperties loggingProperties) {
334337
String timestamp = new Date().format('yyyyMMdd_HHmmss')
335338
if (!loggingProperties.logDir.exists()) {
336339
loggingProperties.logDir.mkdirs()

src/main/groovy/org/silverpeas/setup/TaskEventLogging.groovy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class TaskEventLogging extends BuildAdapter implements TaskExecutionListener {
5050

5151
private buildStarted = false
5252
private List<String> executedTasks = []
53-
private long startTimestamp;
53+
private long startTimestamp
5454

5555
TaskEventLogging() {
5656
startTimestamp = System.currentTimeMillis()
@@ -120,7 +120,7 @@ class TaskEventLogging extends BuildAdapter implements TaskExecutionListener {
120120
result.rethrowFailure()
121121
}
122122

123-
private String unformat(String name) {
123+
private static String unformat(String name) {
124124
StringBuilder str = new StringBuilder()
125125
str.append(name.charAt(0).toUpperCase())
126126
for (int i = 1; i < name.length(); i++) {
@@ -133,7 +133,7 @@ class TaskEventLogging extends BuildAdapter implements TaskExecutionListener {
133133
return str.toString()
134134
}
135135

136-
private void outputTask(String taskTitle) {
136+
private static void outputTask(String taskTitle) {
137137
StringBuilder result = new StringBuilder("${taskTitle}... ")
138138
int charToAdd = 20 - result.length()
139139
for (int i = 0; i < charToAdd; i++) {
@@ -142,7 +142,7 @@ class TaskEventLogging extends BuildAdapter implements TaskExecutionListener {
142142
print result.toString()
143143
}
144144

145-
private void outputStatus(String status) {
145+
private static void outputStatus(String status) {
146146
println " ${status}"
147147
}
148148
}

src/main/groovy/org/silverpeas/setup/api/AbstractScript.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ abstract class AbstractScript implements Script {
3232

3333
protected File script
3434
protected FileLogger logger
35-
protected Map settings
35+
protected Map<String, String> settings
3636

3737
/**
3838
* Constructs a new script instance that refers the script located at the specified path.
@@ -59,7 +59,7 @@ abstract class AbstractScript implements Script {
5959
* @return itself.
6060
*/
6161
@Override
62-
AbstractScript useSettings(final Map settings) {
62+
AbstractScript useSettings(final Map<String, String> settings) {
6363
this.settings = settings
6464
return this
6565
}
@@ -160,6 +160,6 @@ abstract class AbstractScript implements Script {
160160
*/
161161
@Override
162162
boolean equals(final Object obj) {
163-
return (obj.class.name.equals(this.class.name) && obj.hashCode() == this.hashCode())
163+
return (obj.class.name == this.class.name && obj.hashCode() == this.hashCode())
164164
}
165165
}

src/main/groovy/org/silverpeas/setup/api/DataSourceProvider.groovy

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ class DataSourceProvider {
3636

3737
private final DataSource dataSource
3838

39-
DataSourceProvider(final Map settings) {
39+
DataSourceProvider(final Map<String, String> settings) {
4040
Objects.requireNonNull(settings)
41-
DriverAdapterCPDS cpds = new DriverAdapterCPDS();
42-
cpds.setDriver(settings.DB_DRIVER);
43-
cpds.setUrl(settings.DB_URL);
44-
cpds.setUser(settings.DB_USER);
45-
cpds.setPassword(settings.DB_PASSWORD);
46-
47-
SharedPoolDataSource tds = new SharedPoolDataSource();
48-
tds.setConnectionPoolDataSource(cpds);
49-
tds.setMaxTotal(10);
50-
tds.setDefaultMaxWaitMillis(50);
41+
DriverAdapterCPDS cpds = new DriverAdapterCPDS()
42+
cpds.setDriver(settings.DB_DRIVER)
43+
cpds.setUrl(settings.DB_URL)
44+
cpds.setUser(settings.DB_USER)
45+
cpds.setPassword(settings.DB_PASSWORD)
46+
47+
SharedPoolDataSource tds = new SharedPoolDataSource()
48+
tds.setConnectionPoolDataSource(cpds)
49+
tds.setMaxTotal(10)
50+
tds.setDefaultMaxWaitMillis(50)
5151
dataSource = tds
5252
}
5353
}

src/main/groovy/org/silverpeas/setup/api/FileLogger.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class FileLogger {
247247
}
248248

249249
private def getLogHandler() {
250-
return this.logHandler == null ? DEFAULT_LOG_HANDLER: this.logHandler;
250+
return this.logHandler == null ? DEFAULT_LOG_HANDLER: this.logHandler
251251
}
252252

253253
private FileLogger(String namespace) {

src/main/groovy/org/silverpeas/setup/api/GroovyScript.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class GroovyScript extends AbstractScript {
4949
* @throws RuntimeException if an error occurs during the execution of the script.
5050
*/
5151
@Override
52-
void run(Map args) throws RuntimeException {
52+
void run(Map<String, ?> args) throws RuntimeException {
5353
logger.info "${script.name} processing..."
5454
Binding parameters = new Binding()
5555
parameters.setVariable('settings', settings)

src/main/groovy/org/silverpeas/setup/api/JBossServer.groovy

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class JBossServer {
8080
}
8181
}
8282

83-
private void assertCommandSucceeds(command) throws AssertionError, InvalidObjectException {
83+
private static void assertCommandSucceeds(command) throws AssertionError, InvalidObjectException {
8484
String result = command.in.text
8585
if (command.exitValue() != 0 || result.contains('"outcome" => "failed"')) {
8686
boolean rollBacked = result.contains('"rolled-back" => true')
@@ -165,7 +165,7 @@ class JBossServer {
165165
* @return itself.
166166
*/
167167
JBossServer withStartingTimeout(long timeout) {
168-
if (this.timeout != null && this.timeout > 0) {
168+
if (this.timeout > 0) {
169169
this.timeout = timeout
170170
}
171171
return this
@@ -404,13 +404,13 @@ class JBossServer {
404404
* @throws RuntimeException if the adding of the artifact failed.
405405
*/
406406
void add(String artifactPath, String name, String context) throws RuntimeException {
407-
String normalizedArtifactPath = FilenameUtils.separatorsToUnix(artifactPath);
407+
String normalizedArtifactPath = FilenameUtils.separatorsToUnix(artifactPath)
408408
Path artifactTruePath = Paths.get(normalizedArtifactPath)
409409
boolean archive = Files.isRegularFile(artifactTruePath)
410410
if (!isInDeployments(name)) {
411411
Process proc = executeCliCommand(
412412
"/deployment=${name}:add(runtime-name=${context},content=[{path=>${normalizedArtifactPath},archive=${archive}}])",
413-
SystemUtils.IS_OS_WINDOWS);
413+
SystemUtils.IS_OS_WINDOWS)
414414
proc.waitFor()
415415
if (proc.exitValue() != 0 || !isInDeployments(name)) {
416416
throw new RuntimeException("Adding of ${name} in JBoss failed with exit code " +
@@ -537,9 +537,9 @@ class JBossServer {
537537
* @return the instance of the process which handles the CLI command execution.
538538
*/
539539
Process executeCliCommand(String commands, boolean wrapIntoDoubleQuotes = false) {
540-
String finalCommands = commands;
540+
String finalCommands = commands
541541
if (wrapIntoDoubleQuotes) {
542-
finalCommands = "\"" + finalCommands + "\"";
542+
finalCommands = "\"" + finalCommands + "\""
543543
}
544544
return new ProcessBuilder(cli, '--connect', finalCommands)
545545
.redirectErrorStream(true)

src/main/groovy/org/silverpeas/setup/api/JcrRepositoryFactory.groovy

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ package org.silverpeas.setup.api
2626
import groovy.xml.XmlUtil
2727
import org.apache.jackrabbit.core.RepositoryImpl
2828
import org.apache.jackrabbit.core.config.RepositoryConfig
29-
import org.gradle.api.Project
3029

3130
import javax.jcr.Repository
3231
import javax.jcr.RepositoryException
@@ -44,14 +43,13 @@ class JcrRepositoryFactory {
4443
private static final String JCR_CONFIG_FILE = '/repository.xml'
4544

4645
private File repositoryConf
47-
private Project project
4846

4947
private synchronized File getRepositoryConfiguration(Map settings) {
5048
if (!repositoryConf) {
5149
initJNDIContext()
5250
File destination = File.createTempFile('repository', 'xml')
5351

54-
SAXParserFactory factory = javax.xml.parsers.SAXParserFactory.newInstance()
52+
SAXParserFactory factory = SAXParserFactory.newInstance()
5553
factory.validating = false
5654
factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",
5755
false)
@@ -71,14 +69,14 @@ class JcrRepositoryFactory {
7169
return repositoryConf
7270
}
7371

74-
private void initJNDIContext() {
72+
private static void initJNDIContext() {
7573
DataSourceProvider dataSourceProvider = ManagedBeanContainer.get(DataSourceProvider)
76-
InitialContext ic = new InitialContext();
74+
InitialContext ic = new InitialContext()
7775
try {
7876
ic.lookup('java:/datasources/DocumentStore')
79-
} catch(NameNotFoundException ex) {
77+
} catch(NameNotFoundException e) {
8078
ic.createSubcontext('java:/datasources')
81-
ic.bind('java:/datasources/DocumentStore', dataSourceProvider.dataSource);
79+
ic.bind('java:/datasources/DocumentStore', dataSourceProvider.dataSource)
8280
}
8381
}
8482

@@ -89,15 +87,15 @@ class JcrRepositoryFactory {
8987
Repository createRepository(Map settings) {
9088
try {
9189
File repositoryConf = getRepositoryConfiguration(settings)
92-
Properties jcrProperties = new Properties();
90+
Properties jcrProperties = new Properties()
9391
jcrProperties.load(new FileInputStream(
94-
"${settings.SILVERPEAS_HOME}/properties/org/silverpeas/util/jcr.properties"));
95-
String jcrHomePath = jcrProperties[JCR_HOME];
92+
"${settings.SILVERPEAS_HOME}/properties/org/silverpeas/util/jcr.properties"))
93+
String jcrHomePath = jcrProperties[JCR_HOME]
9694

97-
RepositoryConfig config = RepositoryConfig.create(repositoryConf.path, jcrHomePath);
98-
return RepositoryImpl.create(config);
95+
RepositoryConfig config = RepositoryConfig.create(repositoryConf.path, jcrHomePath)
96+
return RepositoryImpl.create(config)
9997
} catch (IOException | RepositoryException ex) {
100-
throw new RuntimeException(ex.getMessage(), ex);
98+
throw new RuntimeException(ex.getMessage(), ex)
10199
}
102100
}
103101
}

0 commit comments

Comments
 (0)