mirror of
https://github.com/Alfresco/alfresco-sdk.git
synced 2025-05-12 17:05:08 +00:00
Fixed issue #5 - added a hardcoded file-mappings.properties that allows overriding resources in /WEB-INF/ (which is not recommended, but may be necessary in some cases).
git-svn-id: http://maven-alfresco-archetypes.googlecode.com/svn/trunk@338 04253f4f-3451-0410-a141-5562f1e59037
This commit is contained in:
parent
c6c2f0cf39
commit
2ee4244cb0
@ -11,7 +11,9 @@ import org.codehaus.plexus.util.DirectoryScanner;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* Handles the project own resources, that is:
|
||||
@ -29,11 +31,16 @@ public class AmpProjectPackagingTask
|
||||
extends AbstractAmpPackagingTask
|
||||
{
|
||||
private static final String MODULE_PROPERTIES = "module.properties";
|
||||
private static final String FILE_MAPPINGS = "file-mappings.properties";
|
||||
|
||||
private static final String WEB_PATH = "web/";
|
||||
|
||||
private static final String CONFIG_PATH = "config/";
|
||||
|
||||
private static final String FILE_MAPPINGS_CONTENT = "# Add mapping for /WEB-INF/, since MMT doesn't support it by default\n" +
|
||||
"/web/WEB-INF=/WEB-INF\n";
|
||||
|
||||
|
||||
private Resource[] webResources = new Resource[0];
|
||||
|
||||
private final File moduleProperties;
|
||||
@ -71,6 +78,8 @@ public class AmpProjectPackagingTask
|
||||
|
||||
handeWebAppSourceDirectory( context );
|
||||
|
||||
synthesiseFileMappings(context);
|
||||
|
||||
|
||||
// Notice: this will work only in case we are copying only this AMP or this AMP is
|
||||
// set as last overlay of the maven-amp-plugin
|
||||
@ -145,6 +154,46 @@ public class AmpProjectPackagingTask
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Synthesizes (creates) a standard file-mappings.properties file so that resources in webapp/WEB-INF
|
||||
* get written to the correct location by the MMT.
|
||||
*
|
||||
* @param context The packaging context
|
||||
* @throws MojoExecutionException if the file could not be created
|
||||
*/
|
||||
protected void synthesiseFileMappings(final AmpPackagingContext context)
|
||||
throws MojoExecutionException
|
||||
{
|
||||
try
|
||||
{
|
||||
File fileMappings = new File(context.getAmpDirectory(), FILE_MAPPINGS);
|
||||
OutputStream out = null;
|
||||
|
||||
fileMappings.createNewFile(); // Note: ignore if the file already exists - we simply overwrite its existing contents
|
||||
|
||||
try
|
||||
{
|
||||
out = new FileOutputStream(fileMappings, false);
|
||||
|
||||
out.write(FILE_MAPPINGS_CONTENT.getBytes());
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (out != null)
|
||||
{
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (final IOException ioe)
|
||||
{
|
||||
throw new MojoExecutionException("Could not create file-mappings.properties in [" + context.getAmpDirectory().getAbsolutePath() + "]", ioe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles the webapp sources.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user