You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by an...@apache.org on 2019/08/12 18:25:49 UTC
[sling-slingfeature-maven-plugin] 01/01: Added Feature Launcher
This is an automated email from the ASF dual-hosted git repository.
andysch pushed a commit to branch issues/SLING-8626
in repository https://gitbox.apache.org/repos/asf/sling-slingfeature-maven-plugin.git
commit d19bc0edda45b39174cd9ea32910bf9f52150f84
Author: Andreas Schaefer <sc...@iMac.local>
AuthorDate: Mon Aug 12 11:22:16 2019 -0700
Added Feature Launcher
---
pom.xml | 5 ++
.../feature/maven/mojos/FeatureLauncherMojo.java | 57 ++++++++++++++++++++++
.../META-INF/m2e/lifecycle-mapping-metadata.xml | 1 +
3 files changed, 63 insertions(+)
diff --git a/pom.xml b/pom.xml
index e4b273f..bcc6140 100644
--- a/pom.xml
+++ b/pom.xml
@@ -196,6 +196,11 @@
<version>0.0.2</version>
</dependency>
<dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.feature.launcher</artifactId>
+ <version>1.0.4</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven.version}</version>
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/FeatureLauncherMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/FeatureLauncherMojo.java
new file mode 100644
index 0000000..e38d76f
--- /dev/null
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/FeatureLauncherMojo.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.feature.maven.mojos;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.sling.feature.launcher.impl.Main;
+import org.apache.sling.feature.maven.ProjectHelper;
+
+import java.io.File;
+
+/**
+ * Launches the given Feature File
+ */
+@Mojo(
+ name = "launch-features",
+ requiresProject = true,
+ threadSafe = true
+)
+public final class FeatureLauncherMojo extends AbstractFeatureMojo {
+
+ public static final String CFG_FEATURE_FILE = "featureFile";
+
+ /**
+ * The path of the file that is launched here
+ */
+ @Parameter(property = CFG_FEATURE_FILE, required = true)
+ private File featureFile;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ ProjectHelper.checkPreprocessorRun(this.project);
+ if(!featureFile.isFile()) {
+ throw new MojoFailureException("Feature File is not a file: " + featureFile);
+ }
+ if(!featureFile.canRead()) {
+ throw new MojoFailureException("Feature File is cannot be read: " + featureFile);
+ }
+ Main.main(new String[] {"-f", featureFile.getAbsolutePath()});
+ }
+}
diff --git a/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml b/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
index f8d6a20..817daa0 100644
--- a/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
+++ b/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
@@ -25,6 +25,7 @@
<goal>analyse-features</goal>
<goal>attach-features</goal>
<goal>process-resources</goal>
+ <goal>launch-features</goal>
</goals>
</pluginExecutionFilter>
<action>