正则表达式模式在Adobe Experience Manager过滤器排除规则中似乎不起作用
问题描述:
我正在使用Adobe Experience Manager版本6,并且遇到了难以排除我的软件包中的.DS_Store
文件的问题。正则表达式模式在Adobe Experience Manager过滤器排除规则中似乎不起作用
我修改了META-INF/vault/filter.xml
文件排除的文件名模式:
<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
<filter root="/apps/myapp">
<exclude pattern="\.DS_Store"/>
</filter>
</workspaceFilter>
但是当我上传我的包或通过VLT的.DS_Store
文件仍包含推动他们。
我做了一些尝试,通过CRXDE Lite创建一个包含过滤器和排除规则的包,但它让我更加困惑。
当我用了排除原来的过滤器,并检查覆盖,.DS_Store
文件仍然包括:
但是,当我创建这个滤波器排除规则,并检查覆盖中,.DS_Store
文件是排除:
为什么在排除DS_Store之前敲击点不起作用,但使用0或更多的模式呢?
答
您的第一个不起作用的正则表达式(.DS_Store)正在查找位于.DS_Store的节点,该文件可能位于/.DS_Store中。正则表达式需要匹配完整路径。你的第二个例子(。* DS_Store)正在工作的原因是因为它在DS_Store之前查找0个或更多任何字符。这显然匹配DS_Store中结束的任何路径。
您可以试试http://www.regexr.com/上的示例,并在文本区域添加一些文件路径以查看它的匹配方式。
而不是尝试使用filter.xml来排除文件,您可能只需在构建中使用maven-assembler插件将其排除。
在你的pom.xml将添加插件这样的:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/zip.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
在zip.xml你会指定像不包括文件下面,你不希望包含在你的包:
<?xml version='1.0' encoding='UTF-8'?><assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>zip</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${basedir}/src/main/content/jcr_root</directory>
<outputDirectory>jcr_root</outputDirectory>
<excludes>
<exclude>**/.DS_Store</exclude>
</excludes>
<filtered>false</filtered>
</fileSet>
<fileSet>
<directory>${basedir}/src/main/content/META-INF</directory>
<outputDirectory>META-INF</outputDirectory>
<excludes>
<exclude>**/.DS_Store</exclude>
</excludes>
<filtered>true</filtered>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>jcr_root/apps/myapp/install</outputDirectory>
<useProjectArtifact>false</useProjectArtifact>
<scope>compile</scope>
<includes>
<include>com.icfolson.aem:myapp-core</include>
</includes>
<useStrictFiltering>true</useStrictFiltering>
</dependencySet>
</dependencySets>