Skip to content

Commit e270f92

Browse files
committed
Bug 8687
Fix a bug when generating the final persistence.xml: take into account both the silverpeas name and the silverpeas version in the jar files to include in the persistence.xml descriptor. Normalize some paths like JCR_HOME
1 parent c95ebf7 commit e270f92

File tree

6 files changed

+39
-29
lines changed

6 files changed

+39
-29
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class SilverpeasSetupExtension {
7070
* directory is deployed as such in the JBoss/Wildfly application server.
7171
* environment variable.
7272
*/
73-
final File distDir
73+
final Property<File> distDir
7474

7575
/**
7676
* The properties to access the configuration if Silverpeas in order to apply it to the
@@ -155,7 +155,8 @@ class SilverpeasSetupExtension {
155155
}
156156
migrationHome = project.file("${silverpeasHome.path}/migrations")
157157
deploymentDir = project.file("${silverpeasHome.path}/deployments")
158-
distDir = project.file("${project.buildDir}/dist")
158+
distDir = project.objects.property(File)
159+
distDir.set(new File(project.buildDir, "dist"))
159160
config = project.objects.newInstance(SilverpeasConfigurationProperties, project, silverpeasHome)
160161
logging = project.objects.newInstance(SilverpeasLoggingProperties)
161162
silverpeasBundles = project.files()

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,20 @@ class SilverpeasSetupPlugin implements Plugin<Project> {
136136
File driversDir) {
137137
try {
138138
Task assemble = project.tasks.getByName(ASSEMBLE.name).doLast {
139-
if (!extension.distDir.exists()) {
140-
extension.distDir.mkdirs()
139+
if (!extension.distDir.get().exists()) {
140+
extension.distDir.get().mkdirs()
141141
}
142142
SilverpeasBuilder builder = new SilverpeasBuilder(project, FileLogger.getLogger(delegate.name))
143143
builder.driversDir = extension.driversDir
144144
builder.silverpeasHome = extension.silverpeasHome
145145
builder.settings = extension.config.settings
146146
builder.extractSoftwareBundles(extension.silverpeasBundles.files,
147-
extension.tiersBundles.files, extension.distDir)
147+
extension.tiersBundles.files, extension.distDir.get())
148148
}
149149
assemble.description = 'Assemble all the software bundles that made Silverpeas'
150-
assemble.onlyIf { !extension.distDir.exists() && !driversDir.exists()}
150+
assemble.onlyIf { !extension.distDir.get().exists() && !driversDir.exists()}
151151
assemble.outputs.upToDateWhen {
152-
extension.distDir.exists() && driversDir.exists()
152+
extension.distDir.get().exists() && driversDir.exists()
153153
}
154154
} catch (UnknownTaskException e) {
155155
// nothing to do
@@ -163,16 +163,16 @@ class SilverpeasSetupPlugin implements Plugin<Project> {
163163
SilverpeasBuilder builder = new SilverpeasBuilder(project, FileLogger.getLogger(delegate.name))
164164
builder.silverpeasHome = extension.silverpeasHome
165165
builder.settings = extension.config.settings
166-
builder.developmentMode = extension.developmentMode
167-
builder.generateSilverpeasApplication(extension.distDir)
166+
builder.developmentMode = extension.developmentMode.get()
167+
builder.generateSilverpeasApplication(extension.distDir.get())
168168
}
169169
build.description = 'Build the Silverpeas Collaborative Web Application'
170170
build.onlyIf {
171-
extension.distDir.exists()
171+
extension.distDir.get().exists()
172172
}
173173
build.outputs.upToDateWhen {
174-
boolean ok = extension.distDir.exists() &&
175-
Files.exists(Paths.get(extension.distDir.path, 'WEB-INF', 'web.xml'))
174+
boolean ok = extension.distDir.get().exists() &&
175+
Files.exists(Paths.get(extension.distDir.get().path, 'WEB-INF', 'web.xml'))
176176
if (!extension.developmentMode) {
177177
ok = ok && Files.exists(
178178
Paths.get(project.buildDir.path, SilverpeasConstructionTask.SILVERPEAS_WAR))
@@ -210,9 +210,13 @@ class SilverpeasSetupPlugin implements Plugin<Project> {
210210
settings.SILVERPEAS_HOME = normalizePath(silverSetup.silverpeasHome.path)
211211
settings.MIGRATION_HOME = normalizePath(silverSetup.migrationHome.path)
212212
settings.CONFIGURATION_HOME = normalizePath(silverSetup.config.configurationHome.path)
213-
settings.DB_DATASOURCE_JNDI = 'java:/datasources/silverpeas'
214213
settings.SILVERPEAS_DATA_HOME = normalizePath(settings.SILVERPEAS_DATA_HOME)
215214
settings.SILVERPEAS_DATA_WEB = normalizePath(settings.SILVERPEAS_DATA_WEB)
215+
settings.JCR_HOME = normalizePath(settings.JCR_HOME)
216+
settings.SILVERPEAS_TEMP = normalizePath(settings.SILVERPEAS_TEMP)
217+
settings.SILVERPEAS_LOG = normalizePath(settings.SILVERPEAS_LOG)
218+
settings.HIDDEN_SILVERPEAS_DIR = normalizePath(settings.HIDDEN_SILVERPEAS_DIR)
219+
settings.DB_DATASOURCE_JNDI = 'java:/datasources/silverpeas'
216220
switch (settings.DB_SERVERTYPE) {
217221
case 'MSSQL':
218222
settings.DB_URL = "jdbc:jtds:sqlserver://${settings.DB_SERVER}:${settings.DB_PORT_MSSQL}/${settings.DB_NAME}"

src/main/groovy/org/silverpeas/setup/configuration/VariableReplacement.groovy

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,18 @@ class VariableReplacement {
6767
static final String parseExpression(String expression, Map variables) {
6868
def matching = expression =~ VARIABLE_PATTERN
6969
matching.each { token ->
70-
if (!token[1].startsWith('env') && !token[1].startsWith('sys')) {
71-
if (variables.containsKey(token[1])) {
72-
expression = expression.replace(token[0], variables[token[1]])
73-
} else {
74-
println "Error: no such variable ${token[1]}"
75-
throw new StopExecutionException("Error: no such variable ${token[1]}")
70+
try {
71+
if (!token[1].startsWith('env') && !token[1].startsWith('sys')) {
72+
if (variables.containsKey(token[1])) {
73+
expression = expression.replace(token[0], variables[token[1]])
74+
} else {
75+
println "Error: no such variable ${token[1]}"
76+
throw new StopExecutionException("Error: no such variable ${token[1]}")
77+
}
7678
}
79+
} catch (Exception e) {
80+
println "Error: cannot replace token ${token[0]} by value of ${token[1]}: ${variables[token[1]]}"
81+
throw e
7782
}
7883
}
7984
return expression

src/main/groovy/org/silverpeas/setup/construction/SilverpeasBuilder.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ class SilverpeasBuilder {
264264
Paths.get(sourceDir.path, 'WEB-INF', 'lib').toFile().list(new FilenameFilter() {
265265
@Override
266266
boolean accept(final File dir, final String name) {
267-
return name.endsWith("''${project.version}.jar")
267+
return name.startsWith('silverpeas') && name.endsWith("${settings.SILVERPEAS_VERSION}.jar")
268268
}
269269
}).each { jpaComponent ->
270270
persistence.'persistence-unit'.'jta-data-source' + {

src/main/groovy/org/silverpeas/setup/construction/SilverpeasConstructionTask.groovy

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class SilverpeasConstructionTask extends DefaultTask {
4444

4545
File silverpeasHome
4646
File driversDir
47-
File destinationDir
4847
Map settings
48+
final Property<File> destinationDir = project.objects.property(File)
4949
final ConfigurableFileCollection silverpeasBundles = project.files()
5050
final ConfigurableFileCollection tiersBundles = project.files()
5151
final Property<Boolean> developmentMode = project.objects.property(Boolean)
@@ -63,11 +63,11 @@ class SilverpeasConstructionTask extends DefaultTask {
6363
}
6464

6565
boolean precondition() {
66-
!destinationDir.exists() && !driversDir.exists()
66+
!destinationDir.get().exists() && !driversDir.exists()
6767
}
6868

6969
boolean isUpToDate() {
70-
boolean ok = destinationDir.exists() && driversDir.exists()
70+
boolean ok = destinationDir.get().exists() && driversDir.exists()
7171
if (!developmentMode.get()) {
7272
ok = ok && Files.exists(Paths.get(project.buildDir.path, SILVERPEAS_WAR))
7373
}
@@ -84,8 +84,8 @@ class SilverpeasConstructionTask extends DefaultTask {
8484

8585
@TaskAction
8686
void construct() {
87-
if (!destinationDir.exists()) {
88-
destinationDir.mkdirs()
87+
if (!destinationDir.get().exists()) {
88+
destinationDir.get().mkdirs()
8989
}
9090
if (!driversDir.exists()) {
9191
driversDir.mkdirs()
@@ -95,8 +95,8 @@ class SilverpeasConstructionTask extends DefaultTask {
9595
builder.silverpeasHome = silverpeasHome
9696
builder.developmentMode = developmentMode.get()
9797
builder.settings = settings
98-
builder.extractSoftwareBundles(silverpeasBundles.files, tiersBundles.files, destinationDir)
99-
builder.generateSilverpeasApplication(destinationDir)
98+
builder.extractSoftwareBundles(silverpeasBundles.files, tiersBundles.files, destinationDir.get())
99+
builder.generateSilverpeasApplication(destinationDir.get())
100100
}
101101

102102
}

src/main/groovy/org/silverpeas/setup/installation/SilverpeasInstallationTask.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class SilverpeasInstallationTask extends DefaultTask {
4242

4343
Property<JBossServer> jboss = project.objects.property(JBossServer)
4444
File deploymentDir
45-
File distDir
45+
final Property<File> distDir = project.objects.property(File)
4646
final Property<Boolean> developmentMode = project.objects.property(Boolean)
4747
final FileLogger log = FileLogger.getLogger(this.name)
4848

@@ -86,7 +86,7 @@ class SilverpeasInstallationTask extends DefaultTask {
8686
if (developmentMode.get()) {
8787
log.info '(Re)Installation of silverpeas.war as exploded (dev mode)'
8888
server.remove(SILVERPEAS_WAR)
89-
server.add(distDir.path, SILVERPEAS_WAR)
89+
server.add(distDir.get().path, SILVERPEAS_WAR)
9090
server.deploy(SILVERPEAS_WAR)
9191
log.info '(Re)Installation of silverpeas.war as exploded (dev mode): [OK]'
9292
}

0 commit comments

Comments
 (0)