Skip to content

Commit

Permalink
Changes according to the LFR Forum
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas Polesovsky committed Nov 3, 2009
1 parent ccd4cf7 commit b49a197
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 6 deletions.
Expand Up @@ -8,5 +8,15 @@
<packaging>war</packaging>
<version>${version}</version>
<name>${artifactId} - Liferay Layout</name>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
Expand Up @@ -53,6 +53,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<overlays>
<overlay>
<!-- empty groupId/artifactId is detected as the current build -->
Expand Down
4 changes: 2 additions & 2 deletions plugins/liferay-maven-plugin/pom.xml
Expand Up @@ -13,7 +13,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>com.commsen.liferay</groupId>
Expand Down Expand Up @@ -66,4 +66,4 @@
</plugins>
</build>

</project>
</project>
Expand Up @@ -7,7 +7,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -18,6 +18,7 @@

import java.io.File;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.util.List;

import org.apache.commons.io.FileUtils;
Expand Down Expand Up @@ -131,11 +132,56 @@ public void execute() throws MojoExecutionException {

File srcServiceProperties = new File(srcFolder, "service.properties");
File resServiceProperties = new File(resourcesFolder, "service.properties");
FileUtils.deleteQuietly(resServiceProperties);
BuildService.deleteQuietly(resServiceProperties);
try {
FileUtils.moveFile(srcServiceProperties, resServiceProperties);
BuildService.moveFile(srcServiceProperties, resServiceProperties);
} catch (IOException e) {
getLog().warn(e);
}
}

public static boolean deleteQuietly(File file) {
if (file == null) {
return false;
}

try {
return file.delete();
} catch (Exception e) {
return false;
}
}

public static void moveFile(File srcFile, File destFile) throws IOException {
if (srcFile == null) {
throw new NullPointerException("Source must not be null");
}
if (destFile == null) {
throw new NullPointerException("Destination must not be null");
}
if (!srcFile.exists()) {
throw new FileNotFoundException("Source '" + srcFile + "' does not exist");
}
if (srcFile.isDirectory()) {
throw new IOException("Source '" + srcFile + "' is a directory");
}
if (destFile.exists()) {
throw new IOException("Destination '" + destFile + "' already exists");
}
if (destFile.isDirectory()) {
throw new IOException("Destination '" + destFile + "' is a directory");
}
boolean rename = srcFile.renameTo(destFile);
if (!rename) {
FileUtils.copyFile( srcFile, destFile );
if (!srcFile.delete()) {
deleteQuietly(destFile);
throw new IOException("Failed to delete original file '" + srcFile +
"' after copy to '" + destFile + "'");
}
}
}

}


0 comments on commit b49a197

Please sign in to comment.