Skip to content

Commit 00fbdfa

Browse files
committed
Allow to parameterize output file
Use Path instead of File as plugin parameter type Update plugins to most recent versions Minor tweaks to site
1 parent 8d1aeef commit 00fbdfa

File tree

4 files changed

+63
-70
lines changed

4 files changed

+63
-70
lines changed

aem-classification-maven-plugin/pom.xml

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22
<modelVersion>4.0.0</modelVersion>
33
<artifactId>aem-classification-maven-plugin</artifactId>
4+
<version>1.1.0-SNAPSHOT</version>
45
<name>AEM Classification Maven Plugin</name>
56
<description>Maven plugin to generate classification maps from existing AEM instances (https://docs.adobe.com/content/help/en/experience-manager-65/deploying/upgrading/sustainable-upgrades.html).</description>
67
<packaging>maven-plugin</packaging>
@@ -25,6 +26,7 @@
2526

2627
<properties>
2728
<maven.compiler.release>11</maven.compiler.release> <!-- used for compiler and javadoc plugin -->
29+
<maven.version>3.9.8</maven.version><!-- due to https://issues.apache.org/jira/browse/MNG-8136 and https://github.com/eclipse-sisu/sisu.plexus/issues/21-->
2830
</properties>
2931

3032
<build>
@@ -38,31 +40,6 @@
3840
<scmBranch>gh-pages</scmBranch>
3941
</configuration>
4042
</plugin>
41-
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
42-
<plugin>
43-
<groupId>org.eclipse.m2e</groupId>
44-
<artifactId>lifecycle-mapping</artifactId>
45-
<version>1.0.0</version>
46-
<configuration>
47-
<lifecycleMappingMetadata>
48-
<pluginExecutions>
49-
<pluginExecution>
50-
<pluginExecutionFilter>
51-
<groupId>org.apache.maven.plugins</groupId>
52-
<artifactId>maven-plugin-plugin</artifactId>
53-
<versionRange>[3.6.0,)</versionRange>
54-
<goals>
55-
<goal>descriptor</goal>
56-
</goals>
57-
</pluginExecutionFilter>
58-
<action>
59-
<ignore />
60-
</action>
61-
</pluginExecution>
62-
</pluginExecutions>
63-
</lifecycleMappingMetadata>
64-
</configuration>
65-
</plugin>
6643
</plugins>
6744
</pluginManagement>
6845
<plugins>
@@ -83,7 +60,7 @@
8360
<reporting>
8461
<plugins>
8562
<plugin>
86-
<artifactId>maven-plugin-plugin</artifactId>
63+
<artifactId>maven-plugin-report-plugin</artifactId>
8764
</plugin>
8865
<plugin>
8966
<artifactId>maven-project-info-reports-plugin</artifactId>

aem-classification-maven-plugin/src/main/java/biz/netcentric/filevault/validator/aem/classification/mojo/DownloadContentClassificationMojo.java

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
* #L%
1414
*/
1515

16-
import java.io.File;
17-
import java.io.FileOutputStream;
1816
import java.io.IOException;
1917
import java.io.InputStream;
2018
import java.io.OutputStream;
@@ -52,13 +50,12 @@
5250
import biz.netcentric.filevault.validator.aem.classification.map.MutableContentClassificationMapImpl;
5351

5452
/**
55-
* Downloads the classification data from a remote JCR repository (only works with AEM 6.4 or newer),
53+
* Downloads the classification data from a remote JCR (only works with AEM 6.4 or newer) via HTTP endpoints,
5654
* serializes it into a map file and optionally wraps that within a JAR file.
5755
* <p>
58-
* That JAR file still needs to be manually uploaded to a Maven repository to leverage this classification map from the plugin.
56+
* That JAR file still needs to be manually uploaded to a Maven repository to leverage this classification map from the aem-classification-validator.
5957
* <p>
60-
* Uses the JCR search to find the current classification and also deprecation infos from properties "cq:deprecated" and "cq:deprecatedReason"
61-
* The search index needs to be setup for that though (property index limited to properties jcr:primaryType and jcr:mixinTypes for node types granite:FinalArea, granite:PublicArea, granite:InternalArea, granite:AbstractArea and another property index for properties cq:deprecated for any node type)
58+
* Uses the JCR search to find the current classification and also deprecation infos from properties {@code cq:deprecated} and {@code cq:deprecatedReason}.
6259
*/
6360
@Mojo(requiresProject=false, name = "download-content-classification")
6461
public class DownloadContentClassificationMojo extends AbstractMojo {
@@ -86,7 +83,11 @@ public class DownloadContentClassificationMojo extends AbstractMojo {
8683
* needs to be set to the filepath the map should have within the JAR.
8784
*/
8885
@Parameter(property="relativeFileNameInJar", required = false)
89-
File relativeFileNameInJar;
86+
Path relativeFileNameInJar;
87+
88+
/** The path of the classification map file (and potentially wrapper jar) without extension. If not set it is written to the default temporary directory of the file system with a random file name. */
89+
@Parameter(property="outputFile", required = false)
90+
Path outputFile;
9091

9192
@Override
9293
public void execute() throws MojoExecutionException, MojoFailureException {
@@ -113,15 +114,20 @@ public void execute() throws MojoExecutionException, MojoFailureException {
113114
retrieveDeprecatedResourceTypes(httpClient, map);
114115

115116
// 3. persist the map
116-
Path outputFile = Files.createTempFile("contentclassification", ".map");
117-
try (OutputStream fileOutputStream = Files.newOutputStream(outputFile)) {
117+
final Path classificationMapFile;
118+
if (outputFile == null) {
119+
classificationMapFile = Files.createTempFile("contentclassification", ".map");
120+
} else {
121+
classificationMapFile = outputFile.resolveSibling(outputFile.getFileName() + ".map");
122+
}
123+
try (OutputStream fileOutputStream = Files.newOutputStream(classificationMapFile)) {
118124
map.write(fileOutputStream);
119125
}
120-
log.info("Written classification map to " + outputFile + " containing " + map.size() + " entries.");
126+
log.info("Written classification map to " + classificationMapFile + " containing " + map.size() + " entries.");
121127

122128
// 4. optionally wrap in a JAR
123129
if (relativeFileNameInJar != null) {
124-
File jarFile = createJarWrapper(outputFile, relativeFileNameInJar.toPath());
130+
Path jarFile = createJarWrapper(classificationMapFile, relativeFileNameInJar);
125131
log.info("Written wrapper jar to " + jarFile);
126132
}
127133
} catch (InterruptedException e) {
@@ -232,11 +238,17 @@ private InputStream downloadFromAem(HttpClient httpClient, String path) throws I
232238
return response.body();
233239
}
234240

235-
File createJarWrapper(Path sourceFile, Path relativeFileNameInJar) throws IOException {
241+
Path createJarWrapper(Path sourceFile, Path relativeFileNameInJar) throws IOException {
236242
Manifest manifest = new Manifest();
237243
manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
238-
File outputFile = File.createTempFile("contentclassification", ".jar");
239-
try (JarOutputStream target = new JarOutputStream(new FileOutputStream(outputFile), manifest)) {
244+
final Path jarFile;
245+
if (outputFile == null) {
246+
jarFile = Files.createTempFile("contentclassification", ".jar");
247+
} else {
248+
jarFile = outputFile.resolveSibling(outputFile.getFileName() + ".jar");
249+
}
250+
251+
try (JarOutputStream target = new JarOutputStream(Files.newOutputStream(jarFile), manifest)) {
240252
JarEntry entry = new JarEntry(getPathWithUnixSeparators(relativeFileNameInJar));
241253
entry.setTime(Files.getLastModifiedTime(sourceFile).toMillis());
242254
target.putNextEntry(entry);
@@ -245,7 +257,7 @@ File createJarWrapper(Path sourceFile, Path relativeFileNameInJar) throws IOExce
245257
}
246258
target.closeEntry();
247259
}
248-
return outputFile;
260+
return jarFile;
249261
}
250262

251263
static String getPathWithUnixSeparators(Path path) {

aem-classification-maven-plugin/src/site/markdown/index.md renamed to aem-classification-maven-plugin/src/site/markdown/index.md.vm

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ Prepare AEM Server
1010
----------
1111
The AEM instance needs to have several [query indices][3] in place for this plugin to work:
1212

13-
1. property index limited to properties jcr:primaryType and jcr:mixinTypes for node types granite:FinalArea, granite:PublicArea, granite:InternalArea and granite:AbstractArea
14-
1. property index for properties cq:deprecated for any node type)
13+
1. property index limited to properties `jcr:primaryType` and `jcr:mixinTypes`for node types
14+
- `granite:FinalArea`,
15+
- `granite:PublicArea`,
16+
- `granite:InternalArea` and
17+
- `granite:AbstractArea`
18+
and
19+
1. property index for properties `cq:deprecated` and `cq:deprecatedReason` for any node type
1520

1621
There is a package containing the relevant indices called [aem-classification-search-index-package][4].
1722

@@ -21,7 +26,7 @@ Usage
2126
The only goal can be used without a Maven project like this
2227

2328
```
24-
mvn biz.netcentric.filevault.validator:aem-classification-maven-plugin:1.0.0-SNAPSHOT:download-content-classification
29+
mvn biz.netcentric.filevault.validator:aem-classification-maven-plugin:${project.version}:download-content-classification
2530
```
2631

2732
[1]: https://docs.adobe.com/content/help/en/experience-manager-65/deploying/upgrading/sustainable-upgrades.html#content-classifications

pom.xml

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -80,94 +80,93 @@
8080
<plugins>
8181
<plugin>
8282
<artifactId>maven-surefire-plugin</artifactId>
83-
<version>3.0.0-M7</version>
83+
<version>3.5.1</version>
8484
</plugin>
8585
<plugin>
8686
<artifactId>maven-failsafe-plugin</artifactId>
87-
<version>3.0.0-M7</version>
87+
<version>3.5.1</version>
8888
</plugin>
8989
<plugin>
9090
<artifactId>maven-compiler-plugin</artifactId>
91-
<version>3.10.1</version>
91+
<version>3.13.0</version>
9292
</plugin>
9393
<plugin>
9494
<artifactId>maven-install-plugin</artifactId>
95-
<version>3.0.1</version>
95+
<version>3.1.3</version>
9696
</plugin>
9797
<plugin>
9898
<artifactId>maven-deploy-plugin</artifactId>
99-
<version>3.0.0</version>
99+
<version>3.1.3</version>
100100
</plugin>
101101
<plugin>
102102
<artifactId>maven-resources-plugin</artifactId>
103-
<version>3.3.0</version>
103+
<version>3.3.1</version>
104104
</plugin>
105105
<plugin>
106106
<artifactId>maven-clean-plugin</artifactId>
107-
<version>3.2.0</version>
107+
<version>3.4.0</version>
108108
</plugin>
109109
<plugin>
110110
<artifactId>maven-jar-plugin</artifactId>
111-
<version>3.2.2</version>
111+
<version>3.4.2</version>
112112
</plugin>
113113
<plugin>
114114
<artifactId>maven-javadoc-plugin</artifactId>
115-
<version>3.4.0</version>
115+
<version>3.10.1</version>
116116
</plugin>
117117
<plugin>
118118
<artifactId>maven-source-plugin</artifactId>
119-
<version>3.2.1</version>
119+
<version>3.3.1</version>
120120
</plugin>
121121
<plugin>
122122
<artifactId>maven-release-plugin</artifactId>
123-
<version>3.0.0-M6</version>
123+
<version>3.1.1</version>
124124
</plugin>
125125
<plugin>
126126
<artifactId>maven-plugin-plugin</artifactId>
127-
<version>3.6.4</version>
127+
<version>3.15.0</version>
128+
</plugin>
129+
<plugin>
130+
<artifactId>maven-plugin-report-plugin</artifactId>
131+
<version>3.15.0</version>
128132
</plugin>
129133
<plugin>
130134
<artifactId>maven-project-info-reports-plugin</artifactId>
131-
<version>3.4.0</version>
135+
<version>3.6.2</version>
132136
</plugin>
133137
<plugin>
134138
<artifactId>maven-dependency-plugin</artifactId>
135-
<version>3.3.0</version>
139+
<version>3.8.0</version>
136140
</plugin>
137141
<!-- ====================================================================== -->
138142
<!-- S I T E P L U G I N -->
139143
<!-- ====================================================================== -->
140144
<plugin>
141145
<artifactId>maven-site-plugin</artifactId>
142-
<version>3.12.0</version>
146+
<version>3.12.1</version>
143147
</plugin>
144148
<plugin>
145149
<artifactId>maven-scm-publish-plugin</artifactId>
146-
<version>3.1.0</version>
150+
<version>3.3.0</version>
147151
</plugin>
148152
<plugin>
149153
<artifactId>maven-enforcer-plugin</artifactId>
150-
<version>3.1.0</version>
151-
</plugin>
152-
<plugin>
153-
<groupId>org.codehaus.mojo</groupId>
154-
<artifactId>animal-sniffer-maven-plugin</artifactId>
155-
<version>1.21</version>
154+
<version>3.5.0</version>
156155
</plugin>
157156
<plugin>
158157
<groupId>org.apache.maven.plugins</groupId>
159158
<artifactId>maven-gpg-plugin</artifactId>
160-
<version>3.0.1</version>
159+
<version>3.2.7</version>
161160
</plugin>
162161
<plugin>
163162
<groupId>org.sonatype.plugins</groupId>
164163
<artifactId>nexus-staging-maven-plugin</artifactId>
165-
<version>1.6.8</version>
164+
<version>1.7.0</version>
166165
</plugin>
167166
<plugin>
168167
<groupId>org.apache.jackrabbit</groupId>
169168
<artifactId>filevault-package-maven-plugin</artifactId>
170-
<version>1.3.0</version>
169+
<version>1.4.0</version>
171170
</plugin>
172171
<plugin>
173172
<groupId>com.day.jcr.vault</groupId>
@@ -182,7 +181,7 @@
182181
<plugin>
183182
<groupId>org.codehaus.mojo</groupId>
184183
<artifactId>flatten-maven-plugin</artifactId>
185-
<version>1.2.7</version>
184+
<version>1.6.0</version>
186185
<configuration>
187186
<flattenMode>ossrh</flattenMode>
188187
</configuration>

0 commit comments

Comments
 (0)