You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2024/12/13 14:01:47 UTC
(sling-slingfeature-maven-plugin) 02/02: SLING-12564 apply spotless formatting
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a commit to branch feature/SLING-12564-parent-62
in repository https://gitbox.apache.org/repos/asf/sling-slingfeature-maven-plugin.git
commit 449cc6c65ca5e0f0165cccec28bf408769a35562
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Fri Dec 13 15:01:37 2024 +0100
SLING-12564 apply spotless formatting
---
pom.xml | 283 ++++---
.../apache/sling/feature/maven/Environment.java | 27 +-
.../sling/feature/maven/FeatureConstants.java | 27 +-
.../sling/feature/maven/FeatureProjectConfig.java | 58 +-
.../sling/feature/maven/FeatureProjectInfo.java | 29 +-
.../apache/sling/feature/maven/JSONFeatures.java | 87 ++-
.../apache/sling/feature/maven/Preprocessor.java | 500 ++++++------
.../apache/sling/feature/maven/ProjectHelper.java | 344 +++++----
.../apache/sling/feature/maven/Substitution.java | 63 +-
.../extensions/DependencyLifecycleParticipant.java | 29 +-
.../maven/extensions/FeatureArtifactHandler.java | 26 +-
.../FeatureLifecycleMappingProvider.java | 41 +-
.../feature/maven/mojos/AbstractFeatureMojo.java | 80 +-
.../maven/mojos/AbstractIncludingFeatureMojo.java | 96 +--
.../maven/mojos/AbstractRepositoryMojo.java | 75 +-
.../sling/feature/maven/mojos/Aggregate.java | 64 +-
.../feature/maven/mojos/AggregateFeaturesMojo.java | 156 ++--
.../feature/maven/mojos/AnalyseFeaturesMojo.java | 120 +--
.../sling/feature/maven/mojos/ApisJarMojo.java | 841 +++++++++++++--------
.../maven/mojos/ApplyDefaultConfigMojo.java | 86 ++-
.../apache/sling/feature/maven/mojos/Archive.java | 30 +-
.../maven/mojos/AttachFeatureArchivesMojo.java | 88 ++-
.../feature/maven/mojos/AttachFeaturesMojo.java | 105 +--
.../feature/maven/mojos/CollectArtifactsMojo.java | 43 +-
.../feature/maven/mojos/EmbedFeaturesMojo.java | 51 +-
.../feature/maven/mojos/ExtractExtensionMojo.java | 68 +-
.../feature/maven/mojos/FeatureLauncherMojo.java | 85 ++-
.../maven/mojos/FeatureSelectionConfig.java | 57 +-
.../feature/maven/mojos/FeaturesDiffMojo.java | 92 ++-
.../feature/maven/mojos/IncludeArtifactMojo.java | 80 +-
.../apache/sling/feature/maven/mojos/InfoMojo.java | 98 ++-
.../sling/feature/maven/mojos/JarDecompressor.java | 45 +-
.../sling/feature/maven/mojos/Repository.java | 26 +-
.../sling/feature/maven/mojos/RepositoryMojo.java | 29 +-
.../org/apache/sling/feature/maven/mojos/Scan.java | 32 +-
.../feature/maven/mojos/UpdateVersionsMojo.java | 447 +++++------
.../maven/mojos/apis/ApisConfiguration.java | 120 +--
.../feature/maven/mojos/apis/ApisJarContext.java | 85 ++-
.../sling/feature/maven/mojos/apis/ApisUtil.java | 259 ++++---
.../feature/maven/mojos/apis/ArtifactType.java | 28 +-
.../maven/mojos/apis/ClassFileProcessor.java | 74 +-
.../feature/maven/mojos/apis/DirectorySource.java | 48 +-
.../sling/feature/maven/mojos/apis/FileSource.java | 28 +-
.../feature/maven/mojos/apis/JavadocExecutor.java | 30 +-
.../feature/maven/mojos/apis/JavadocLinks.java | 46 +-
.../feature/maven/mojos/apis/RegionSupport.java | 84 +-
.../feature/maven/mojos/apis/spi/Processor.java | 26 +-
.../maven/mojos/apis/spi/ProcessorContext.java | 30 +-
.../sling/feature/maven/mojos/apis/spi/Source.java | 26 +-
.../maven/mojos/reports/ContentsReporter.java | 30 +-
.../maven/mojos/reports/DuplicatesReporter.java | 81 +-
.../mojos/reports/ExportPackagesReporter.java | 52 +-
.../mojos/reports/ImportPackagesReporter.java | 44 +-
.../feature/maven/mojos/reports/ReportContext.java | 28 +-
.../feature/maven/mojos/reports/Reporter.java | 26 +-
.../reports/ScriptsImportPackagesReporter.java | 63 +-
.../mojos/selection/IncludeExcludeMatcher.java | 52 +-
.../apache/sling/feature/launcher/impl/Main.java | 34 +-
.../sling/feature/maven/JSONFeaturesTest.java | 44 +-
.../sling/feature/maven/PreprocessorTest.java | 34 +-
.../sling/feature/maven/SubstitutionTest.java | 57 +-
.../mojos/AbstractIncludingFeatureMojoTest.java | 74 +-
.../maven/mojos/AbstractRepositoryMojoTest.java | 47 +-
.../maven/mojos/AggregateFeaturesMojoTest.java | 367 +++++----
.../maven/mojos/AnalyseFeaturesMojoTest.java | 40 +-
.../sling/feature/maven/mojos/ApisJarMojoTest.java | 30 +-
.../maven/mojos/AttachFeaturesMojoTest.java | 52 +-
.../maven/mojos/ExtractExtensionsMojoTest.java | 43 +-
.../maven/mojos/FeatureLauncherMojoTest.java | 157 ++--
.../maven/mojos/FeatureSelectionConfigTest.java | 58 +-
.../feature/maven/mojos/JarDecompressorTest.java | 71 +-
.../apache/sling/feature/maven/mojos/ScanTest.java | 30 +-
.../maven/mojos/apis/RegionSupportTest.java | 85 ++-
.../feature/maven/mojos/plugins/TestPlugin1.java | 28 +-
.../feature/maven/mojos/plugins/TestPlugin2.java | 28 +-
.../feature/maven/mojos/plugins/TestPlugin3.java | 30 +-
.../mojos/selection/TestIncludeExcludeMatcher.java | 53 +-
77 files changed, 3885 insertions(+), 3145 deletions(-)
diff --git a/pom.xml b/pom.xml
index 01f481f..acd2883 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
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
@@ -26,11 +26,20 @@
<packaging>maven-plugin</packaging>
<name>Apache Sling OSGi Feature Maven Plugin</name>
- <description>
- Maven Plugin for OSGi Applications
- </description>
+ <description>Maven Plugin for OSGi Applications</description>
<url>https://sling.apache.org/components/slingfeature-maven-plugin/</url>
+ <prerequisites>
+ <maven>${maven.version}</maven>
+ </prerequisites>
+
+ <scm>
+ <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-slingfeature-maven-plugin.git</connection>
+ <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-slingfeature-maven-plugin.git</developerConnection>
+ <tag>HEAD</tag>
+ <url>https://github.com/apache/sling-slingfeature-maven-plugin.git</url>
+ </scm>
+
<properties>
<sling.java.version>11</sling.java.version>
<maven.version>3.8.1</maven.version>
@@ -40,144 +49,6 @@
<sling.feature.version>2.0.0</sling.feature.version>
</properties>
- <scm>
- <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-slingfeature-maven-plugin.git</connection>
- <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-slingfeature-maven-plugin.git</developerConnection>
- <url>https://github.com/apache/sling-slingfeature-maven-plugin.git</url>
- <tag>HEAD</tag>
- </scm>
-
- <prerequisites>
- <maven>${maven.version}</maven>
- </prerequisites>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.eclipse.sisu</groupId>
- <artifactId>sisu-maven-plugin</artifactId>
- <version>0.3.5</version>
- <executions>
- <execution>
- <id>index-project</id>
- <goals>
- <goal>main-index</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-plugin-plugin</artifactId>
- <executions>
- <execution>
- <id>mojo-descriptor</id>
- <phase>process-classes</phase>
- <goals>
- <goal>descriptor</goal>
- </goals>
- <configuration>
- <externalJavadocBaseUrls>
- <externalJavadocBaseUrl>https://www.javadoc.io/doc/org.apache.sling/org.apache.sling.feature/${sling.feature.version}/</externalJavadocBaseUrl>
- </externalJavadocBaseUrls>
- <internalJavadocBaseUrl>apidocs/</internalJavadocBaseUrl>
- </configuration>
- </execution>
- <execution>
- <id>generated-helpmojo</id>
- <goals>
- <goal>helpmojo</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-scm-publish-plugin</artifactId>
- <configuration>
- <checkoutDirectory>${user.home}/maven-sites/${maven.site.path}</checkoutDirectory>
- <tryUpdate>true</tryUpdate>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>src/site/markdown/**</exclude>
- <exclude>src/test/resources/**/*.txt</exclude>
- <exclude>src/test/resources/**/*.feature</exclude>
- <exclude>src/test/resources/**/*.xml</exclude>
- <exclude>src/test/resources/META-INF/services/*</exclude>
- <exclude>src/it/**/*.json</exclude>
- </excludes>
- </configuration>
- </plugin>
- <plugin><!-- prepare site content by filtering ${project.*} values -->
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>filter-site</id>
- <phase>pre-site</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.build.directory}/site-src</outputDirectory>
- <resources>
- <resource>
- <directory>src/site</directory>
- <filtering>true</filtering>
- </resource>
- </resources>
- </configuration>
- </execution>
- <execution>
- <id>default-testResources</id>
- <configuration>
- <!-- copy .gitignore as well -->
- <addDefaultExcludes>false</addDefaultExcludes>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <siteDirectory>${project.build.directory}/site-src</siteDirectory>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-invoker-plugin</artifactId>
- <version>3.6.1</version>
- <configuration>
- <debug>true</debug>
- <projectsDirectory>src/it</projectsDirectory>
- <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
- <settingsFile>src/it/settings.xml</settingsFile>
- <pomIncludes>
- <pomInclude>**/pom.xml</pomInclude>
- </pomIncludes>
- <postBuildHookScript>verify</postBuildHookScript>
- <streamLogsOnFailures>true</streamLogsOnFailures>
- </configuration>
- <executions>
- <execution>
- <id>integration-test</id>
- <goals>
- <goal>install</goal>
- <goal>integration-test</goal>
- <goal>verify</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
@@ -446,6 +317,134 @@
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>sisu-maven-plugin</artifactId>
+ <version>0.3.5</version>
+ <executions>
+ <execution>
+ <id>index-project</id>
+ <goals>
+ <goal>main-index</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>mojo-descriptor</id>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ <phase>process-classes</phase>
+ <configuration>
+ <externalJavadocBaseUrls>
+ <externalJavadocBaseUrl>https://www.javadoc.io/doc/org.apache.sling/org.apache.sling.feature/${sling.feature.version}/</externalJavadocBaseUrl>
+ </externalJavadocBaseUrls>
+ <internalJavadocBaseUrl>apidocs/</internalJavadocBaseUrl>
+ </configuration>
+ </execution>
+ <execution>
+ <id>generated-helpmojo</id>
+ <goals>
+ <goal>helpmojo</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-scm-publish-plugin</artifactId>
+ <configuration>
+ <checkoutDirectory>${user.home}/maven-sites/${maven.site.path}</checkoutDirectory>
+ <tryUpdate>true</tryUpdate>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>src/site/markdown/**</exclude>
+ <exclude>src/test/resources/**/*.txt</exclude>
+ <exclude>src/test/resources/**/*.feature</exclude>
+ <exclude>src/test/resources/**/*.xml</exclude>
+ <exclude>src/test/resources/META-INF/services/*</exclude>
+ <exclude>src/it/**/*.json</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <!-- prepare site content by filtering ${project.*} values -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>filter-site</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <phase>pre-site</phase>
+ <configuration>
+ <outputDirectory>${project.build.directory}/site-src</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/site</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>default-testResources</id>
+ <configuration>
+ <!-- copy .gitignore as well -->
+ <addDefaultExcludes>false</addDefaultExcludes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <configuration>
+ <siteDirectory>${project.build.directory}/site-src</siteDirectory>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <version>3.6.1</version>
+ <configuration>
+ <debug>true</debug>
+ <projectsDirectory>src/it</projectsDirectory>
+ <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+ <settingsFile>src/it/settings.xml</settingsFile>
+ <pomIncludes>
+ <pomInclude>**/pom.xml</pomInclude>
+ </pomIncludes>
+ <postBuildHookScript>verify</postBuildHookScript>
+ <streamLogsOnFailures>true</streamLogsOnFailures>
+ </configuration>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <goals>
+ <goal>install</goal>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
<reporting>
<plugins>
<plugin>
diff --git a/src/main/java/org/apache/sling/feature/maven/Environment.java b/src/main/java/org/apache/sling/feature/maven/Environment.java
index d739c8e..a03a6dd 100644
--- a/src/main/java/org/apache/sling/feature/maven/Environment.java
+++ b/src/main/java/org/apache/sling/feature/maven/Environment.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -41,4 +43,3 @@ public class Environment {
*/
public final Map<String, FeatureProjectInfo> modelProjects = new HashMap<>();
}
-
diff --git a/src/main/java/org/apache/sling/feature/maven/FeatureConstants.java b/src/main/java/org/apache/sling/feature/maven/FeatureConstants.java
index 15279ac..a62bd9d 100644
--- a/src/main/java/org/apache/sling/feature/maven/FeatureConstants.java
+++ b/src/main/java/org/apache/sling/feature/maven/FeatureConstants.java
@@ -1,23 +1,24 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
public abstract class FeatureConstants {
public static final String PACKAGING_FEATURE = "slingosgifeature";
-
}
diff --git a/src/main/java/org/apache/sling/feature/maven/FeatureProjectConfig.java b/src/main/java/org/apache/sling/feature/maven/FeatureProjectConfig.java
index 4d410aa..0536e6a 100644
--- a/src/main/java/org/apache/sling/feature/maven/FeatureProjectConfig.java
+++ b/src/main/java/org/apache/sling/feature/maven/FeatureProjectConfig.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -62,7 +64,6 @@ public class FeatureProjectConfig {
public static final String CFG_DEFAULT_METADATA = "defaultMetadata";
-
private final String featuresDirName;
private final String includes;
@@ -90,7 +91,7 @@ public class FeatureProjectConfig {
private final boolean enableLegacyVariableReplacement;
private final Map<String, Map<String, String>> defaultMetadata = new HashMap<>();
-
+
public static FeatureProjectConfig getMainConfig(final FeatureProjectInfo info) {
return new FeatureProjectConfig(info, false);
}
@@ -107,7 +108,7 @@ public class FeatureProjectConfig {
final String defaultSkipValue;
final String incCfgName;
final String exCfgName;
- if ( test ) {
+ if (test) {
featuresDirCfgName = CFG_TEST_FEATURES;
defaultDir = DEFAULT_TEST_FEATURE_DIR;
this.scope = Artifact.SCOPE_TEST;
@@ -116,7 +117,8 @@ public class FeatureProjectConfig {
exCfgName = CFG_TEST_FEATURES_EXCLUDES;
defaultSkipValue = "true";
this.name = "test feature";
- this.skipAddJar = "true".equals(ProjectHelper.getConfigValue(info.plugin, CFG_SKIP_ADD_JAR_TO_TEST_FEATURE, "true"));
+ this.skipAddJar =
+ "true".equals(ProjectHelper.getConfigValue(info.plugin, CFG_SKIP_ADD_JAR_TO_TEST_FEATURE, "true"));
} else {
featuresDirCfgName = CFG_FEATURES;
defaultDir = DEFAULT_FEATURE_DIR;
@@ -126,7 +128,8 @@ public class FeatureProjectConfig {
exCfgName = CFG_FEATURES_EXCLUDES;
defaultSkipValue = "false";
this.name = "feature";
- this.skipAddJar = "true".equals(ProjectHelper.getConfigValue(info.plugin, CFG_SKIP_ADD_JAR_TO_FEATURE, "true"));
+ this.skipAddJar =
+ "true".equals(ProjectHelper.getConfigValue(info.plugin, CFG_SKIP_ADD_JAR_TO_FEATURE, "true"));
}
this.featuresDirName = ProjectHelper.getConfigValue(info.plugin, featuresDirCfgName, defaultDir);
this.includes = ProjectHelper.getConfigValue(info.plugin, incCfgName, DEFAULT_FEATURE_INCLUDES);
@@ -135,29 +138,31 @@ public class FeatureProjectConfig {
this.skipAddDep = "true".equals(skipCfg.toLowerCase());
this.jarStartOrder = ProjectHelper.getConfigValue(info.plugin, CFG_JAR_START_ORDER, null);
this.validate = "true".equals(ProjectHelper.getConfigValue(info.plugin, CFG_VALIDATE_FEATURES, "true"));
- this.enableProjectVariableReplacement = "true".equals(ProjectHelper.getConfigValue(info.plugin, CFG_ENABLE_PROJ_VARS, "true"));
+ this.enableProjectVariableReplacement =
+ "true".equals(ProjectHelper.getConfigValue(info.plugin, CFG_ENABLE_PROJ_VARS, "true"));
String vars = ProjectHelper.getConfigValue(info.plugin, CFG_REPLACE_PROP_VARS, null);
- if ( vars == null ) {
+ if (vars == null) {
this.replacePropertyVariables = null;
} else {
this.replacePropertyVariables = vars.split(",");
}
- this.enableLegacyVariableReplacement = "true".equals(ProjectHelper.getConfigValue(info.plugin, CFG_LEGACY_REPLACE, "false"));
+ this.enableLegacyVariableReplacement =
+ "true".equals(ProjectHelper.getConfigValue(info.plugin, CFG_LEGACY_REPLACE, "false"));
// process metadata
- if ( !test ) {
+ if (!test) {
final Xpp3Dom metadataRoot = ProjectHelper.getConfig(info.plugin, CFG_DEFAULT_METADATA);
- if ( metadataRoot != null ) {
- for(final Xpp3Dom extension : metadataRoot.getChildren()) {
+ if (metadataRoot != null) {
+ for (final Xpp3Dom extension : metadataRoot.getChildren()) {
final String name = extension.getName();
final Map<String, String> map = this.defaultMetadata.computeIfAbsent(name, id -> new HashMap<>());
- for(final Xpp3Dom key : extension.getChildren()) {
- if ( key.getValue() != null ) {
+ for (final Xpp3Dom key : extension.getChildren()) {
+ if (key.getValue() != null) {
map.put(key.getName(), key.getValue());
}
}
}
- }
+ }
}
}
@@ -217,4 +222,3 @@ public class FeatureProjectConfig {
return this.defaultMetadata;
}
}
-
diff --git a/src/main/java/org/apache/sling/feature/maven/FeatureProjectInfo.java b/src/main/java/org/apache/sling/feature/maven/FeatureProjectInfo.java
index 2089a28..4ebf878 100644
--- a/src/main/java/org/apache/sling/feature/maven/FeatureProjectInfo.java
+++ b/src/main/java/org/apache/sling/feature/maven/FeatureProjectInfo.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -26,7 +28,7 @@ import org.apache.sling.feature.Feature;
public class FeatureProjectInfo {
public MavenProject project;
- public Plugin plugin;
+ public Plugin plugin;
public boolean featureDone = false;
public boolean testFeatureDone = false;
@@ -37,4 +39,3 @@ public class FeatureProjectInfo {
public final Map<String, Feature> testFeatures = new TreeMap<>();
public final Map<String, Feature> assembledTestFeatures = new TreeMap<>();
}
-
diff --git a/src/main/java/org/apache/sling/feature/maven/JSONFeatures.java b/src/main/java/org/apache/sling/feature/maven/JSONFeatures.java
index 66e011b..1b636fb 100644
--- a/src/main/java/org/apache/sling/feature/maven/JSONFeatures.java
+++ b/src/main/java/org/apache/sling/feature/maven/JSONFeatures.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -35,7 +37,6 @@ import jakarta.json.JsonValue;
import jakarta.json.JsonWriter;
import jakarta.json.stream.JsonGenerator;
import jakarta.json.stream.JsonGeneratorFactory;
-
import org.apache.commons.io.FileUtils;
import org.apache.felix.cm.json.io.Configurations;
import org.apache.sling.feature.Artifact;
@@ -59,24 +60,24 @@ public class JSONFeatures {
* @throws IOException If reading fails
*/
public static String read(final Reader reader, final ArtifactId optionalId, final String location)
- throws IOException {
+ throws IOException {
JsonObject featureObj;
try (JsonReader jsonReader = Json.createReader(Configurations.jsonCommentAwareReader(reader))) {
featureObj = jsonReader.readObject();
- if ( !featureObj.containsKey("id") ) {
+ if (!featureObj.containsKey("id")) {
final JsonObjectBuilder job = Json.createObjectBuilder();
job.add("id", optionalId.toMvnId());
- for(final Map.Entry<String, JsonValue> prop : featureObj.entrySet() ) {
+ for (final Map.Entry<String, JsonValue> prop : featureObj.entrySet()) {
job.add(prop.getKey(), prop.getValue());
}
featureObj = job.build();
}
- } catch ( final JsonException je) {
- throw new IOException(location.concat(" : " ).concat(je.getMessage()), je);
+ } catch (final JsonException je) {
+ throw new IOException(location.concat(" : ").concat(je.getMessage()), je);
}
- try ( final StringWriter writer = new StringWriter()) {
- try ( final JsonWriter jsonWriter = Json.createWriter(writer)) {
+ try (final StringWriter writer = new StringWriter()) {
+ try (final JsonWriter jsonWriter = Json.createWriter(writer)) {
jsonWriter.writeObject(featureObj);
}
return writer.toString();
@@ -90,28 +91,29 @@ public class JSONFeatures {
* @throws IOException If anything goes wrong
*/
public static void write(final Writer writer, final Feature feature) throws IOException {
- if ( feature.getId().equals(PLACEHOLDER_ID)) {
+ if (feature.getId().equals(PLACEHOLDER_ID)) {
// write feature with placeholder id
- try ( final StringWriter stringWriter = new StringWriter()) {
+ try (final StringWriter stringWriter = new StringWriter()) {
FeatureJSONWriter.write(stringWriter, feature);
// read feature as json object
try (JsonReader jsonReader = Json.createReader(new StringReader(stringWriter.toString()))) {
final JsonObject featureObj = jsonReader.readObject();
- final JsonGeneratorFactory factory = Json.createGeneratorFactory(Collections.singletonMap(JsonGenerator.PRETTY_PRINTING, true));
+ final JsonGeneratorFactory factory =
+ Json.createGeneratorFactory(Collections.singletonMap(JsonGenerator.PRETTY_PRINTING, true));
// write feature object, except id property
try (final JsonGenerator generator = factory.createGenerator(writer)) {
generator.writeStartObject();
for (final Map.Entry<String, JsonValue> entry : featureObj.entrySet()) {
- if ( !"id".equals(entry.getKey()) ) {
+ if (!"id".equals(entry.getKey())) {
generator.write(entry.getKey(), entry.getValue());
}
}
generator.writeEnd();
}
- } catch ( final JsonException je) {
+ } catch (final JsonException je) {
throw new IOException(je.getMessage(), je);
}
}
@@ -129,51 +131,54 @@ public class JSONFeatures {
* @param file The file to check for
* @throws IOException when an IO Exception occurs
*/
- public static void handleExtensions(final Feature feature, final File file) throws IOException {
- for(final Extension ext : feature.getExtensions()) {
- if ( ext.getType() == ExtensionType.TEXT && ext.getText().startsWith(FILE_PREFIX)) {
+ public static void handleExtensions(final Feature feature, final File file) throws IOException {
+ for (final Extension ext : feature.getExtensions()) {
+ if (ext.getType() == ExtensionType.TEXT && ext.getText().startsWith(FILE_PREFIX)) {
final int pos = file.getName().lastIndexOf(".");
- final String baseName = pos == -1 ? file.getName() : file.getName().substring(0, pos);
+ final String baseName =
+ pos == -1 ? file.getName() : file.getName().substring(0, pos);
final String fileName;
- if ( FILE_PREFIX.equals(ext.getText()) ) {
+ if (FILE_PREFIX.equals(ext.getText())) {
fileName = baseName.concat("-").concat(ext.getName()).concat(".txt");
} else {
- if ( !ext.getText().substring(FILE_PREFIX.length()).startsWith(":") ) {
+ if (!ext.getText().substring(FILE_PREFIX.length()).startsWith(":")) {
throw new IOException("Invalid file reference: " + ext.getText());
}
fileName = baseName.concat("-").concat(ext.getText().substring(FILE_PREFIX.length() + 1));
}
final File txtFile = new File(file.getParentFile(), fileName);
- if ( !txtFile.exists() || !txtFile.isFile()) {
+ if (!txtFile.exists() || !txtFile.isFile()) {
throw new IOException("Extension text file " + txtFile.getAbsolutePath() + " not found.");
}
final String contents = FileUtils.readFileToString(txtFile, StandardCharsets.UTF_8);
ext.setText(contents);
}
}
- }
+ }
private static final String FEATURE_BUNDLES = "bundles";
- public static void handleDefaultMetadata(final Feature feature, final Map<String, Map<String, String>> defaultMetadata) {
- for(final Map.Entry<String, Map<String, String>> entry : defaultMetadata.entrySet()) {
+ public static void handleDefaultMetadata(
+ final Feature feature, final Map<String, Map<String, String>> defaultMetadata) {
+ for (final Map.Entry<String, Map<String, String>> entry : defaultMetadata.entrySet()) {
final String extensionName = entry.getKey();
final Artifacts artifacts;
- if ( FEATURE_BUNDLES.equals(extensionName) ) {
+ if (FEATURE_BUNDLES.equals(extensionName)) {
artifacts = feature.getBundles();
} else {
final Extension ext = feature.getExtensions().getByName(extensionName);
artifacts = ext == null || ext.getType() != ExtensionType.ARTIFACTS ? null : ext.getArtifacts();
}
- if ( artifacts != null ) {
- for(final Map.Entry<String, String> propEntry : entry.getValue().entrySet()) {
- for(final Artifact artifact : artifacts) {
- if ( !artifact.getMetadata().containsKey(propEntry.getKey()) ) {
+ if (artifacts != null) {
+ for (final Map.Entry<String, String> propEntry :
+ entry.getValue().entrySet()) {
+ for (final Artifact artifact : artifacts) {
+ if (!artifact.getMetadata().containsKey(propEntry.getKey())) {
artifact.getMetadata().put(propEntry.getKey(), propEntry.getValue());
}
}
}
}
}
- }
+ }
}
diff --git a/src/main/java/org/apache/sling/feature/maven/Preprocessor.java b/src/main/java/org/apache/sling/feature/maven/Preprocessor.java
index 5022343..b002446 100644
--- a/src/main/java/org/apache/sling/feature/maven/Preprocessor.java
+++ b/src/main/java/org/apache/sling/feature/maven/Preprocessor.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -30,6 +32,14 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.github.fge.jsonschema.core.exceptions.ProcessingException;
+import com.github.fge.jsonschema.core.report.LogLevel;
+import com.github.fge.jsonschema.core.report.ProcessingMessage;
+import com.github.fge.jsonschema.core.report.ProcessingReport;
+import com.github.fge.jsonschema.main.JsonSchema;
+import com.github.fge.jsonschema.main.JsonSchemaFactory;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Exclusion;
import org.apache.maven.project.MavenProject;
@@ -44,15 +54,6 @@ import org.apache.sling.feature.builder.FeatureProvider;
import org.apache.sling.feature.io.json.FeatureJSONReader;
import org.codehaus.plexus.logging.Logger;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.github.fge.jsonschema.core.exceptions.ProcessingException;
-import com.github.fge.jsonschema.core.report.LogLevel;
-import com.github.fge.jsonschema.core.report.ProcessingMessage;
-import com.github.fge.jsonschema.core.report.ProcessingReport;
-import com.github.fge.jsonschema.main.JsonSchema;
-import com.github.fge.jsonschema.main.JsonSchemaFactory;
-
/**
* The processor processes all feature projects.
*/
@@ -63,47 +64,50 @@ public class Preprocessor {
private final ObjectMapper objectMapper;
public Preprocessor() {
- JsonSchemaFactory schemaFactory = JsonSchemaFactory.byDefault();
- String jsonSchemaUri = getClass().getClassLoader().getResource("META-INF/feature/Feature-1.0.0.schema.json").toExternalForm();
- try {
- schema = schemaFactory.getJsonSchema(jsonSchemaUri);
- } catch (ProcessingException e) {
- throw new RuntimeException("An error occured when retrieving the JSON Schema from " + jsonSchemaUri, e);
- }
- objectMapper = new ObjectMapper();
+ JsonSchemaFactory schemaFactory = JsonSchemaFactory.byDefault();
+ String jsonSchemaUri = getClass()
+ .getClassLoader()
+ .getResource("META-INF/feature/Feature-1.0.0.schema.json")
+ .toExternalForm();
+ try {
+ schema = schemaFactory.getJsonSchema(jsonSchemaUri);
+ } catch (ProcessingException e) {
+ throw new RuntimeException("An error occured when retrieving the JSON Schema from " + jsonSchemaUri, e);
+ }
+ objectMapper = new ObjectMapper();
}
private void checkFeatureFileValidation(File featureFile, String json) {
- try {
- JsonNode instance = objectMapper.readTree(json);
- ProcessingReport report = schema.validate(instance, true);
- if (!report.isSuccess()) {
- Formatter formatter = new Formatter();
- formatter.format("Feature file %s validation detected one or more errors:%n", featureFile);
+ try {
+ JsonNode instance = objectMapper.readTree(json);
+ ProcessingReport report = schema.validate(instance, true);
+ if (!report.isSuccess()) {
+ Formatter formatter = new Formatter();
+ formatter.format("Feature file %s validation detected one or more errors:%n", featureFile);
for (ProcessingMessage message : report) {
- if (LogLevel.FATAL == message.getLogLevel()
- || LogLevel.ERROR == message.getLogLevel())
- formatter.format(" * %s: %s%n",
- message.asJson().get("schema").get("pointer").asText(),
- message.getMessage());
- }
+ if (LogLevel.FATAL == message.getLogLevel() || LogLevel.ERROR == message.getLogLevel())
+ formatter.format(
+ " * %s: %s%n",
+ message.asJson().get("schema").get("pointer").asText(), message.getMessage());
+ }
String errorMessage = formatter.toString();
- formatter.close();
- throw new RuntimeException(errorMessage);
- }
- } catch (IOException e) {
- throw new RuntimeException("An error occurred while reading " + featureFile + " Feature file:", e);
- } catch (ProcessingException e) {
- throw new RuntimeException("An error occurred while validating Feature " + featureFile + ", read the log for details:", e);
- }
- }
+ formatter.close();
+ throw new RuntimeException(errorMessage);
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("An error occurred while reading " + featureFile + " Feature file:", e);
+ } catch (ProcessingException e) {
+ throw new RuntimeException(
+ "An error occurred while validating Feature " + featureFile + ", read the log for details:", e);
+ }
+ }
/**
* Process the provided projects.
* @param env The environment with all maven settings and projects
*/
public void process(final Environment env) {
- for(final FeatureProjectInfo finfo : env.modelProjects.values()) {
+ for (final FeatureProjectInfo finfo : env.modelProjects.values()) {
final FeatureProjectConfig cfg = FeatureProjectConfig.getMainConfig(finfo);
ProjectHelper.setDefaultMetadata(finfo.project, cfg.getDefaultMetadata());
@@ -124,17 +128,15 @@ public class Preprocessor {
* @param info The project to process.
* @param config The configuration for the project.
*/
- private void process(final Environment env,
- final FeatureProjectInfo info,
- final FeatureProjectConfig config) {
- if ( (config.isTestConfig() && info.testFeatureDone == true )
- || (!config.isTestConfig() && info.featureDone == true) ) {
+ private void process(final Environment env, final FeatureProjectInfo info, final FeatureProjectConfig config) {
+ if ((config.isTestConfig() && info.testFeatureDone == true)
+ || (!config.isTestConfig() && info.featureDone == true)) {
env.logger.debug("Return assembled " + config.getName() + " for " + info.project.getId());
return;
}
// prevent recursion and multiple processing
- if ( config.isTestConfig() ) {
+ if (config.isTestConfig()) {
info.testFeatureDone = true;
} else {
info.featureDone = true;
@@ -143,99 +145,111 @@ public class Preprocessor {
// read project features
readProjectFeatures(env.logger, info, config);
- if ( (config.isTestConfig() ? info.testFeatures : info.features).isEmpty() ) {
+ if ((config.isTestConfig() ? info.testFeatures : info.features).isEmpty()) {
env.logger.debug("No " + config.getName() + " found in project " + info.project.getId());
return;
}
// process attachments (only for jar or bundle)
- if ( "jar".equals(info.project.getPackaging())
- || "bundle".equals(info.project.getPackaging())) {
- if ( config.isSkipAddJarToFeature() ) {
+ if ("jar".equals(info.project.getPackaging()) || "bundle".equals(info.project.getPackaging())) {
+ if (config.isSkipAddJarToFeature()) {
env.logger.debug("Skip adding jar to " + config.getName());
} else {
- if ( info.features.size() > 1 ) {
+ if (info.features.size() > 1) {
throw new RuntimeException("Jar can only be added if just one feature is defined in the project");
}
- final Artifact jar = new Artifact(new ArtifactId(info.project.getGroupId(),
+ final Artifact jar = new Artifact(new ArtifactId(
+ info.project.getGroupId(),
info.project.getArtifactId(),
info.project.getVersion(),
null,
"jar"));
- if ( config.getJarStartOrder() != null ) {
+ if (config.getJarStartOrder() != null) {
jar.setStartOrder(Integer.valueOf(config.getJarStartOrder()));
}
// add to first feature
- (config.isTestConfig() ? info.testFeatures : info.features).values().iterator().next().getBundles().add(jar);
+ (config.isTestConfig() ? info.testFeatures : info.features)
+ .values()
+ .iterator()
+ .next()
+ .getBundles()
+ .add(jar);
}
}
// assemble features
final Map<String, Feature> features = (config.isTestConfig() ? info.testFeatures : info.features);
final Map<String, Feature> processFeatures = new HashMap<>(features);
- final Map<String, Feature> aggregatedFeatures = (config.isTestConfig() ? info.assembledTestFeatures : info.assembledFeatures);
- while ( aggregatedFeatures.size() < features.size() ) {
- final int start = aggregatedFeatures.size();
-
- final Iterator<Map.Entry<String, Feature>> iter = processFeatures.entrySet().iterator();
- while ( iter.hasNext() ) {
- final Map.Entry<String, Feature> entry = iter.next();
- boolean process = false;
- if ( entry.getValue().getPrototype() == null ) {
- // no include we can process
- process = true;
- } else {
+ final Map<String, Feature> aggregatedFeatures =
+ (config.isTestConfig() ? info.assembledTestFeatures : info.assembledFeatures);
+ while (aggregatedFeatures.size() < features.size()) {
+ final int start = aggregatedFeatures.size();
+
+ final Iterator<Map.Entry<String, Feature>> iter =
+ processFeatures.entrySet().iterator();
+ while (iter.hasNext()) {
+ final Map.Entry<String, Feature> entry = iter.next();
+ boolean process = false;
+ if (entry.getValue().getPrototype() == null) {
+ // no include we can process
+ process = true;
+ } else {
final ArtifactId prototype = entry.getValue().getPrototype().getId();
- if ( !prototype.getGroupId().equals(info.project.getGroupId())
- || !prototype.getArtifactId().equals(info.project.getArtifactId())
- || !prototype.getVersion().equals(info.project.getVersion()) ) {
- process = true;
- } else {
- // same project
- for(final Feature f : aggregatedFeatures.values()) {
- if ( f.getId().equals(prototype) ) {
- process = true;
- break;
- }
- }
- }
- }
- if ( process ) {
- iter.remove();
- final Feature assembledFeature = FeatureBuilder.assemble(entry.getValue(), new BuilderContext(this.createFeatureProvider(env,
- info,
- config.isTestConfig(),
- config.isSkipAddDependencies(),
- config.getScope(), null))
- .setArtifactProvider(
- aid ->
- {
- try
- {
- return ProjectHelper
- .getOrResolveArtifact(info.project, env.session,
- env.artifactHandlerManager, env.repoSystem, aid)
- .getFile().toURI().toURL();
- }
- catch (Exception e)
- {
- env.logger.error(e.getMessage(), e);
- return null;
- }
- }));
- aggregatedFeatures.put(entry.getKey(), assembledFeature);
- break;
- }
- }
- if ( aggregatedFeatures.size() == start ) {
- throw new RuntimeException("Circular dependency in features in project " + info.project.getId());
- }
+ if (!prototype.getGroupId().equals(info.project.getGroupId())
+ || !prototype.getArtifactId().equals(info.project.getArtifactId())
+ || !prototype.getVersion().equals(info.project.getVersion())) {
+ process = true;
+ } else {
+ // same project
+ for (final Feature f : aggregatedFeatures.values()) {
+ if (f.getId().equals(prototype)) {
+ process = true;
+ break;
+ }
+ }
+ }
+ }
+ if (process) {
+ iter.remove();
+ final Feature assembledFeature = FeatureBuilder.assemble(
+ entry.getValue(),
+ new BuilderContext(this.createFeatureProvider(
+ env,
+ info,
+ config.isTestConfig(),
+ config.isSkipAddDependencies(),
+ config.getScope(),
+ null))
+ .setArtifactProvider(aid -> {
+ try {
+ return ProjectHelper.getOrResolveArtifact(
+ info.project,
+ env.session,
+ env.artifactHandlerManager,
+ env.repoSystem,
+ aid)
+ .getFile()
+ .toURI()
+ .toURL();
+ } catch (Exception e) {
+ env.logger.error(e.getMessage(), e);
+ return null;
+ }
+ }));
+ aggregatedFeatures.put(entry.getKey(), assembledFeature);
+ break;
+ }
+ }
+ if (aggregatedFeatures.size() == start) {
+ throw new RuntimeException("Circular dependency in features in project " + info.project.getId());
+ }
}
- if ( config.isSkipAddDependencies() ) {
+ if (config.isSkipAddDependencies()) {
env.logger.debug("Not adding artifacts from features as dependencies");
} else {
- for(final Feature f : (config.isTestConfig() ? info.assembledTestFeatures : info.assembledFeatures).values()) {
+ for (final Feature f :
+ (config.isTestConfig() ? info.assembledTestFeatures : info.assembledFeatures).values()) {
addDependenciesFromFeature(env, info, f, config.getScope());
}
}
@@ -249,18 +263,15 @@ public class Preprocessor {
* @param scope The scope which the new dependencies should have
*/
private void addDependenciesFromFeature(
- final Environment env,
- final FeatureProjectInfo info,
- final Feature assembledFeature,
- final String scope) {
- for(final org.apache.sling.feature.Artifact entry : assembledFeature.getBundles()) {
+ final Environment env, final FeatureProjectInfo info, final Feature assembledFeature, final String scope) {
+ for (final org.apache.sling.feature.Artifact entry : assembledFeature.getBundles()) {
this.addDependency(env.logger, info.project, entry.getId(), scope);
}
- for(final Extension ext : assembledFeature.getExtensions()) {
- if ( ext.getType() != ExtensionType.ARTIFACTS ) {
+ for (final Extension ext : assembledFeature.getExtensions()) {
+ if (ext.getType() != ExtensionType.ARTIFACTS) {
continue;
}
- for(final org.apache.sling.feature.Artifact art : ext.getArtifacts()) {
+ for (final org.apache.sling.feature.Artifact art : ext.getArtifacts()) {
this.addDependency(env.logger, info.project, art.getId(), scope);
}
}
@@ -275,40 +286,42 @@ public class Preprocessor {
* @param config The configuration
*/
protected void readProjectFeatures(
- final Logger logger,
- final FeatureProjectInfo info,
- final FeatureProjectConfig config) {
+ final Logger logger, final FeatureProjectInfo info, final FeatureProjectConfig config) {
// feature files first:
final File dir = new File(info.project.getBasedir(), config.getFeaturesDir());
- if ( dir.exists() ) {
+ if (dir.exists()) {
final List<File> files = new ArrayList<>();
ProjectHelper.scan(files, dir, config.getIncludes(), config.getExcludes());
- for(final File file : files) {
- logger.debug("Reading feature file " + file + " in project " + info.project.getId());
+ for (final File file : files) {
+ logger.debug("Reading feature file " + file + " in project " + info.project.getId());
// if the feature is in the root of the configured directory
// and the feature is named "feature.json"
// and the feature is not a test feature, this is the main feature
// which does not get a classifier
final String suggestedClassifier;
- if (config.isTestConfig() || !file.getName().equals("feature.json")
- || !file.getParentFile().getAbsolutePath().equals(
- new File(info.project.getBasedir(), config.getFeaturesDir()).getAbsolutePath())) {
+ if (config.isTestConfig()
+ || !file.getName().equals("feature.json")
+ || !file.getParentFile()
+ .getAbsolutePath()
+ .equals(new File(info.project.getBasedir(), config.getFeaturesDir())
+ .getAbsolutePath())) {
final int lastDot = file.getName().lastIndexOf('.');
suggestedClassifier = file.getName().substring(0, lastDot);
} else {
suggestedClassifier = null;
}
- final String readJson = ProjectHelper.readFeatureFile(info.project, file,
+ final String readJson = ProjectHelper.readFeatureFile(
+ info.project,
+ file,
suggestedClassifier,
config.isEnableLegacyVariableReplacement(),
config.isEnableProjectVariableReplacement(),
config.getReplacePropertyVariables());
- final String json = preprocessFeature(info.project, config.isValidate(),
- file, readJson);
+ final String json = preprocessFeature(info.project, config.isValidate(), file, readJson);
try (final Reader reader = new StringReader(json)) {
final Feature feature = FeatureJSONReader.read(reader, file.getAbsolutePath());
@@ -320,18 +333,20 @@ public class Preprocessor {
// Default metadata
JSONFeatures.handleDefaultMetadata(feature, ProjectHelper.getDefaultMetadata(info.project));
-
+
ProjectHelper.setFeatureInfo(info.project, feature);
this.postProcessReadFeature(feature);
- (config.isTestConfig() ? info.testFeatures : info.features).put(file.toPath().normalize().toFile().getAbsolutePath(), feature);
+ (config.isTestConfig() ? info.testFeatures : info.features)
+ .put(file.toPath().normalize().toFile().getAbsolutePath(), feature);
- } catch ( final IOException io) {
+ } catch (final IOException io) {
throw new RuntimeException("Unable to read feature " + file.getAbsolutePath(), io);
}
}
} else {
- logger.debug("Feature directory " + config.getFeaturesDir() + " does not exist in project " + info.project.getId());
+ logger.debug("Feature directory " + config.getFeaturesDir() + " does not exist in project "
+ + info.project.getId());
}
}
@@ -343,7 +358,7 @@ public class Preprocessor {
}
return json;
- }
+ }
/**
* Hook to post process the local feature
@@ -351,140 +366,147 @@ public class Preprocessor {
* @param result The read feature
* @return The post processed feature
*/
- protected Feature postProcessReadFeature(final Feature result) {
+ protected Feature postProcessReadFeature(final Feature result) {
return result;
}
-
- protected FeatureProvider createFeatureProvider(final Environment env,
+ protected FeatureProvider createFeatureProvider(
+ final Environment env,
final FeatureProjectInfo info,
final boolean isTest,
final boolean skipAddDependencies,
final String dependencyScope,
final List<Feature> projectFeatures) {
- final String projectKey = info.project.getGroupId() + ":" + info.project.getArtifactId();
+ final String projectKey = info.project.getGroupId() + ":" + info.project.getArtifactId();
return new FeatureProvider() {
- private final Set<ArtifactId> processing = new HashSet<>();
+ private final Set<ArtifactId> processing = new HashSet<>();
@Override
public Feature provide(final ArtifactId id) {
- if ( processing.contains(id) ) {
- env.logger.error("Unable to get feature " + id.toMvnId() + " : Recursive dependency list including project " + info.project);
+ if (processing.contains(id)) {
+ env.logger.error("Unable to get feature " + id.toMvnId()
+ + " : Recursive dependency list including project " + info.project);
return null;
}
processing.add(id);
try {
- // add feature to dependencies
- if ( !skipAddDependencies ) {
- addDependency(env.logger, info.project, id, dependencyScope);
- }
-
- final String key = id.getGroupId() + ":" + id.getArtifactId();
- if ( projectKey.equals(key) ) {
- // this is a feature from the current project
- final Feature found = findFeature(info, isTest, id);
- if ( found == null ) {
- env.logger.error("Unable to find included feature " + id.toMvnId() + " in project " + info.project);
- return null;
- }
- return found;
- }
- // if it's a project from the current reactor build, we can't resolve it right now
- final FeatureProjectInfo depProjectInfo = env.modelProjects.get(key);
- if ( depProjectInfo != null ) {
- env.logger.debug("Found reactor " + id.getType() + " dependency to project: " + id);
- if ( isTest ) {
+ // add feature to dependencies
+ if (!skipAddDependencies) {
+ addDependency(env.logger, info.project, id, dependencyScope);
+ }
+
+ final String key = id.getGroupId() + ":" + id.getArtifactId();
+ if (projectKey.equals(key)) {
+ // this is a feature from the current project
+ final Feature found = findFeature(info, isTest, id);
+ if (found == null) {
+ env.logger.error(
+ "Unable to find included feature " + id.toMvnId() + " in project " + info.project);
+ return null;
+ }
+ return found;
+ }
+ // if it's a project from the current reactor build, we can't resolve it right now
+ final FeatureProjectInfo depProjectInfo = env.modelProjects.get(key);
+ if (depProjectInfo != null) {
+ env.logger.debug("Found reactor " + id.getType() + " dependency to project: " + id);
+ if (isTest) {
process(env, depProjectInfo, FeatureProjectConfig.getTestConfig(depProjectInfo));
- } else {
+ } else {
process(env, depProjectInfo, FeatureProjectConfig.getMainConfig(depProjectInfo));
- }
+ }
final Feature found = findFeature(depProjectInfo, isTest, id);
- if ( isTest && found == null ) {
- env.logger.error("Unable to get feature " + id.toMvnId() + " : Recursive test feature dependency list including project " + info.project);
- } else if ( !isTest && found == null ) {
- env.logger.error("Unable to get feature " + id.toMvnId() + " : Recursive feature dependency list including project " + info.project);
- }
- return found;
- } else {
- env.logger.debug("Found external " + id.getType() + " dependency: " + id);
-
- // "external" dependency, we can already resolve it
- final File featureFile = ProjectHelper.getOrResolveArtifact(info.project, env.session, env.artifactHandlerManager, env.repoSystem, id).getFile();
- try (final FileReader r = new FileReader(featureFile)) {
- return FeatureJSONReader.read(r, featureFile.getAbsolutePath());
- } catch ( final IOException ioe) {
- env.logger.error("Unable to read feature file from " + featureFile, ioe);
- }
- }
-
- return null;
+ if (isTest && found == null) {
+ env.logger.error("Unable to get feature " + id.toMvnId()
+ + " : Recursive test feature dependency list including project " + info.project);
+ } else if (!isTest && found == null) {
+ env.logger.error("Unable to get feature " + id.toMvnId()
+ + " : Recursive feature dependency list including project " + info.project);
+ }
+ return found;
+ } else {
+ env.logger.debug("Found external " + id.getType() + " dependency: " + id);
+
+ // "external" dependency, we can already resolve it
+ final File featureFile = ProjectHelper.getOrResolveArtifact(
+ info.project, env.session, env.artifactHandlerManager, env.repoSystem, id)
+ .getFile();
+ try (final FileReader r = new FileReader(featureFile)) {
+ return FeatureJSONReader.read(r, featureFile.getAbsolutePath());
+ } catch (final IOException ioe) {
+ env.logger.error("Unable to read feature file from " + featureFile, ioe);
+ }
+ }
+
+ return null;
} finally {
- processing.remove(id);
+ processing.remove(id);
}
}
};
}
- private void addDependency(final Logger logger, final MavenProject project, final ArtifactId id, final String scope) {
- if ( id.getGroupId().equals(project.getGroupId())
- && id.getArtifactId().equals(project.getArtifactId())
- && id.getVersion().equals(project.getVersion()) ) {
+ private void addDependency(
+ final Logger logger, final MavenProject project, final ArtifactId id, final String scope) {
+ if (id.getGroupId().equals(project.getGroupId())
+ && id.getArtifactId().equals(project.getArtifactId())
+ && id.getVersion().equals(project.getVersion())) {
// skip artifact from the same project
logger.debug("- skipping dependency " + id.toMvnId());
} else {
- boolean found = false;
- for(final Dependency d : project.getDependencies()) {
- if ( d.getGroupId().equals(id.getGroupId()) && d.getArtifactId().equals(id.getArtifactId())) {
- if ( d.getVersion().equals(id.getVersion()) && d.getType().equals(id.getType())) {
- if ( d.getClassifier() == null && id.getClassifier() == null ) {
- found = true;
- break;
- }
- if ( d.getClassifier() != null && d.getClassifier().equals(id.getClassifier())) {
- found = true;
- break;
- }
- }
- }
- }
- if ( !found ) {
- logger.debug("- adding dependency " + id.toMvnId());
- final Dependency dep = ProjectHelper.toDependency(id, scope);
-
- // Exclude all transitive dependencies coming from the feature model deps
- Exclusion exclusion = new Exclusion();
- exclusion.setGroupId("*");
- exclusion.setArtifactId("*");
- dep.addExclusion(exclusion);
-
- project.getDependencies().add(dep);
- }
+ boolean found = false;
+ for (final Dependency d : project.getDependencies()) {
+ if (d.getGroupId().equals(id.getGroupId()) && d.getArtifactId().equals(id.getArtifactId())) {
+ if (d.getVersion().equals(id.getVersion()) && d.getType().equals(id.getType())) {
+ if (d.getClassifier() == null && id.getClassifier() == null) {
+ found = true;
+ break;
+ }
+ if (d.getClassifier() != null && d.getClassifier().equals(id.getClassifier())) {
+ found = true;
+ break;
+ }
+ }
+ }
+ }
+ if (!found) {
+ logger.debug("- adding dependency " + id.toMvnId());
+ final Dependency dep = ProjectHelper.toDependency(id, scope);
+
+ // Exclude all transitive dependencies coming from the feature model deps
+ Exclusion exclusion = new Exclusion();
+ exclusion.setGroupId("*");
+ exclusion.setArtifactId("*");
+ dep.addExclusion(exclusion);
+
+ project.getDependencies().add(dep);
+ }
}
}
private Feature findFeature(final FeatureProjectInfo info, final boolean isTest, final ArtifactId id) {
- Feature found = findFeature(isTest ? info.assembledTestFeatures : info.assembledFeatures, id);
- if ( found == null ) {
- if ( isTest ) {
- found = findFeature(info.assembledFeatures, id);
- }
+ Feature found = findFeature(isTest ? info.assembledTestFeatures : info.assembledFeatures, id);
+ if (found == null) {
+ if (isTest) {
+ found = findFeature(info.assembledFeatures, id);
+ }
}
return found;
}
private Feature findFeature(final Map<String, Feature> featureMap, final ArtifactId id) {
- Feature found = null;
- if ( featureMap != null ) {
- for(final Map.Entry<String, Feature> f : featureMap.entrySet()) {
- if ( f.getValue().getId().equals(id) ) {
+ Feature found = null;
+ if (featureMap != null) {
+ for (final Map.Entry<String, Feature> f : featureMap.entrySet()) {
+ if (f.getValue().getId().equals(id)) {
found = f.getValue();
break;
}
}
- }
- return found;
+ }
+ return found;
}
}
diff --git a/src/main/java/org/apache/sling/feature/maven/ProjectHelper.java b/src/main/java/org/apache/sling/feature/maven/ProjectHelper.java
index 6cf36a5..bf73042 100644
--- a/src/main/java/org/apache/sling/feature/maven/ProjectHelper.java
+++ b/src/main/java/org/apache/sling/feature/maven/ProjectHelper.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -65,10 +67,12 @@ public abstract class ProjectHelper {
/** Read feature. */
private static final String RAW_FEATURE_JSON = Feature.class.getName() + "/rawmain.json";
+
private static final String RAW_TEST_FEATURE_JSON = Feature.class.getName() + "/rawtest.json";
/** Assembled feature. */
private static final String ASSEMBLED_FEATURE_JSON = Feature.class.getName() + "/assembledmain.json";
+
private static final String ASSEMBLED_TEST_FEATURE_JSON = Feature.class.getName() + "/assembledtest.json";
/** Default metadata */
@@ -78,17 +82,17 @@ public abstract class ProjectHelper {
private static final String ARTIFACT_CACHE = Artifact.class.getName() + "/cache";
private static void store(final MavenProject project, final String key, final Map<String, Feature> features) {
- if ( features != null && !features.isEmpty()) {
+ if (features != null && !features.isEmpty()) {
project.setContextValue(key, features.size());
// we have to serialize as the dependency lifecycle participant uses a different class loader (!)
int index = 0;
- for(final Map.Entry<String, Feature> entry : features.entrySet()) {
- try ( final StringWriter w1 = new StringWriter() ) {
+ for (final Map.Entry<String, Feature> entry : features.entrySet()) {
+ try (final StringWriter w1 = new StringWriter()) {
FeatureJSONWriter.write(w1, entry.getValue());
project.setContextValue(key + "_" + String.valueOf(index), w1.toString());
project.setContextValue(key + "_" + String.valueOf(index) + "f", entry.getKey());
index++;
- } catch ( final IOException ioe) {
+ } catch (final IOException ioe) {
throw new RuntimeException(ioe.getMessage(), ioe);
}
}
@@ -101,31 +105,31 @@ public abstract class ProjectHelper {
Map<String, Feature> result = null;
try {
result = (Map<String, Feature>) project.getContextValue(cacheKey);
- if (result != null && !result.isEmpty() ) {
+ if (result != null && !result.isEmpty()) {
final Feature f = result.values().iterator().next();
f.getId();
}
- } catch ( final Exception e) {
+ } catch (final Exception e) {
// if we get a class cast exception, we read again
result = null;
}
- if ( result == null ) {
+ if (result == null) {
result = new TreeMap<>();
- final Integer size = (Integer)project.getContextValue(key);
- if ( size != null ) {
- for(int i=0; i<size;i++) {
- final String text = (String)project.getContextValue(key + "_" + String.valueOf(i));
- if ( text == null ) {
+ final Integer size = (Integer) project.getContextValue(key);
+ if (size != null) {
+ for (int i = 0; i < size; i++) {
+ final String text = (String) project.getContextValue(key + "_" + String.valueOf(i));
+ if (text == null) {
throw new RuntimeException("Unable to get feature from internal store.");
}
- final String file = (String)project.getContextValue(key + "_" + String.valueOf(i) + "f");
- if ( file == null ) {
+ final String file = (String) project.getContextValue(key + "_" + String.valueOf(i) + "f");
+ if (file == null) {
throw new RuntimeException("Unable to get feature from internal store.");
}
- try ( final StringReader r = new StringReader(text) ) {
+ try (final StringReader r = new StringReader(text)) {
final Feature feature = FeatureJSONReader.read(r, project.getId());
result.put(file, feature);
- } catch ( final IOException ioe) {
+ } catch (final IOException ioe) {
throw new RuntimeException(ioe.getMessage(), ioe);
}
}
@@ -212,27 +216,25 @@ public abstract class ProjectHelper {
* @return The default value if nothing is configured, the value otherwise.
* @throws RuntimeException If more than one value is configured
*/
- public static String getConfigValue(final Plugin plugin,
- final String name,
- final String defaultValue) {
+ public static String getConfigValue(final Plugin plugin, final String name, final String defaultValue) {
final Set<String> values = new HashSet<>();
- final Xpp3Dom config = plugin == null ? null : (Xpp3Dom)plugin.getConfiguration();
+ final Xpp3Dom config = plugin == null ? null : (Xpp3Dom) plugin.getConfiguration();
final Xpp3Dom globalNode = (config == null ? null : config.getChild(name));
- if ( globalNode != null ) {
+ if (globalNode != null) {
values.add(globalNode.getValue());
}
- for(final PluginExecution exec : plugin.getExecutions()) {
- final Xpp3Dom cfg = (Xpp3Dom)exec.getConfiguration();
+ for (final PluginExecution exec : plugin.getExecutions()) {
+ final Xpp3Dom cfg = (Xpp3Dom) exec.getConfiguration();
final Xpp3Dom pluginNode = (cfg == null ? null : cfg.getChild(name));
- if ( pluginNode != null
+ if (pluginNode != null
&& pluginNode.getValue() != null
- && !pluginNode.getValue().isEmpty() ) {
+ && !pluginNode.getValue().isEmpty()) {
values.add(pluginNode.getValue());
}
}
- if ( values.size() > 1 ) {
- throw new RuntimeException("More than one value configured in plugin (executions) of "
- + plugin.getKey() + " for " + name + " : " + values);
+ if (values.size() > 1) {
+ throw new RuntimeException("More than one value configured in plugin (executions) of " + plugin.getKey()
+ + " for " + name + " : " + values);
}
return values.isEmpty() ? defaultValue : values.iterator().next();
}
@@ -245,36 +247,37 @@ public abstract class ProjectHelper {
* @return {@code null} if nothing is configured, the value otherwise.
* @throws RuntimeException If more than one value is configured
*/
- public static Xpp3Dom getConfig(final Plugin plugin,
- final String name) {
+ public static Xpp3Dom getConfig(final Plugin plugin, final String name) {
final Set<Xpp3Dom> values = new HashSet<>();
- final Xpp3Dom config = plugin == null ? null : (Xpp3Dom)plugin.getConfiguration();
+ final Xpp3Dom config = plugin == null ? null : (Xpp3Dom) plugin.getConfiguration();
final Xpp3Dom globalNode = (config == null ? null : config.getChild(name));
- if ( globalNode != null && globalNode.getChildCount() > 0 ) {
+ if (globalNode != null && globalNode.getChildCount() > 0) {
values.add(globalNode);
}
- for(final PluginExecution exec : plugin.getExecutions()) {
- final Xpp3Dom cfg = (Xpp3Dom)exec.getConfiguration();
+ for (final PluginExecution exec : plugin.getExecutions()) {
+ final Xpp3Dom cfg = (Xpp3Dom) exec.getConfiguration();
final Xpp3Dom pluginNode = (cfg == null ? null : cfg.getChild(name));
- if ( pluginNode != null && pluginNode.getChildCount() > 0 ) {
+ if (pluginNode != null && pluginNode.getChildCount() > 0) {
values.add(pluginNode);
}
}
- if ( values.size() > 1 ) {
- throw new RuntimeException("More than one value configured in plugin (executions) of "
- + plugin.getKey() + " for " + name + " : " + values);
+ if (values.size() > 1) {
+ throw new RuntimeException("More than one value configured in plugin (executions) of " + plugin.getKey()
+ + " for " + name + " : " + values);
}
return values.isEmpty() ? null : values.iterator().next();
}
private static Artifact findArtifact(final ArtifactId id, final Collection<Artifact> artifacts) {
if (artifacts != null) {
- for(final Artifact artifact : artifacts) {
- if ( artifact.getGroupId().equals(id.getGroupId())
- && artifact.getArtifactId().equals(id.getArtifactId())
- && artifact.getVersion().equals(id.getVersion())
- && artifact.getType().equals(id.getType())
- && ((id.getClassifier() == null && artifact.getClassifier() == null) || (id.getClassifier() != null && id.getClassifier().equals(artifact.getClassifier()))) ) {
+ for (final Artifact artifact : artifacts) {
+ if (artifact.getGroupId().equals(id.getGroupId())
+ && artifact.getArtifactId().equals(id.getArtifactId())
+ && artifact.getVersion().equals(id.getVersion())
+ && artifact.getType().equals(id.getType())
+ && ((id.getClassifier() == null && artifact.getClassifier() == null)
+ || (id.getClassifier() != null
+ && id.getClassifier().equals(artifact.getClassifier())))) {
return artifact.getFile() == null ? null : artifact;
}
}
@@ -305,23 +308,24 @@ public abstract class ProjectHelper {
* @param overwrite If set to {@code true} the feature is always written even if the file already exists
* @return Return a temporary file
*/
- public static File createTmpFeatureFile(final MavenProject project, final Feature feature, final boolean overwrite) {
+ public static File createTmpFeatureFile(
+ final MavenProject project, final Feature feature, final boolean overwrite) {
final String classifier = feature.getId().getClassifier();
- final File outputFile = new File(getTmpDir(project), classifier == null ? "feature.json" : "feature-" + classifier + ".json");
- if ( overwrite || !outputFile.exists() ) {
+ final File outputFile =
+ new File(getTmpDir(project), classifier == null ? "feature.json" : "feature-" + classifier + ".json");
+ if (overwrite || !outputFile.exists()) {
outputFile.getParentFile().mkdirs();
- try ( final Writer writer = new FileWriter(outputFile)) {
+ try (final Writer writer = new FileWriter(outputFile)) {
FeatureJSONWriter.write(writer, feature);
} catch (final IOException e) {
- throw new RuntimeException("Unable to write feature " + feature.getId().toMvnId() + " to " + outputFile, e);
+ throw new RuntimeException(
+ "Unable to write feature " + feature.getId().toMvnId() + " to " + outputFile, e);
}
}
return outputFile;
}
-
-
/**
* Get a resolved Artifact from the coordinates provided
*
@@ -333,27 +337,36 @@ public abstract class ProjectHelper {
* @return the artifact, which has been resolved.
*/
@SuppressWarnings("deprecation")
- public static Artifact getOrResolveArtifact(final MavenProject project,
+ public static Artifact getOrResolveArtifact(
+ final MavenProject project,
final MavenSession session,
final ArtifactHandlerManager artifactHandlerManager,
final RepositorySystem repoSystem,
final ArtifactId id) {
@SuppressWarnings("unchecked")
Map<String, Artifact> cache = (Map<String, Artifact>) project.getContextValue(ARTIFACT_CACHE);
- if ( cache == null ) {
+ if (cache == null) {
cache = new ConcurrentHashMap<>();
project.setContextValue(ARTIFACT_CACHE, cache);
}
Artifact result = cache.get(id.toMvnId());
- if ( result == null ) {
+ if (result == null) {
result = findArtifact(id, project.getAttachedArtifacts());
- if ( result == null ) {
+ if (result == null) {
result = findArtifact(id, project.getDependencyArtifacts());
- if ( result == null ) {
- if ( isLocalProjectArtifact(project, id)) {
- for(final Map.Entry<String, Feature> entry : getFeatures(project).entrySet()) {
- if ( entry.getValue().getId().equals(id)) {
- final Artifact artifact = new DefaultArtifact(id.getGroupId(), id.getArtifactId(), id.getVersion(), Artifact.SCOPE_PROVIDED, id.getType(), id.getClassifier(), null);
+ if (result == null) {
+ if (isLocalProjectArtifact(project, id)) {
+ for (final Map.Entry<String, Feature> entry :
+ getFeatures(project).entrySet()) {
+ if (entry.getValue().getId().equals(id)) {
+ final Artifact artifact = new DefaultArtifact(
+ id.getGroupId(),
+ id.getArtifactId(),
+ id.getVersion(),
+ Artifact.SCOPE_PROVIDED,
+ id.getType(),
+ id.getClassifier(),
+ null);
artifact.setFile(createTmpFeatureFile(project, entry.getValue()));
result = artifact;
@@ -361,19 +374,23 @@ public abstract class ProjectHelper {
}
}
}
- if ( result == null ) {
+ if (result == null) {
try {
-
- org.eclipse.aether.artifact.Artifact prjArtifact = new org.eclipse.aether.artifact.DefaultArtifact(
+
+ org.eclipse.aether.artifact.Artifact prjArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(
id.getGroupId(),
id.getArtifactId(),
id.getClassifier(),
null, // extension retrieved via artifactTye
id.getVersion(),
- RepositoryUtils.newArtifactType(id.getType(), artifactHandlerManager.getArtifactHandler(id.getType()))
- );
- ArtifactRequest artifactRequest = new ArtifactRequest(prjArtifact, project.getRemoteProjectRepositories(), null);
- ArtifactResult artifactResult = repoSystem.resolveArtifact(session.getRepositorySession(), artifactRequest);
+ RepositoryUtils.newArtifactType(
+ id.getType(),
+ artifactHandlerManager.getArtifactHandler(id.getType())));
+ ArtifactRequest artifactRequest =
+ new ArtifactRequest(prjArtifact, project.getRemoteProjectRepositories(), null);
+ ArtifactResult artifactResult =
+ repoSystem.resolveArtifact(session.getRepositorySession(), artifactRequest);
result = RepositoryUtils.toArtifact(artifactResult.getArtifact());
} catch (final org.eclipse.aether.resolution.ArtifactResolutionException e) {
throw new RuntimeException("Unable to get artifact for " + id.toMvnId(), e);
@@ -387,9 +404,14 @@ public abstract class ProjectHelper {
return result;
}
- public static Feature getOrResolveFeature(final MavenProject project, final MavenSession session,
- final ArtifactHandlerManager artifactHandlerManager, final RepositorySystem repoSystem, final ArtifactId id) {
- final File artFile = getOrResolveArtifact(project, session, artifactHandlerManager, repoSystem, id).getFile();
+ public static Feature getOrResolveFeature(
+ final MavenProject project,
+ final MavenSession session,
+ final ArtifactHandlerManager artifactHandlerManager,
+ final RepositorySystem repoSystem,
+ final ArtifactId id) {
+ final File artFile = getOrResolveArtifact(project, session, artifactHandlerManager, repoSystem, id)
+ .getFile();
try (final Reader reader = new FileReader(artFile)) {
return FeatureJSONReader.read(reader, artFile.getAbsolutePath());
} catch (final IOException ioe) {
@@ -401,9 +423,10 @@ public abstract class ProjectHelper {
if (d == null) {
return "null";
}
- return "Dependency {groupId=" + d.getGroupId() + ", artifactId=" + d.getArtifactId() + ", version=" + d.getVersion() +
- (d.getClassifier() != null ? ", classifier=" + d.getClassifier() : "") +
- ", type=" + d.getType() + "}";
+ return "Dependency {groupId=" + d.getGroupId() + ", artifactId=" + d.getArtifactId() + ", version="
+ + d.getVersion() + (d.getClassifier() != null ? ", classifier=" + d.getClassifier() : "")
+ + ", type="
+ + d.getType() + "}";
}
public static Dependency toDependency(final ArtifactId id, final String scope) {
@@ -422,26 +445,26 @@ public abstract class ProjectHelper {
if (dep == null) {
return null;
}
- return new ArtifactId(dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getClassifier(),
- dep.getType());
+ return new ArtifactId(
+ dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getClassifier(), dep.getType());
}
public static void setFeatureInfo(final MavenProject project, final Feature feature) {
// set title, description, vendor, license
- if ( feature.getTitle() == null ) {
+ if (feature.getTitle() == null) {
feature.setTitle(project.getName());
}
- if ( feature.getDescription() == null ) {
+ if (feature.getDescription() == null) {
feature.setDescription(project.getDescription());
}
- if ( feature.getVendor() == null && project.getOrganization() != null ) {
+ if (feature.getVendor() == null && project.getOrganization() != null) {
feature.setVendor(project.getOrganization().getName());
}
- if ( feature.getLicense() == null
- && project.getLicenses() != null
- && !project.getLicenses().isEmpty()) {
+ if (feature.getLicense() == null
+ && project.getLicenses() != null
+ && !project.getLicenses().isEmpty()) {
final String license = project.getLicenses().stream()
- .filter(l -> l.getName() != null )
+ .filter(l -> l.getName() != null)
.map(l -> l.getName())
.collect(Collectors.joining(", "));
@@ -452,37 +475,37 @@ public abstract class ProjectHelper {
private static final String AGGREGATE_PREFIX = ":aggregate:";
private static String toString(final List<String> featureKeys) {
- final StringBuilder sb = new StringBuilder();
- if ( featureKeys.size() > 1 ) {
- sb.append('[');
- }
+ final StringBuilder sb = new StringBuilder();
+ if (featureKeys.size() > 1) {
+ sb.append('[');
+ }
boolean first = true;
for (String key : featureKeys) {
- if ( first ) {
- first = false;
- } else {
- sb.append(", ");
- }
- if ( key.startsWith(AGGREGATE_PREFIX) ) {
+ if (first) {
+ first = false;
+ } else {
+ sb.append(", ");
+ }
+ if (key.startsWith(AGGREGATE_PREFIX)) {
key = key.substring(0, key.length() - 2);
- sb.append("aggregate ");
+ sb.append("aggregate ");
if (key.length() == AGGREGATE_PREFIX.length()) {
sb.append("main artifact (no classifier)");
} else {
sb.append(key.substring(AGGREGATE_PREFIX.length()));
}
- } else {
- sb.append(key);
- }
+ } else {
+ sb.append(key);
+ }
+ }
+ if (featureKeys.size() > 1) {
+ sb.append(']');
}
- if ( featureKeys.size() > 1 ) {
- sb.append(']');
- }
return sb.toString();
}
public static boolean isAggregate(final String featureKey) {
- return featureKey.startsWith(AGGREGATE_PREFIX);
+ return featureKey.startsWith(AGGREGATE_PREFIX);
}
public static boolean isAttachAggregate(final String featureKey) {
@@ -490,20 +513,22 @@ public abstract class ProjectHelper {
}
public static String generateAggregateFeatureKey(final String classifier, final boolean attach) {
- return (classifier != null ? AGGREGATE_PREFIX.concat(classifier) : AGGREGATE_PREFIX).concat(":")
+ return (classifier != null ? AGGREGATE_PREFIX.concat(classifier) : AGGREGATE_PREFIX)
+ .concat(":")
.concat(attach ? "T" : "F");
}
private static final String NULL_KEY = ":";
- private static void addClassifier(final Map<String, List<String>> classifiers, final String classifier, final String featureKey) {
- final String key = classifier == null ? NULL_KEY : classifier;
- List<String> list = classifiers.get(key);
- if ( list == null ) {
- list = new ArrayList<>();
- classifiers.put(key, list);
- }
- list.add(featureKey);
+ private static void addClassifier(
+ final Map<String, List<String>> classifiers, final String classifier, final String featureKey) {
+ final String key = classifier == null ? NULL_KEY : classifier;
+ List<String> list = classifiers.get(key);
+ if (list == null) {
+ list = new ArrayList<>();
+ classifiers.put(key, list);
+ }
+ list.add(featureKey);
}
/**
@@ -520,8 +545,8 @@ public abstract class ProjectHelper {
* @param additionalClassifier Optional additional classifier
* @param attachFeature Set to true to attach the feature
*/
- public static void validateFeatureClassifiers(final MavenProject project,
- final String additionalClassifier, final boolean attachFeature) {
+ public static void validateFeatureClassifiers(
+ final MavenProject project, final String additionalClassifier, final boolean attachFeature) {
validateFeatureClassifiers(project, true, additionalClassifier, attachFeature);
}
@@ -531,33 +556,38 @@ public abstract class ProjectHelper {
* @param project The maven project
* @param additionalClassifier Optional additional classifier
*/
- private static void validateFeatureClassifiers(final MavenProject project, final boolean classifierProvided,
- final String additionalClassifier, final boolean attachFeature) {
+ private static void validateFeatureClassifiers(
+ final MavenProject project,
+ final boolean classifierProvided,
+ final String additionalClassifier,
+ final boolean attachFeature) {
final Map<String, List<String>> classifiers = new HashMap<>();
- for(final Map.Entry<String, Feature> entry : getFeatures(project).entrySet()) {
- addClassifier(classifiers, entry.getValue().getId().getClassifier(), entry.getKey());
+ for (final Map.Entry<String, Feature> entry : getFeatures(project).entrySet()) {
+ addClassifier(classifiers, entry.getValue().getId().getClassifier(), entry.getKey());
}
- for(final Map.Entry<String, Feature> entry : getTestFeatures(project).entrySet()) {
- if ( entry.getValue().getId().getClassifier() == null ) {
- throw new RuntimeException("Found test feature without classifier in project " + project.getId() + " : " + entry.getKey());
- }
- addClassifier(classifiers, entry.getValue().getId().getClassifier(), entry.getKey());
+ for (final Map.Entry<String, Feature> entry : getTestFeatures(project).entrySet()) {
+ if (entry.getValue().getId().getClassifier() == null) {
+ throw new RuntimeException(
+ "Found test feature without classifier in project " + project.getId() + " : " + entry.getKey());
+ }
+ addClassifier(classifiers, entry.getValue().getId().getClassifier(), entry.getKey());
}
if (classifierProvided) {
final String key = ProjectHelper.generateAggregateFeatureKey(additionalClassifier, attachFeature);
- addClassifier(classifiers, additionalClassifier, key);
+ addClassifier(classifiers, additionalClassifier, key);
}
- for(final Map.Entry<String, List<String>> entry : classifiers.entrySet()) {
- if ( entry.getValue().size() > 1 ) {
- if ( entry.getKey().equals(NULL_KEY)) {
- throw new RuntimeException("More than one feature file without classifier in project " + project.getId() + " : " + toString(entry.getValue()));
- } else {
- throw new RuntimeException("More than one feature file for classifier " + entry.getKey() + " in project " + project.getId() + " : " + toString(entry.getValue()));
- }
- }
+ for (final Map.Entry<String, List<String>> entry : classifiers.entrySet()) {
+ if (entry.getValue().size() > 1) {
+ if (entry.getKey().equals(NULL_KEY)) {
+ throw new RuntimeException("More than one feature file without classifier in project "
+ + project.getId() + " : " + toString(entry.getValue()));
+ } else {
+ throw new RuntimeException("More than one feature file for classifier " + entry.getKey()
+ + " in project " + project.getId() + " : " + toString(entry.getValue()));
+ }
+ }
}
-
}
/**
@@ -566,15 +596,14 @@ public abstract class ProjectHelper {
* @param id The artifact id
* @return {@code true} if the artifact belongs to the project
*/
- public static boolean isLocalProjectArtifact(final MavenProject project,
- final ArtifactId id) {
- return id.getGroupId().equals(project.getGroupId())
- && id.getArtifactId().equals(project.getArtifactId())
- && id.getVersion().equals(project.getVersion());
+ public static boolean isLocalProjectArtifact(final MavenProject project, final ArtifactId id) {
+ return id.getGroupId().equals(project.getGroupId())
+ && id.getArtifactId().equals(project.getArtifactId())
+ && id.getVersion().equals(project.getVersion());
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public static Map<String,String> propertiesToMap(final Properties value) {
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public static Map<String, String> propertiesToMap(final Properties value) {
Map m = value;
return m;
}
@@ -605,21 +634,28 @@ public abstract class ProjectHelper {
* @param additionalVars any additional variables
* @return The read and minified JSON
*/
- public static String readFeatureFile(final MavenProject project,
+ public static String readFeatureFile(
+ final MavenProject project,
final File file,
final String suggestedClassifier,
final boolean legacyReplace,
final boolean enableProjectVars,
final String[] additionalVars) {
- final ArtifactId fileId = new ArtifactId(project.getGroupId(),
+ final ArtifactId fileId = new ArtifactId(
+ project.getGroupId(),
project.getArtifactId(),
project.getVersion(),
suggestedClassifier,
FeatureConstants.PACKAGING_FEATURE);
// replace variables
- try ( final Reader reader = new FileReader(file) ) {
- return Substitution.replaceMavenVars(project, legacyReplace, enableProjectVars, additionalVars, JSONFeatures.read(reader, fileId, file.getAbsolutePath()));
+ try (final Reader reader = new FileReader(file)) {
+ return Substitution.replaceMavenVars(
+ project,
+ legacyReplace,
+ enableProjectVars,
+ additionalVars,
+ JSONFeatures.read(reader, fileId, file.getAbsolutePath()));
} catch (final IOException e) {
throw new RuntimeException("Unable to read feature file " + file.getAbsolutePath(), e);
}
@@ -648,7 +684,7 @@ public abstract class ProjectHelper {
@SuppressWarnings("unchecked")
public static final Map<String, Map<String, String>> getDefaultMetadata(final MavenProject project) {
Map<String, Map<String, String>> map = (Map<String, Map<String, String>>) project.getContextValue(METADATA_KEY);
- if ( map == null ) {
+ if (map == null) {
map = Collections.emptyMap();
}
return map;
diff --git a/src/main/java/org/apache/sling/feature/maven/Substitution.java b/src/main/java/org/apache/sling/feature/maven/Substitution.java
index 41678bf..364282a 100644
--- a/src/main/java/org/apache/sling/feature/maven/Substitution.java
+++ b/src/main/java/org/apache/sling/feature/maven/Substitution.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -20,6 +22,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Properties;
+import aQute.bnd.version.MavenVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.interpolation.InterpolationException;
@@ -31,41 +34,39 @@ import org.codehaus.plexus.interpolation.RecursionInterceptor;
import org.codehaus.plexus.interpolation.RegexBasedInterpolator;
import org.codehaus.plexus.interpolation.SimpleRecursionInterceptor;
-import aQute.bnd.version.MavenVersion;
-
public class Substitution {
- public static String replaceMavenVars(MavenProject project,
+ public static String replaceMavenVars(
+ MavenProject project,
boolean legacyReplace,
boolean replaceProjectProps,
- String[] additionalProperties, String s) {
+ String[] additionalProperties,
+ String s) {
RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
final RecursionInterceptor recursionInterceptor;
- if ( legacyReplace ) {
+ if (legacyReplace) {
project.getProperties().setProperty("project.osgiVersion", getOSGiVersion(project.getVersion()));
interpolator.addValueSource(new PropertiesBasedValueSource(System.getProperties()));
interpolator.addValueSource(new PropertiesBasedValueSource(project.getProperties()));
List<String> synonymPrefixes = Collections.singletonList("project.");
- PrefixedValueSourceWrapper modelWrapper = new PrefixedValueSourceWrapper(
- new ObjectBasedValueSource(project),
- synonymPrefixes,
- true);
- interpolator.addValueSource( modelWrapper );
+ PrefixedValueSourceWrapper modelWrapper =
+ new PrefixedValueSourceWrapper(new ObjectBasedValueSource(project), synonymPrefixes, true);
+ interpolator.addValueSource(modelWrapper);
recursionInterceptor = new PrefixAwareRecursionInterceptor(synonymPrefixes, true);
} else {
final Properties props = new Properties();
- if ( replaceProjectProps ) {
+ if (replaceProjectProps) {
props.setProperty("project.groupId", project.getGroupId());
props.setProperty("project.artifactId", project.getArtifactId());
props.setProperty("project.version", project.getVersion());
props.setProperty("project.osgiVersion", getOSGiVersion(project.getVersion()));
}
- if ( additionalProperties != null ) {
- for(String p : additionalProperties) {
+ if (additionalProperties != null) {
+ for (String p : additionalProperties) {
p = p.trim();
// check for a system property that overwrites the project property
String value = System.getProperty(p);
@@ -96,17 +97,17 @@ public class Substitution {
private static String cleanVersionString(final String version) {
final StringBuilder sb = new StringBuilder();
boolean afterDot = false;
- for(int i=0;i<version.length(); i++) {
+ for (int i = 0; i < version.length(); i++) {
final char c = version.charAt(i);
- if ( c == '.' ) {
- if (afterDot == true ) {
+ if (c == '.') {
+ if (afterDot == true) {
sb.append('0');
}
afterDot = true;
sb.append(c);
- } else if ( afterDot && c == '0' ) {
+ } else if (afterDot && c == '0') {
// skip
- } else if ( afterDot && c == '-' ) {
+ } else if (afterDot && c == '-') {
sb.append('0');
sb.append(c);
afterDot = false;
@@ -126,7 +127,7 @@ public class Substitution {
sb.append(dav.getMinorVersion());
sb.append('.');
sb.append(dav.getIncrementalVersion());
- if ( dav.getQualifier() != null ) {
+ if (dav.getQualifier() != null) {
sb.append('.');
sb.append(dav.getQualifier());
}
diff --git a/src/main/java/org/apache/sling/feature/maven/extensions/DependencyLifecycleParticipant.java b/src/main/java/org/apache/sling/feature/maven/extensions/DependencyLifecycleParticipant.java
index a185068..457554f 100644
--- a/src/main/java/org/apache/sling/feature/maven/extensions/DependencyLifecycleParticipant.java
+++ b/src/main/java/org/apache/sling/feature/maven/extensions/DependencyLifecycleParticipant.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.extensions;
@@ -55,7 +57,8 @@ public class DependencyLifecycleParticipant extends AbstractMavenLifecyclePartic
private final RepositorySystem repoSystem;
@Inject
- public DependencyLifecycleParticipant(Logger logger, ArtifactHandlerManager artifactHandlerManager, RepositorySystem repoSystem) {
+ public DependencyLifecycleParticipant(
+ Logger logger, ArtifactHandlerManager artifactHandlerManager, RepositorySystem repoSystem) {
super();
this.logger = logger;
this.artifactHandlerManager = artifactHandlerManager;
diff --git a/src/main/java/org/apache/sling/feature/maven/extensions/FeatureArtifactHandler.java b/src/main/java/org/apache/sling/feature/maven/extensions/FeatureArtifactHandler.java
index 1c44303..5286fb3 100644
--- a/src/main/java/org/apache/sling/feature/maven/extensions/FeatureArtifactHandler.java
+++ b/src/main/java/org/apache/sling/feature/maven/extensions/FeatureArtifactHandler.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.extensions;
diff --git a/src/main/java/org/apache/sling/feature/maven/extensions/FeatureLifecycleMappingProvider.java b/src/main/java/org/apache/sling/feature/maven/extensions/FeatureLifecycleMappingProvider.java
index 5237e2c..240e184 100644
--- a/src/main/java/org/apache/sling/feature/maven/extensions/FeatureLifecycleMappingProvider.java
+++ b/src/main/java/org/apache/sling/feature/maven/extensions/FeatureLifecycleMappingProvider.java
@@ -1,30 +1,32 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.extensions;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import javax.inject.Named;
-import javax.inject.Provider;
-import javax.inject.Singleton;
-
import org.apache.maven.lifecycle.mapping.Lifecycle;
import org.apache.maven.lifecycle.mapping.LifecycleMapping;
import org.apache.maven.lifecycle.mapping.LifecyclePhase;
@@ -35,9 +37,13 @@ public class FeatureLifecycleMappingProvider implements Provider<LifecycleMappin
private static final String DEFAULT_LIFECYCLE_KEY = "default";
private static final Map<String, LifecyclePhase> BINDINGS;
+
static {
BINDINGS = new HashMap<>();
- BINDINGS.put("install", new LifecyclePhase("org.apache.sling:slingfeature-maven-plugin:attach-features,org.apache.maven.plugins:maven-install-plugin:install"));
+ BINDINGS.put(
+ "install",
+ new LifecyclePhase(
+ "org.apache.sling:slingfeature-maven-plugin:attach-features,org.apache.maven.plugins:maven-install-plugin:install"));
BINDINGS.put("deploy", new LifecyclePhase("org.apache.maven.plugins:maven-deploy-plugin:deploy"));
}
@@ -77,5 +83,4 @@ public class FeatureLifecycleMappingProvider implements Provider<LifecycleMappin
public LifecycleMapping get() {
return lifecycleMapping;
}
-
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/AbstractFeatureMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/AbstractFeatureMojo.java
index 3e35575..f658aa4 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/AbstractFeatureMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/AbstractFeatureMojo.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -65,7 +67,8 @@ public abstract class AbstractFeatureMojo extends AbstractMojo {
/**
* Directory containing feature files
*/
- @Parameter(name = FeatureProjectConfig.CFG_FEATURES,
+ @Parameter(
+ name = FeatureProjectConfig.CFG_FEATURES,
required = true,
defaultValue = FeatureProjectConfig.DEFAULT_FEATURE_DIR)
protected File features;
@@ -75,7 +78,8 @@ public abstract class AbstractFeatureMojo extends AbstractMojo {
* the configured directory. Only feature files specified by
* this include are processed.
*/
- @Parameter(name = FeatureProjectConfig.CFG_FEATURES_INCLUDES,
+ @Parameter(
+ name = FeatureProjectConfig.CFG_FEATURES_INCLUDES,
defaultValue = FeatureProjectConfig.DEFAULT_FEATURE_INCLUDES)
private String featuresIncludes;
@@ -90,7 +94,8 @@ public abstract class AbstractFeatureMojo extends AbstractMojo {
/**
* Directory containing test feature files.
*/
- @Parameter(name = FeatureProjectConfig.CFG_TEST_FEATURES,
+ @Parameter(
+ name = FeatureProjectConfig.CFG_TEST_FEATURES,
required = true,
defaultValue = FeatureProjectConfig.DEFAULT_TEST_FEATURE_DIR)
private File testFeatures;
@@ -98,7 +103,8 @@ public abstract class AbstractFeatureMojo extends AbstractMojo {
/**
* Comma separated list of includes for the test features.
*/
- @Parameter(name = FeatureProjectConfig.CFG_TEST_FEATURES_INCLUDES,
+ @Parameter(
+ name = FeatureProjectConfig.CFG_TEST_FEATURES_INCLUDES,
defaultValue = FeatureProjectConfig.DEFAULT_FEATURE_INCLUDES)
private String testFeaturesIncludes;
@@ -118,30 +124,26 @@ public abstract class AbstractFeatureMojo extends AbstractMojo {
* If set to {@code true} the artifacts from the feature are not added as dependencies
* with scope={@code provided} to the project.
*/
- @Parameter(name=FeatureProjectConfig.CFG_SKIP_ADD_FEATURE_DEPENDENCIES,
- defaultValue="false")
+ @Parameter(name = FeatureProjectConfig.CFG_SKIP_ADD_FEATURE_DEPENDENCIES, defaultValue = "false")
private boolean skipAddFeatureDependencies;
/**
* If set to {@code true} the artifacts from the test feature are not added as dependencies
* with scope={@code test} to the project.
*/
- @Parameter(name=FeatureProjectConfig.CFG_SKIP_ADD_TEST_FEATURE_DEPENDENCIES,
- defaultValue="true")
+ @Parameter(name = FeatureProjectConfig.CFG_SKIP_ADD_TEST_FEATURE_DEPENDENCIES, defaultValue = "true")
private boolean skipAddTestFeatureDependencies;
/**
* If set to {@code true} the main jar artifact is not added to the feature.
*/
- @Parameter(name=FeatureProjectConfig.CFG_SKIP_ADD_JAR_TO_FEATURE,
- defaultValue="false")
+ @Parameter(name = FeatureProjectConfig.CFG_SKIP_ADD_JAR_TO_FEATURE, defaultValue = "false")
private boolean skipAddJarToFeature;
/**
* If set to {@code true} the main jar artifact is not added to the test feature.
*/
- @Parameter(name=FeatureProjectConfig.CFG_SKIP_ADD_JAR_TO_TEST_FEATURE,
- defaultValue="false")
+ @Parameter(name = FeatureProjectConfig.CFG_SKIP_ADD_JAR_TO_TEST_FEATURE, defaultValue = "false")
private boolean skipAddJarToTestFeature;
/**
@@ -168,7 +170,7 @@ public abstract class AbstractFeatureMojo extends AbstractMojo {
/**
* The start level for the attached jar/bundle.
*/
- @Parameter(name=FeatureProjectConfig.CFG_JAR_START_ORDER)
+ @Parameter(name = FeatureProjectConfig.CFG_JAR_START_ORDER)
protected int jarStartOrder;
/**
@@ -280,18 +282,19 @@ public abstract class AbstractFeatureMojo extends AbstractMojo {
}
}
if (!dir.isDirectory()) {
- throw new MojoExecutionException(
- "Generated features configuration is not a directory: " + dir);
+ throw new MojoExecutionException("Generated features configuration is not a directory: " + dir);
}
final List<File> files = new ArrayList<>();
- ProjectHelper.scan(files, dir, this.generatedFeaturesIncludes,
- this.generatedFeaturesExcludes);
+ ProjectHelper.scan(files, dir, this.generatedFeaturesIncludes, this.generatedFeaturesExcludes);
for (final File file : files) {
getLog().debug("Reading feature file " + file);
try {
- final String json = ProjectHelper.readFeatureFile(project, file, null,
+ final String json = ProjectHelper.readFeatureFile(
+ project,
+ file,
+ null,
this.enableLegacyVariableReplacement,
this.enableProjectVariableReplacement,
this.replacePropertyVariables != null ? this.replacePropertyVariables.split(",") : null);
@@ -333,8 +336,8 @@ public abstract class AbstractFeatureMojo extends AbstractMojo {
}
private BuilderContext getBuilderContext() {
- final BuilderContext builderContext = new BuilderContext(new BaseFeatureProvider())
- .setArtifactProvider(new BaseArtifactProvider());
+ final BuilderContext builderContext =
+ new BuilderContext(new BaseFeatureProvider()).setArtifactProvider(new BaseArtifactProvider());
return builderContext;
}
@@ -348,7 +351,8 @@ public abstract class AbstractFeatureMojo extends AbstractMojo {
@Override
public Feature provide(ArtifactId id) {
// Check for the feature in the local context
- for (final Feature feat : ProjectHelper.getAssembledFeatures(project).values()) {
+ for (final Feature feat :
+ ProjectHelper.getAssembledFeatures(project).values()) {
if (feat.getId().equals(id)) {
return feat;
}
@@ -359,8 +363,7 @@ public abstract class AbstractFeatureMojo extends AbstractMojo {
}
// Finally, look the feature up via Maven's dependency mechanism
- return ProjectHelper.getOrResolveFeature(project, mavenSession, artifactHandlerManager,
- repoSystem, id);
+ return ProjectHelper.getOrResolveFeature(project, mavenSession, artifactHandlerManager, repoSystem, id);
}
}
@@ -373,9 +376,10 @@ public abstract class AbstractFeatureMojo extends AbstractMojo {
@Override
public URL provide(final ArtifactId id) {
try {
- return ProjectHelper
- .getOrResolveArtifact(project, mavenSession, artifactHandlerManager, repoSystem, id)
- .getFile().toURI().toURL();
+ return ProjectHelper.getOrResolveArtifact(project, mavenSession, artifactHandlerManager, repoSystem, id)
+ .getFile()
+ .toURI()
+ .toURL();
} catch (Exception e) {
getLog().debug("Artifact " + id.toMvnId() + " not found");
return null;
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/AbstractIncludingFeatureMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/AbstractIncludingFeatureMojo.java
index d45a15a..9a0a353 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/AbstractIncludingFeatureMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/AbstractIncludingFeatureMojo.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -51,23 +53,23 @@ public abstract class AbstractIncludingFeatureMojo extends AbstractFeatureMojo {
}
boolean hasFileInclude = false;
- for(final FeatureSelectionConfig.Selection selection : config.getSelections()) {
- switch ( selection.type ) {
- case FILES_INCLUDE:
- hasFileInclude = true;
- selectFeatureFiles(selection.instruction, config.getFilesExcludes(), result);
- break;
- case CLASSIFIER:
- selectFeatureClassifier(selection.instruction, result);
- break;
- case ARTIFACT:
- selectFeatureArtifact(selection.instruction, result);
- break;
- case REFS_INCLUDE:
- selectRefsFiles(selection.instruction, config.getFilesExcludes(), result);
- break;
- default:
- break;
+ for (final FeatureSelectionConfig.Selection selection : config.getSelections()) {
+ switch (selection.type) {
+ case FILES_INCLUDE:
+ hasFileInclude = true;
+ selectFeatureFiles(selection.instruction, config.getFilesExcludes(), result);
+ break;
+ case CLASSIFIER:
+ selectFeatureClassifier(selection.instruction, result);
+ break;
+ case ARTIFACT:
+ selectFeatureArtifact(selection.instruction, result);
+ break;
+ case REFS_INCLUDE:
+ selectRefsFiles(selection.instruction, config.getFilesExcludes(), result);
+ break;
+ default:
+ break;
}
}
@@ -139,17 +141,18 @@ public abstract class AbstractIncludingFeatureMojo extends AbstractFeatureMojo {
* @param result Map containing the result
* @throws MojoExecutionException
*/
- private void selectFeatureFiles(final String include, final List<String> excludes,
- final Map<String, Feature> result)
+ private void selectFeatureFiles(
+ final String include, final List<String> excludes, final Map<String, Feature> result)
throws MojoExecutionException {
final Map<String, Feature> projectFeatures = ProjectHelper.getAssembledFeatures(this.project);
- final String prefix = this.features.toPath().normalize().toFile().getAbsolutePath().concat(File.separator);
+ final String prefix =
+ this.features.toPath().normalize().toFile().getAbsolutePath().concat(File.separator);
final FeatureScanner scanner = new FeatureScanner(projectFeatures, prefix);
if (!excludes.isEmpty()) {
scanner.setExcludes(excludes.toArray(new String[excludes.size()]));
}
- scanner.setIncludes(new String[] { include });
+ scanner.setIncludes(new String[] {include});
scanner.scan();
if (!include.contains("*") && scanner.getIncluded().isEmpty()) {
@@ -165,7 +168,7 @@ public abstract class AbstractIncludingFeatureMojo extends AbstractFeatureMojo {
for (final String exclude : excludes) {
if (!exclude.contains("*")) {
final FeatureScanner excludeScanner = new FeatureScanner(projectFeatures, prefix);
- excludeScanner.setIncludes(new String[] { exclude });
+ excludeScanner.setIncludes(new String[] {exclude});
excludeScanner.scan();
if (excludeScanner.getIncluded().isEmpty()) {
throw new MojoExecutionException("FeatureExclude " + exclude + " not found.");
@@ -189,31 +192,32 @@ public abstract class AbstractIncludingFeatureMojo extends AbstractFeatureMojo {
if (!excludes.isEmpty()) {
scanner.setExcludes(excludes.toArray(new String[excludes.size()]));
}
- scanner.setIncludes(new String[] { selection });
+ scanner.setIncludes(new String[] {selection});
scanner.scan();
- if (!selection.contains("*") && scanner.getIncludedFiles().length == 0 ) {
+ if (!selection.contains("*") && scanner.getIncludedFiles().length == 0) {
throw new MojoExecutionException("RefsInclude " + selection + " not found.");
}
// sort result
final List<String> includedFiles = new ArrayList<>(Arrays.asList(scanner.getIncludedFiles()));
Collections.sort(includedFiles);
- for(final String path : includedFiles) {
+ for (final String path : includedFiles) {
final File selectedFile = new File(this.project.getBasedir(), path.replace('/', File.separatorChar));
try {
final List<String> urls = IOUtils.parseFeatureRefFile(selectedFile);
- for(final String url : urls) {
+ for (final String url : urls) {
try {
final ArtifactId id = ArtifactId.parse(url);
if (ProjectHelper.isLocalProjectArtifact(this.project, id)) {
throw new MojoExecutionException(
- "RefsFile configuration is used to select a local feature: " + id.toMvnId());
+ "RefsFile configuration is used to select a local feature: " + id.toMvnId());
}
- final Feature feature = ProjectHelper.getOrResolveFeature(this.project, this.mavenSession,
- this.artifactHandlerManager, this.repoSystem, id);
+ final Feature feature = ProjectHelper.getOrResolveFeature(
+ this.project, this.mavenSession, this.artifactHandlerManager, this.repoSystem, id);
result.put(id.toMvnUrl(), feature);
- } catch ( final IllegalArgumentException e) {
- throw new MojoExecutionException("Reference " + url + " in " + selectedFile.getAbsolutePath() + " is not a supported url.");
+ } catch (final IllegalArgumentException e) {
+ throw new MojoExecutionException("Reference " + url + " in " + selectedFile.getAbsolutePath()
+ + " is not a supported url.");
}
}
} catch (final IOException e) {
@@ -227,10 +231,10 @@ public abstract class AbstractIncludingFeatureMojo extends AbstractFeatureMojo {
final ArtifactId id = ArtifactId.parse(artifactId);
if (ProjectHelper.isLocalProjectArtifact(this.project, id)) {
throw new MojoExecutionException(
- "FeatureArtifact configuration is used to select a local feature: " + id.toMvnId());
+ "FeatureArtifact configuration is used to select a local feature: " + id.toMvnId());
}
- final Feature feature = ProjectHelper.getOrResolveFeature(this.project, this.mavenSession,
- this.artifactHandlerManager, this.repoSystem, id);
+ final Feature feature = ProjectHelper.getOrResolveFeature(
+ this.project, this.mavenSession, this.artifactHandlerManager, this.repoSystem, id);
result.put(id.toMvnUrl(), feature);
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/AbstractRepositoryMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/AbstractRepositoryMojo.java
index 5eab16a..6a4ef51 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/AbstractRepositoryMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/AbstractRepositoryMojo.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -63,6 +65,7 @@ public abstract class AbstractRepositoryMojo extends AbstractIncludingFeatureMoj
}
}
}
+
protected Feature getLocalFeature(final ArtifactId id) {
final Map<String, org.apache.sling.feature.Feature> features = ProjectHelper.getAssembledFeatures(this.project);
for (Feature f : features.values()) {
@@ -74,40 +77,46 @@ public abstract class AbstractRepositoryMojo extends AbstractIncludingFeatureMoj
}
protected void processFeature(final File artifactDir, final Feature f) throws MojoExecutionException {
- for(final org.apache.sling.feature.Artifact artifact : f.getBundles()) {
+ for (final org.apache.sling.feature.Artifact artifact : f.getBundles()) {
copyArtifactToRepository(artifact.getId(), artifactDir);
}
- for(final Extension ext : f.getExtensions()) {
- if ( ext.getType() == ExtensionType.ARTIFACTS ) {
- for(final org.apache.sling.feature.Artifact artifact : ext.getArtifacts()) {
+ for (final Extension ext : f.getExtensions()) {
+ if (ext.getType() == ExtensionType.ARTIFACTS) {
+ for (final org.apache.sling.feature.Artifact artifact : ext.getArtifacts()) {
copyArtifactToRepository(artifact.getId(), artifactDir);
}
}
}
final ExecutionEnvironmentExtension eee = ExecutionEnvironmentExtension.getExecutionEnvironmentExtension(f);
- if ( eee != null && eee.getFramework() != null ) {
+ if (eee != null && eee.getFramework() != null) {
copyArtifactToRepository(eee.getFramework().getId(), artifactDir);
}
final File featureFile = getRepositoryFile(artifactDir, f.getId());
featureFile.getParentFile().mkdirs();
- try ( final Writer writer = new FileWriter(featureFile)) {
+ try (final Writer writer = new FileWriter(featureFile)) {
FeatureJSONWriter.write(writer, f);
} catch (final IOException e) {
- throw new MojoExecutionException("Unable to write feature file :" + f.getId().toMvnId(), e);
+ throw new MojoExecutionException(
+ "Unable to write feature file :" + f.getId().toMvnId(), e);
}
- if ( f.getPrototype() != null ) {
- if (ProjectHelper.isLocalProjectArtifact(this.project, f.getPrototype().getId())) {
+ if (f.getPrototype() != null) {
+ if (ProjectHelper.isLocalProjectArtifact(
+ this.project, f.getPrototype().getId())) {
final Feature prototype = this.getLocalFeature(f.getPrototype().getId());
if (prototype == null) {
- throw new MojoExecutionException(
- "Unable to find project feature " + f.getPrototype().getId().toMvnId());
+ throw new MojoExecutionException("Unable to find project feature "
+ + f.getPrototype().getId().toMvnId());
}
processFeature(artifactDir, prototype);
} else {
- final Feature prototype = ProjectHelper.getOrResolveFeature(project, mavenSession, artifactHandlerManager,
- repoSystem, f.getPrototype().getId());
+ final Feature prototype = ProjectHelper.getOrResolveFeature(
+ project,
+ mavenSession,
+ artifactHandlerManager,
+ repoSystem,
+ f.getPrototype().getId());
processFeature(artifactDir, prototype);
}
}
@@ -130,21 +139,19 @@ public abstract class AbstractRepositoryMojo extends AbstractIncludingFeatureMoj
* Copy a single artifact to the repository
* @throws MojoExecutionException
*/
- private void copyArtifactToRepository(final ArtifactId artifactId,
- final File artifactDir)
- throws MojoExecutionException {
+ private void copyArtifactToRepository(final ArtifactId artifactId, final File artifactDir)
+ throws MojoExecutionException {
final File artifactFile = getRepositoryFile(artifactDir, artifactId);
if (artifactFile.exists() && !artifactId.getVersion().endsWith("-SNAPSHOT")) {
return;
}
- File source = ProjectHelper.getOrResolveArtifact(this.project,
- this.mavenSession,
- this.artifactHandlerManager,
- this.repoSystem,
- artifactId).getFile();
+ File source = ProjectHelper.getOrResolveArtifact(
+ this.project, this.mavenSession, this.artifactHandlerManager, this.repoSystem, artifactId)
+ .getFile();
if (ProjectHelper.isLocalProjectArtifact(this.project, artifactId) && source.isDirectory()) {
if (artifactId.getClassifier() != null) {
- throw new MojoExecutionException("Classified project artifacts are not supported: " + artifactId.toMvnId());
+ throw new MojoExecutionException(
+ "Classified project artifacts are not supported: " + artifactId.toMvnId());
}
source = this.project.getArtifact().getFile();
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/Aggregate.java b/src/main/java/org/apache/sling/feature/maven/mojos/Aggregate.java
index ef770fc..1610b99 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/Aggregate.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/Aggregate.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -77,8 +79,19 @@ public class Aggregate extends FeatureSelectionConfig {
*/
@Override
public int hashCode() {
- return Objects.hash(super.hashCode(), artifactsOverrides, attach, classifier, configurationOverrides, description,
- frameworkPropertiesOverrides, markAsComplete, markAsFinal, title, variablesOverrides, vendor);
+ return Objects.hash(
+ super.hashCode(),
+ artifactsOverrides,
+ attach,
+ classifier,
+ configurationOverrides,
+ description,
+ frameworkPropertiesOverrides,
+ markAsComplete,
+ markAsFinal,
+ title,
+ variablesOverrides,
+ vendor);
}
/* (non-Javadoc)
@@ -86,20 +99,20 @@ public class Aggregate extends FeatureSelectionConfig {
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!super.equals(obj))
- return false;
- if (getClass() != obj.getClass())
- return false;
+ if (this == obj) return true;
+ if (!super.equals(obj)) return false;
+ if (getClass() != obj.getClass()) return false;
Aggregate other = (Aggregate) obj;
- return Objects.equals(artifactsOverrides, other.artifactsOverrides) && attach == other.attach
+ return Objects.equals(artifactsOverrides, other.artifactsOverrides)
+ && attach == other.attach
&& Objects.equals(classifier, other.classifier)
&& Objects.equals(configurationOverrides, other.configurationOverrides)
&& Objects.equals(description, other.description)
&& Objects.equals(frameworkPropertiesOverrides, other.frameworkPropertiesOverrides)
- && markAsComplete == other.markAsComplete && markAsFinal == other.markAsFinal
- && Objects.equals(title, other.title) && Objects.equals(variablesOverrides, other.variablesOverrides)
+ && markAsComplete == other.markAsComplete
+ && markAsFinal == other.markAsFinal
+ && Objects.equals(title, other.title)
+ && Objects.equals(variablesOverrides, other.variablesOverrides)
&& Objects.equals(vendor, other.vendor);
}
@@ -109,7 +122,8 @@ public class Aggregate extends FeatureSelectionConfig {
+ ", classifier=" + classifier + ", attach=" + attach
+ ", markAsFinal=" + markAsFinal + ", markAsComplete=" + markAsComplete + ", title=" + title
+ ", description=" + description + ", vendor=" + vendor + ", artifactsOverrides=" + artifactsOverrides
- + ", variablesOverrides=" + variablesOverrides + ", frameworkPropertiesOverrides=" + frameworkPropertiesOverrides + "]";
+ + ", variablesOverrides=" + variablesOverrides + ", frameworkPropertiesOverrides="
+ + frameworkPropertiesOverrides + "]";
}
public List<ArtifactId> getArtifactOverrideRules() {
@@ -132,4 +146,4 @@ public class Aggregate extends FeatureSelectionConfig {
}
return result;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/AggregateFeaturesMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/AggregateFeaturesMojo.java
index 9d0127a..a511280 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/AggregateFeaturesMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/AggregateFeaturesMojo.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -44,15 +46,16 @@ import org.apache.sling.feature.maven.ProjectHelper;
/**
* Aggregate multiple features into a single one.
*/
-@Mojo(name = "aggregate-features",
- defaultPhase = LifecyclePhase.GENERATE_RESOURCES,
- requiresDependencyResolution = ResolutionScope.TEST,
- threadSafe = true
-)
+@Mojo(
+ name = "aggregate-features",
+ defaultPhase = LifecyclePhase.GENERATE_RESOURCES,
+ requiresDependencyResolution = ResolutionScope.TEST,
+ threadSafe = true)
public class AggregateFeaturesMojo extends AbstractIncludingFeatureMojo {
/* A context flag to track if we have already been processed */
- private static final String PROPERTY_HANDLED_AGGREGATE_FEATURES = AggregateFeaturesMojo.class.getName() + "/generated";
+ private static final String PROPERTY_HANDLED_AGGREGATE_FEATURES =
+ AggregateFeaturesMojo.class.getName() + "/generated";
/**
* The definition of the features used to create the new feature.
@@ -62,43 +65,47 @@ public class AggregateFeaturesMojo extends AbstractIncludingFeatureMojo {
@Parameter
Map<String, Properties> handlerConfiguration = new HashMap<>();
-
+
/**
* Additional post process handlers to use when aggregating
- *
+ *
* <p>Normally handlers are discovered using the {@link ServiceLoader} mechanism but some
* special-purpose handlers are not registered by default.</p>
- *
+ *
* <p>These handlers will be installed after the ones discovered by the {@link ServiceLoader}.</p>
*/
@Parameter
List<String> additionalPostProcessHandlers = new ArrayList<>();
-
+
@Override
public void execute() throws MojoExecutionException {
checkPreconditions();
// SLING-9656 - make sure to process each aggregate feature only once
@SuppressWarnings("unchecked")
- Map<Aggregate, Feature> handledAggregates = (Map<Aggregate, Feature>)this.project.getContextValue(PROPERTY_HANDLED_AGGREGATE_FEATURES);
+ Map<Aggregate, Feature> handledAggregates =
+ (Map<Aggregate, Feature>) this.project.getContextValue(PROPERTY_HANDLED_AGGREGATE_FEATURES);
if (handledAggregates == null) {
handledAggregates = new HashMap<>();
this.project.setContextValue(PROPERTY_HANDLED_AGGREGATE_FEATURES, handledAggregates);
}
for (final Aggregate aggregate : aggregates) {
- final String aggregateFeatureKey = ProjectHelper.generateAggregateFeatureKey(aggregate.classifier, aggregate.attach);
+ final String aggregateFeatureKey =
+ ProjectHelper.generateAggregateFeatureKey(aggregate.classifier, aggregate.attach);
// SLING-9656 - check if we have already processed this one
Feature processedFeature = handledAggregates.get(aggregate);
if (processedFeature != null) {
getLog().debug("Found previously processed aggregate-feature " + aggregateFeatureKey);
if (ProjectHelper.getAssembledFeatures(project).remove(aggregateFeatureKey, processedFeature)) {
- getLog().debug(" Removed previous aggregate feature '" + aggregateFeatureKey + "' from the project assembled features map");
+ getLog().debug(" Removed previous aggregate feature '" + aggregateFeatureKey
+ + "' from the project assembled features map");
}
if (ProjectHelper.getFeatures(this.project).remove(aggregateFeatureKey, processedFeature)) {
- getLog().debug(" Removed previous aggregate feature '" + aggregateFeatureKey + "' from the project features map");
+ getLog().debug(" Removed previous aggregate feature '" + aggregateFeatureKey
+ + "' from the project features map");
}
}
@@ -110,31 +117,35 @@ public class AggregateFeaturesMojo extends AbstractIncludingFeatureMojo {
getLog().warn("No features found for aggregate with classifier " + aggregate.classifier);
}
- final Map<String,String> variablesOverwrites = new HashMap<>();
- if (aggregate.variablesOverrides != null)
- variablesOverwrites.putAll(aggregate.variablesOverrides);
- final Map<String,String> frameworkPropertiesOverwrites = new HashMap<>();
+ final Map<String, String> variablesOverwrites = new HashMap<>();
+ if (aggregate.variablesOverrides != null) variablesOverwrites.putAll(aggregate.variablesOverrides);
+ final Map<String, String> frameworkPropertiesOverwrites = new HashMap<>();
if (aggregate.frameworkPropertiesOverrides != null)
frameworkPropertiesOverwrites.putAll(aggregate.frameworkPropertiesOverrides);
final BuilderContext builderContext = new BuilderContext(new BaseFeatureProvider() {
- @Override
- public Feature provide(ArtifactId id) {
- // check in selection
- for (final Feature feat : selection.values()) {
- if (feat.getId().equals(id)) {
- return feat;
+ @Override
+ public Feature provide(ArtifactId id) {
+ // check in selection
+ for (final Feature feat : selection.values()) {
+ if (feat.getId().equals(id)) {
+ return feat;
+ }
+ }
+ return super.provide(id);
}
- }
- return super.provide(id);
- }
- }).setArtifactProvider(new BaseArtifactProvider())
- .addVariablesOverrides(variablesOverwrites)
- .addFrameworkPropertiesOverrides(frameworkPropertiesOverwrites)
- .addMergeExtensions(StreamSupport.stream(Spliterators.spliteratorUnknownSize(
- ServiceLoader.load(MergeHandler.class).iterator(), Spliterator.ORDERED),
- false).toArray(MergeHandler[]::new))
- .addPostProcessExtensions(postProcessHandlers().toArray(PostProcessHandler[]::new));
+ })
+ .setArtifactProvider(new BaseArtifactProvider())
+ .addVariablesOverrides(variablesOverwrites)
+ .addFrameworkPropertiesOverrides(frameworkPropertiesOverwrites)
+ .addMergeExtensions(StreamSupport.stream(
+ Spliterators.spliteratorUnknownSize(
+ ServiceLoader.load(MergeHandler.class)
+ .iterator(),
+ Spliterator.ORDERED),
+ false)
+ .toArray(MergeHandler[]::new))
+ .addPostProcessExtensions(postProcessHandlers().toArray(PostProcessHandler[]::new));
for (final ArtifactId rule : aggregate.getArtifactOverrideRules()) {
builderContext.addArtifactsOverride(rule);
}
@@ -148,8 +159,12 @@ public class AggregateFeaturesMojo extends AbstractIncludingFeatureMojo {
builderContext.setHandlerConfiguration(key, ProjectHelper.propertiesToMap(props));
}
- final ArtifactId newFeatureID = new ArtifactId(project.getGroupId(), project.getArtifactId(),
- project.getVersion(), aggregate.classifier, FeatureConstants.PACKAGING_FEATURE);
+ final ArtifactId newFeatureID = new ArtifactId(
+ project.getGroupId(),
+ project.getArtifactId(),
+ project.getVersion(),
+ aggregate.classifier,
+ FeatureConstants.PACKAGING_FEATURE);
final Feature result = assembleFeature(newFeatureID, builderContext, selection);
if (aggregate.markAsFinal) {
@@ -181,31 +196,38 @@ public class AggregateFeaturesMojo extends AbstractIncludingFeatureMojo {
}
private Stream<PostProcessHandler> postProcessHandlers() {
-
- Stream<PostProcessHandler> serviceLoaderHandlers = StreamSupport.stream(Spliterators.spliteratorUnknownSize(
- ServiceLoader.load(PostProcessHandler.class).iterator(), Spliterator.ORDERED), false);
+
+ Stream<PostProcessHandler> serviceLoaderHandlers = StreamSupport.stream(
+ Spliterators.spliteratorUnknownSize(
+ ServiceLoader.load(PostProcessHandler.class).iterator(), Spliterator.ORDERED),
+ false);
Stream<PostProcessHandler> additionalHandlers = this.additionalPostProcessHandlers.stream()
- .map( extension -> {
- try {
- return (PostProcessHandler) Class.forName(extension).getDeclaredConstructor().newInstance();
- } catch (Exception e) {
- throw new RuntimeException("Unable to instantiate post-process extension " + extension, e);
- }
- });
-
+ .map(extension -> {
+ try {
+ return (PostProcessHandler) Class.forName(extension)
+ .getDeclaredConstructor()
+ .newInstance();
+ } catch (Exception e) {
+ throw new RuntimeException("Unable to instantiate post-process extension " + extension, e);
+ }
+ });
+
return Stream.concat(serviceLoaderHandlers, additionalHandlers);
}
- Feature assembleFeature(final ArtifactId newFeatureID, final BuilderContext builderContext,
- final Map<String, Feature> selection) throws MojoExecutionException {
+ Feature assembleFeature(
+ final ArtifactId newFeatureID, final BuilderContext builderContext, final Map<String, Feature> selection)
+ throws MojoExecutionException {
try {
- return FeatureBuilder.assemble(newFeatureID, builderContext,
- selection.values().toArray(new Feature[selection.size()]));
- } catch ( final Exception e) {
- throw new MojoExecutionException("Unable to aggregate feature " +
- (newFeatureID.getClassifier() == null ? "<main artifact>" : newFeatureID.getClassifier())
- + " : " + e.getMessage(), e);
+ return FeatureBuilder.assemble(
+ newFeatureID, builderContext, selection.values().toArray(new Feature[selection.size()]));
+ } catch (final Exception e) {
+ throw new MojoExecutionException(
+ "Unable to aggregate feature "
+ + (newFeatureID.getClassifier() == null ? "<main artifact>" : newFeatureID.getClassifier())
+ + " : " + e.getMessage(),
+ e);
}
}
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/AnalyseFeaturesMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/AnalyseFeaturesMojo.java
index 1cab2fe..ed759de 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/AnalyseFeaturesMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/AnalyseFeaturesMojo.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -42,11 +44,11 @@ import org.apache.sling.feature.scanner.Scanner;
/**
* Analyse the feature.
*/
-@Mojo(name = "analyse-features",
+@Mojo(
+ name = "analyse-features",
defaultPhase = LifecyclePhase.VERIFY,
- requiresDependencyResolution = ResolutionScope.TEST,
- threadSafe = true
- )
+ requiresDependencyResolution = ResolutionScope.TEST,
+ threadSafe = true)
public class AnalyseFeaturesMojo extends AbstractIncludingFeatureMojo {
/**
@@ -84,15 +86,22 @@ public class AnalyseFeaturesMojo extends AbstractIncludingFeatureMojo {
list = Collections.singletonList(a);
}
- getLog().debug(MessageUtils.buffer().a("Setting up the ").strong("Scanner").a("...").toString());
+ getLog().debug(MessageUtils.buffer()
+ .a("Setting up the ")
+ .strong("Scanner")
+ .a("...")
+ .toString());
Scanner scanner;
try {
scanner = new Scanner(getArtifactProvider());
} catch (final IOException e) {
- throw new MojoExecutionException("A fatal error occurred while setting up the Scanner, see error cause:",
- e);
+ throw new MojoExecutionException(
+ "A fatal error occurred while setting up the Scanner, see error cause:", e);
}
- getLog().debug(MessageUtils.buffer().strong("Scanner").a(" successfully set up").toString());
+ getLog().debug(MessageUtils.buffer()
+ .strong("Scanner")
+ .a(" successfully set up")
+ .toString());
FeatureProvider featureProvider = getFeatureProvider();
@@ -101,8 +110,11 @@ public class AnalyseFeaturesMojo extends AbstractIncludingFeatureMojo {
try {
Map<String, Map<String, String>> taskConfiguration = an.getTaskConfiguration();
- getLog().debug(MessageUtils.buffer().a("Setting up the ").strong("analyser")
- .a(" with following configuration:").toString());
+ getLog().debug(MessageUtils.buffer()
+ .a("Setting up the ")
+ .strong("analyser")
+ .a(" with following configuration:")
+ .toString());
getLog().debug(" * Task Configuration = " + taskConfiguration);
Set<String> includedTasks = an.getIncludeTasks();
if (includedTasks == null) {
@@ -122,14 +134,18 @@ public class AnalyseFeaturesMojo extends AbstractIncludingFeatureMojo {
getLog().debug(" * Include Tasks = " + includedTasks);
getLog().debug(" * Exclude Tasks = " + an.getExcludeTasks());
final Analyser analyser = new Analyser(scanner, taskConfiguration, includedTasks, an.getExcludeTasks());
- getLog().debug(MessageUtils.buffer().strong("Analyser").a(" successfully set up").toString());
+ getLog().debug(MessageUtils.buffer()
+ .strong("Analyser")
+ .a(" successfully set up")
+ .toString());
getLog().debug("Retrieving Feature files...");
- final Collection<Feature> features = this.getSelectedFeatures(an).values();
+ final Collection<Feature> features =
+ this.getSelectedFeatures(an).values();
if (features.isEmpty()) {
getLog().debug(
- "There are no associated feature files to current project, plugin execution will be skipped");
+ "There are no associated feature files to current project, plugin execution will be skipped");
continue;
} else {
getLog().debug("Starting analysis of features...");
@@ -137,18 +153,23 @@ public class AnalyseFeaturesMojo extends AbstractIncludingFeatureMojo {
for (final Feature f : features) {
try {
- getLog().debug(MessageUtils.buffer().a("Analyzing feature ").strong(f.getId().toMvnId())
- .a(" ...").toString());
+ getLog().debug(MessageUtils.buffer()
+ .a("Analyzing feature ")
+ .strong(f.getId().toMvnId())
+ .a(" ...")
+ .toString());
Dependency fwk = an.getFramework();
if (fwk == null) {
fwk = this.framework;
}
- final AnalyserResult result = analyser.analyse(f, ProjectHelper.toArtifactId(fwk), featureProvider);
+ final AnalyserResult result =
+ analyser.analyse(f, ProjectHelper.toArtifactId(fwk), featureProvider);
results.computeIfAbsent(f, (key) -> new ArrayList<>()).add(result);
} catch (final Exception t) {
throw new MojoFailureException(
- "Exception during analysing feature " + f.getId().toMvnId() + " : " + t.getMessage(),
+ "Exception during analysing feature "
+ + f.getId().toMvnId() + " : " + t.getMessage(),
t);
}
}
@@ -160,21 +181,26 @@ public class AnalyseFeaturesMojo extends AbstractIncludingFeatureMojo {
}
}
boolean hasErrors = false;
- for(final Map.Entry<Feature, List<AnalyserResult>> entry : results.entrySet()) {
+ for (final Map.Entry<Feature, List<AnalyserResult>> entry : results.entrySet()) {
final Feature f = entry.getKey();
final List<AnalyserResult> result = entry.getValue();
- final List<String> warnings = result.stream().flatMap(r -> r.getWarnings().stream()).collect(Collectors.toList());
- final List<String> errors = result.stream().flatMap(r -> r.getErrors().stream()).collect(Collectors.toList());
+ final List<String> warnings =
+ result.stream().flatMap(r -> r.getWarnings().stream()).collect(Collectors.toList());
+ final List<String> errors =
+ result.stream().flatMap(r -> r.getErrors().stream()).collect(Collectors.toList());
- if ( (warnings.isEmpty() || !logWarnings) && errors.isEmpty() ) {
- getLog().debug(MessageUtils.buffer().a("feature ").project(f.getId().toMvnId())
- .a(" succesfully passed all analysis").toString());
+ if ((warnings.isEmpty() || !logWarnings) && errors.isEmpty()) {
+ getLog().debug(MessageUtils.buffer()
+ .a("feature ")
+ .project(f.getId().toMvnId())
+ .a(" succesfully passed all analysis")
+ .toString());
} else {
final String message;
if (!errors.isEmpty()) {
if (logWarnings && !warnings.isEmpty()) {
- message ="errors and warnings";
+ message = "errors and warnings";
} else {
message = "errors";
}
@@ -183,28 +209,32 @@ public class AnalyseFeaturesMojo extends AbstractIncludingFeatureMojo {
message = "warnings";
}
final String m = "Analyser detected "
- .concat(message).concat(" on feature '").concat(f.getId().toMvnId()).concat("'.");
+ .concat(message)
+ .concat(" on feature '")
+ .concat(f.getId().toMvnId())
+ .concat("'.");
if (hasErrors) {
getLog().error(m);
} else {
getLog().warn(m);
}
- if ( logWarnings ) {
+ if (logWarnings) {
for (final String msg : warnings) {
getLog().warn(msg);
}
}
- for (final String msg : errors) {
+ for (final String msg : errors) {
getLog().error(msg);
}
}
}
if (hasErrors) {
- if ( failOnAnalyserErrors ) {
+ if (failOnAnalyserErrors) {
throw new MojoFailureException(
- "One or more feature analyser(s) detected feature error(s), please read the plugin log for more details");
+ "One or more feature analyser(s) detected feature error(s), please read the plugin log for more details");
}
- getLog().warn("Errors found during analyser run, but this plugin is configured to ignore errors and continue the build!");
+ getLog().warn(
+ "Errors found during analyser run, but this plugin is configured to ignore errors and continue the build!");
}
}
@@ -214,7 +244,11 @@ public class AnalyseFeaturesMojo extends AbstractIncludingFeatureMojo {
@Override
public URL provide(final ArtifactId id) {
try {
- return ProjectHelper.getOrResolveArtifact(project, mavenSession, artifactHandlerManager, repoSystem, id).getFile().toURI().toURL();
+ return ProjectHelper.getOrResolveArtifact(
+ project, mavenSession, artifactHandlerManager, repoSystem, id)
+ .getFile()
+ .toURI()
+ .toURL();
} catch (final MalformedURLException e) {
getLog().debug("Malformed url " + e.getMessage(), e);
// ignore
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java
index c6e0ba5..7e6052c 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -110,7 +112,11 @@ import org.osgi.namespace.service.ServiceNamespace;
/**
* Generates the APIs JARs for the selected feature files.
*/
-@Mojo(name = "apis-jar", defaultPhase = LifecyclePhase.PACKAGE, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true)
+@Mojo(
+ name = "apis-jar",
+ defaultPhase = LifecyclePhase.PACKAGE,
+ requiresDependencyResolution = ResolutionScope.TEST,
+ threadSafe = true)
public class ApisJarMojo extends AbstractIncludingFeatureMojo {
/**
@@ -460,7 +466,7 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
if (features.isEmpty()) {
getLog().info(
- "There are no associated feature files in the current project, plugin execution will be skipped");
+ "There are no associated feature files in the current project, plugin execution will be skipped");
} else {
getLog().debug("Starting APIs JARs creation...");
@@ -476,10 +482,14 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
* Create api jars for a feature
*/
private void onFeature(final Feature feature) throws MojoExecutionException {
- getLog().info(MessageUtils.buffer().a("Creating API JARs for Feature ").strong(feature.getId().toMvnId())
- .a(" ...").toString());
-
- final RegionSupport regionSupport = new RegionSupport(this.getLog(), this.incrementalApis, this.toggleApiOnly, this.includeRegions, this.excludeRegions);
+ getLog().info(MessageUtils.buffer()
+ .a("Creating API JARs for Feature ")
+ .strong(feature.getId().toMvnId())
+ .a(" ...")
+ .toString());
+
+ final RegionSupport regionSupport = new RegionSupport(
+ this.getLog(), this.incrementalApis, this.toggleApiOnly, this.includeRegions, this.excludeRegions);
final ApiRegions regions = regionSupport.getApiRegions(feature);
if (regions == null) {
// wrongly configured api regions - skip execution, info is logged already so we
@@ -517,14 +527,15 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
ctx.getConfig().logConfiguration(getLog());
// check additional extension configuration first to fail fast
- if ( this.generateJavadocJar ) {
+ if (this.generateJavadocJar) {
for (final ApiRegion apiRegion : regions.listRegions()) {
final String regionName = apiRegion.getName();
final List<Artifact> artifacts = ApisUtil.getAdditionalJavadocArtifacts(ctx, regionName);
- for(final Artifact artifact : artifacts ) {
- if ( ctx.getFeature().getBundles().getExact(artifact.getId() ) != null ) {
- throw new MojoExecutionException("Additional javadoc artifact is also listed as a bundle " + artifact.getId().toMvnId());
+ for (final Artifact artifact : artifacts) {
+ if (ctx.getFeature().getBundles().getExact(artifact.getId()) != null) {
+ throw new MojoExecutionException("Additional javadoc artifact is also listed as a bundle "
+ + artifact.getId().toMvnId());
}
}
}
@@ -536,7 +547,7 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
}
final List<ArtifactInfo> additionalInfos = new ArrayList<>();
- if ( this.generateJavadocJar ) {
+ if (this.generateJavadocJar) {
for (final ApiRegion apiRegion : regions.listRegions()) {
additionalInfos.addAll(getAdditionalJavadocArtifacts(ctx, apiRegion, regionSupport));
}
@@ -545,8 +556,10 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
// sources report
final List<ArtifactInfo> allInfos = new ArrayList<>(ctx.getArtifactInfos());
allInfos.addAll(additionalInfos);
- final File sourcesReport = new File(mainOutputDir, this.project.getArtifactId().concat("-sources-report.txt"));
- ApisUtil.writeSourceReport(this.generateSourceJar || this.generateJavadocJar, getLog(), sourcesReport, allInfos);
+ final File sourcesReport =
+ new File(mainOutputDir, this.project.getArtifactId().concat("-sources-report.txt"));
+ ApisUtil.writeSourceReport(
+ this.generateSourceJar || this.generateJavadocJar, getLog(), sourcesReport, allInfos);
boolean hasErrors = false;
@@ -559,26 +572,52 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
final List<Map.Entry<String, File>> additionalResources = new ArrayList<>();
if (generateApiJar) {
- final Collection<ArtifactInfo> infos = ctx.getArtifactInfos(regionName, ctx.getConfig().isUseApiDependencies());
+ final Collection<ArtifactInfo> infos =
+ ctx.getArtifactInfos(regionName, ctx.getConfig().isUseApiDependencies());
this.runProcessor(ctx, apiRegion, ArtifactType.APIS, this.apiResources, additionalResources, infos);
- final File apiJar = createArchive(ctx, apiRegion, ArtifactType.APIS, this.apiResources, infos, additionalResources, report);
- report(ctx, apiJar, ArtifactType.APIS, regionSupport, apiRegion, ctx.getConfig().isUseApiDependencies(), report, null);
+ final File apiJar = createArchive(
+ ctx, apiRegion, ArtifactType.APIS, this.apiResources, infos, additionalResources, report);
+ report(
+ ctx,
+ apiJar,
+ ArtifactType.APIS,
+ regionSupport,
+ apiRegion,
+ ctx.getConfig().isUseApiDependencies(),
+ report,
+ null);
additionalResources.clear();
}
// run processor on sources
- if ( generateSourceJar || generateJavadocJar ) {
+ if (generateSourceJar || generateJavadocJar) {
final List<ArtifactInfo> infos = new ArrayList<>(ctx.getArtifactInfos(regionName, false));
- if ( generateJavadocJar ) {
+ if (generateJavadocJar) {
infos.addAll(getAdditionalJavadocArtifacts(ctx, apiRegion, regionSupport));
}
this.runProcessor(ctx, apiRegion, ArtifactType.SOURCES, this.apiResources, additionalResources, infos);
}
if (generateSourceJar) {
- final Collection<ArtifactInfo> infos = ctx.getArtifactInfos(regionName, ctx.getConfig().isUseApiDependencies());
- final File sourceJar = createArchive(ctx, apiRegion, ArtifactType.SOURCES, this.apiSourceResources, infos, additionalResources, report);
- report(ctx, sourceJar, ArtifactType.SOURCES, regionSupport, apiRegion, ctx.getConfig().isUseApiDependencies(), report, null);
+ final Collection<ArtifactInfo> infos =
+ ctx.getArtifactInfos(regionName, ctx.getConfig().isUseApiDependencies());
+ final File sourceJar = createArchive(
+ ctx,
+ apiRegion,
+ ArtifactType.SOURCES,
+ this.apiSourceResources,
+ infos,
+ additionalResources,
+ report);
+ report(
+ ctx,
+ sourceJar,
+ ArtifactType.SOURCES,
+ regionSupport,
+ apiRegion,
+ ctx.getConfig().isUseApiDependencies(),
+ report,
+ null);
}
if (ctx.getConfig().isUseApiDependencies() && (this.generateApiJar || this.generateSourceJar)) {
@@ -587,24 +626,47 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
if (generateJavadocJar) {
final File javadocsDir = new File(regionDir, ArtifactType.JAVADOC.getId());
- final ExecutionEnvironmentExtension ext = ExecutionEnvironmentExtension
- .getExecutionEnvironmentExtension(feature);
+ final ExecutionEnvironmentExtension ext =
+ ExecutionEnvironmentExtension.getExecutionEnvironmentExtension(feature);
final JavadocLinks links = new JavadocLinks();
- links.calculateLinks(ctx.getConfig().getJavadocLinks(), ctx.getArtifactInfos(regionName, false),
+ links.calculateLinks(
+ ctx.getConfig().getJavadocLinks(),
+ ctx.getArtifactInfos(regionName, false),
ext != null ? ext.getFramework() : null);
- final Collection<ArtifactInfo> infos = generateJavadoc(ctx, regionName, links, javadocsDir, regionSupport, ctx.getConfig().isUseApiDependenciesForJavadoc());
+ final Collection<ArtifactInfo> infos = generateJavadoc(
+ ctx,
+ regionName,
+ links,
+ javadocsDir,
+ regionSupport,
+ ctx.getConfig().isUseApiDependenciesForJavadoc());
ctx.setJavadocDir(javadocsDir);
- final File javadocJar = createArchive(ctx, apiRegion, ArtifactType.JAVADOC,
- this.apiJavadocResources, infos, null, report);
- report(ctx, javadocJar, ArtifactType.JAVADOC, regionSupport, apiRegion, ctx.getConfig().isUseApiDependenciesForJavadoc(), report, links);
-
- if ( ctx.getConfig().isUseApiDependencies() && ctx.getConfig().isGenerateJavadocForAllApi() ) {
+ final File javadocJar = createArchive(
+ ctx, apiRegion, ArtifactType.JAVADOC, this.apiJavadocResources, infos, null, report);
+ report(
+ ctx,
+ javadocJar,
+ ArtifactType.JAVADOC,
+ regionSupport,
+ apiRegion,
+ ctx.getConfig().isUseApiDependenciesForJavadoc(),
+ report,
+ links);
+
+ if (ctx.getConfig().isUseApiDependencies() && ctx.getConfig().isGenerateJavadocForAllApi()) {
final File javadocsAllDir = new File(regionDir, ArtifactType.JAVADOC_ALL.getId());
- final Collection<ArtifactInfo> infosForAll = generateJavadoc(ctx, regionName, links, javadocsAllDir, regionSupport, false);
+ final Collection<ArtifactInfo> infosForAll =
+ generateJavadoc(ctx, regionName, links, javadocsAllDir, regionSupport, false);
ctx.setJavadocDir(javadocsAllDir);
- final File javadocAllJar = createArchive(ctx, apiRegion, ArtifactType.JAVADOC_ALL,
- this.apiJavadocResources, infosForAll, null, report);
+ final File javadocAllJar = createArchive(
+ ctx,
+ apiRegion,
+ ArtifactType.JAVADOC_ALL,
+ this.apiJavadocResources,
+ infosForAll,
+ null,
+ report);
report(ctx, javadocAllJar, ArtifactType.JAVADOC, regionSupport, apiRegion, false, report, links);
}
}
@@ -612,15 +674,19 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
// write dependency report
final ArtifactId dependencyReportId = this.buildArtifactId(ctx, apiRegion, ArtifactType.DEPENDENCY_REPORT);
final File dependencyReportFile = new File(mainOutputDir, dependencyReportId.toMvnName());
- if ( this.useApiDependencies ) {
+ if (this.useApiDependencies) {
final List<String> output = new ArrayList<>();
- for(final ArtifactInfo info : ctx.getArtifactInfos(regionName, false)) {
- if ( !info.isUseAsDependencyPerRegion(regionName) && !"".equals(info.getNotUseAsDependencyPerRegionReason(regionName))) {
- output.add("- ".concat(info.getId().toMvnId()).concat(" : ").concat(info.getNotUseAsDependencyPerRegionReason(regionName)));
+ for (final ArtifactInfo info : ctx.getArtifactInfos(regionName, false)) {
+ if (!info.isUseAsDependencyPerRegion(regionName)
+ && !"".equals(info.getNotUseAsDependencyPerRegionReason(regionName))) {
+ output.add("- "
+ .concat(info.getId().toMvnId())
+ .concat(" : ")
+ .concat(info.getNotUseAsDependencyPerRegionReason(regionName)));
}
}
Collections.sort(output);
- if ( output.isEmpty() ) {
+ if (output.isEmpty()) {
output.add("All artifacts are used as a dependency");
} else {
output.add(0, "The following artifacts are not used as a dependency:");
@@ -631,8 +697,8 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
} catch (final IOException e) {
throw new MojoExecutionException("Unable to write " + dependencyReportFile, e);
}
- } else {
- if ( dependencyReportFile.exists() ) {
+ } else {
+ if (dependencyReportFile.exists()) {
dependencyReportFile.delete();
}
}
@@ -659,20 +725,25 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
throw new MojoExecutionException("API generation has errors, please see report files for more information");
}
- getLog().info(MessageUtils.buffer().a("APIs JARs for Feature ").project(feature.getId().toMvnId())
- .a(" succesfully created").toString());
+ getLog().info(MessageUtils.buffer()
+ .a("APIs JARs for Feature ")
+ .project(feature.getId().toMvnId())
+ .a(" succesfully created")
+ .toString());
}
- private void report(final ApisJarContext ctx,
+ private void report(
+ final ApisJarContext ctx,
final File jarFile,
final ArtifactType artifactType,
final RegionSupport regionSupport,
final ApiRegion apiRegion,
final boolean omitDependencyArtifacts,
final List<String> report,
- final JavadocLinks links) throws MojoExecutionException {
- final Map.Entry<Set<String>, Set<String>> packageResult = ApisUtil.getPackages(ctx, jarFile,
- artifactType.getContentExtension());
+ final JavadocLinks links)
+ throws MojoExecutionException {
+ final Map.Entry<Set<String>, Set<String>> packageResult =
+ ApisUtil.getPackages(ctx, jarFile, artifactType.getContentExtension());
final Set<String> apiPackages = packageResult.getKey();
final Set<String> otherPackages = packageResult.getValue();
if (omitDependencyArtifacts) {
@@ -696,7 +767,8 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
}
final List<ApiExport> missing = new ArrayList<>();
- for (final ApiExport exp : regionSupport.getAllExports(apiRegion, ctx.getConfig().getEnabledToggles())) {
+ for (final ApiExport exp :
+ regionSupport.getAllExports(apiRegion, ctx.getConfig().getEnabledToggles())) {
final String packageName = exp.getName();
if (!apiPackages.remove(packageName) && !otherPackages.remove(packageName)) {
missing.add(exp);
@@ -709,11 +781,11 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
if (artifactType == ArtifactType.JAVADOC && !omitDependencyArtifacts) {
otherPackages.removeAll(ctx.getPackagesWithoutSources());
// handle additional artifacts
- for(final Artifact artifact : ApisUtil.getAdditionalJavadocArtifacts(ctx, apiRegion.getName()) ) {
+ for (final Artifact artifact : ApisUtil.getAdditionalJavadocArtifacts(ctx, apiRegion.getName())) {
final ArtifactInfo info = ctx.getArtifactInfo(artifact.getId());
- if ( info != null ) {
- for(final Clause clause : info.getUsedExportedPackages(apiRegion.getName())) {
- if ( !apiPackages.remove(clause.getName()) ) {
+ if (info != null) {
+ for (final Clause clause : info.getUsedExportedPackages(apiRegion.getName())) {
+ if (!apiPackages.remove(clause.getName())) {
final ApiExport export = new ApiExport(clause.getName());
missing.add(export);
}
@@ -726,8 +798,14 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
apiPackages.addAll(otherPackages);
if (artifactType == ArtifactType.JAVADOC) {
// jquery and legal might be part of javadoc
- final Collection<String> jqueryPackages = Arrays.asList("jquery", "jquery.external.jquery", "jquery.images",
- "jquery.jszip-utils.dist", "jquery.jszip.dist", "resources", "legal");
+ final Collection<String> jqueryPackages = Arrays.asList(
+ "jquery",
+ "jquery.external.jquery",
+ "jquery.images",
+ "jquery.jszip-utils.dist",
+ "jquery.jszip.dist",
+ "resources",
+ "legal");
apiPackages.removeAll(jqueryPackages);
}
@@ -735,8 +813,13 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
getLog().info("Verified " + artifactType.getId() + " jar for region " + apiRegion.getName());
} else {
Collections.sort(missing);
- report.add(artifactType.getId().concat(" jar for region ").concat(apiRegion.getName()).concat(" has ")
- .concat(String.valueOf(missing.size() + apiPackages.size())).concat(" errors:"));
+ report.add(artifactType
+ .getId()
+ .concat(" jar for region ")
+ .concat(apiRegion.getName())
+ .concat(" has ")
+ .concat(String.valueOf(missing.size() + apiPackages.size()))
+ .concat(" errors:"));
for (final ApiExport exp : missing) {
final List<String> candidates = new ArrayList<>();
for (final ArtifactInfo info : ctx.getArtifactInfos()) {
@@ -747,7 +830,9 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
}
}
}
- report.add("- Missing package ".concat(exp.getName()).concat(" from bundle(s) ")
+ report.add("- Missing package "
+ .concat(exp.getName())
+ .concat(" from bundle(s) ")
.concat(String.join(",", candidates)));
}
for (final String m : apiPackages) {
@@ -756,8 +841,7 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
}
}
- private File getArtifactFile(final ArtifactId artifactId)
- throws MojoExecutionException {
+ private File getArtifactFile(final ArtifactId artifactId) throws MojoExecutionException {
final URL artifactURL = retrieve(artifactId);
if (artifactURL == null) {
throw new MojoExecutionException("Unable to find artifact " + artifactId.toMvnId());
@@ -779,10 +863,9 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
* @param artifact The artifact
* @throws MojoExecutionException
*/
- private void onArtifact(final ApiRegions apiRegions,
- final ApisJarContext ctx,
- final RegionSupport regionSupport,
- Artifact artifact) throws MojoExecutionException {
+ private void onArtifact(
+ final ApiRegions apiRegions, final ApisJarContext ctx, final RegionSupport regionSupport, Artifact artifact)
+ throws MojoExecutionException {
File bundleFile = getArtifactFile(artifact.getId());
Manifest manifest = regionSupport.getManifest(artifact.getId(), bundleFile);
@@ -792,7 +875,8 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
if (exportedPackageClauses.length > 0) {
// calculate the exported packages in the manifest file for all regions
- final Set<String> usedExportedPackages = regionSupport.computeAllUsedExportPackages(apiRegions, ctx.getConfig().getEnabledToggles(), exportedPackageClauses, artifact);
+ final Set<String> usedExportedPackages = regionSupport.computeAllUsedExportPackages(
+ apiRegions, ctx.getConfig().getEnabledToggles(), exportedPackageClauses, artifact);
boolean isArtifactFullyExported = usedExportedPackages.size() == exportedPackageClauses.length;
if (!usedExportedPackages.isEmpty()) {
@@ -809,7 +893,8 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
throw new MojoExecutionException(
"More than one previous version artifact configured for "
+ artifact.getId().toMvnId() + " : " + previous.toMvnId() + ", "
- + exp.getPreviousArtifactId().toMvnId());
+ + exp.getPreviousArtifactId()
+ .toMvnId());
}
previous = exp.getPreviousArtifactId();
}
@@ -820,8 +905,8 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
if (previous != null) {
final Artifact previousArtifact = new Artifact(previous);
previousArtifact.getMetadata().putAll(artifact.getMetadata());
- getLog().debug("Using " + previous.toMvnId() + " instead of " + artifact.getId().toMvnId()
- + " due to disabled toggle(s)");
+ getLog().debug("Using " + previous.toMvnId() + " instead of "
+ + artifact.getId().toMvnId() + " due to disabled toggle(s)");
artifact = previousArtifact;
bundleFile = getArtifactFile(artifact.getId());
manifest = regionSupport.getManifest(artifact.getId(), bundleFile);
@@ -833,21 +918,22 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
// calculate per region packages
for (final ApiRegion region : apiRegions.listRegions()) {
- final Set<Clause> usedExportedPackagesPerRegion = regionSupport.computeUsedExportPackagesPerRegion(region,
- exportedPackageClauses, usedExportedPackages);
+ final Set<Clause> usedExportedPackagesPerRegion = regionSupport.computeUsedExportPackagesPerRegion(
+ region, exportedPackageClauses, usedExportedPackages);
// check whether packages are included in api jars - or added as a dependency
String useAsDependency = "";
- if ( ctx.getConfig().isUseApiDependencies() ) {
- useAsDependency = regionSupport.calculateOmitDependenciesFlag(region, exportedPackageClauses,
- usedExportedPackagesPerRegion);
+ if (ctx.getConfig().isUseApiDependencies()) {
+ useAsDependency = regionSupport.calculateOmitDependenciesFlag(
+ region, exportedPackageClauses, usedExportedPackagesPerRegion);
}
- if (useAsDependency == null ) {
+ if (useAsDependency == null) {
if (ctx.findDependencyArtifact(getLog(), info)) {
// check scm info
if (artifact.getMetadata().get(ApisUtil.SCM_LOCATION) != null) {
- throw new MojoExecutionException("Dependency artifact must not specify "
- + ApisUtil.SCM_LOCATION + " : " + artifact.getId().toMvnId());
+ throw new MojoExecutionException(
+ "Dependency artifact must not specify " + ApisUtil.SCM_LOCATION + " : "
+ + artifact.getId().toMvnId());
}
} else {
useAsDependency = "Unable to find artifact in maven repository.";
@@ -855,16 +941,20 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
}
info.setUsedExportedPackages(region.getName(), usedExportedPackagesPerRegion, useAsDependency);
if (!isArtifactFullyExported) {
- final Set<Clause> providedCapabilitiesPerRegion = computeProvidedCapabilities(region, getProvidedCapability(manifest), artifact);
+ final Set<Clause> providedCapabilitiesPerRegion =
+ computeProvidedCapabilities(region, getProvidedCapability(manifest), artifact);
info.setProvidedCapabilities(region.getName(), providedCapabilitiesPerRegion);
} else {
- // in case there are no region restrictions just include all capabilities
- info.setProvidedCapabilities(region.getName(), new LinkedHashSet<>(Arrays.asList(getProvidedCapability(manifest))));
+ // in case there are no region restrictions just include all capabilities
+ info.setProvidedCapabilities(
+ region.getName(), new LinkedHashSet<>(Arrays.asList(getProvidedCapability(manifest))));
}
}
- info.setBinDirectory(new File(ctx.getDeflatedBinDir(), info.getId().toMvnName()));
- info.setSourceDirectory(new File(ctx.getDeflatedSourcesDir(), info.getId().toMvnName()));
+ info.setBinDirectory(
+ new File(ctx.getDeflatedBinDir(), info.getId().toMvnName()));
+ info.setSourceDirectory(
+ new File(ctx.getDeflatedSourcesDir(), info.getId().toMvnName()));
final boolean skipBinDeflate = info.getBinDirectory().exists();
if (skipBinDeflate) {
@@ -930,8 +1020,13 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
final Set<String> foundPackages = new HashSet<>();
if (info.getSourceDirectory() != null && info.getSourceDirectory().exists()) {
final String encoding = artifact.getMetadata().getOrDefault(ApisUtil.SCM_ENCODING, "UTF-8");
- this.postProcessSourcesDirectory(ctx, info, foundPackages, info.getSourceDirectory(),
- "UTF-8".equals(encoding) ? null : encoding, "");
+ this.postProcessSourcesDirectory(
+ ctx,
+ info,
+ foundPackages,
+ info.getSourceDirectory(),
+ "UTF-8".equals(encoding) ? null : encoding,
+ "");
}
// check for missing packages
for (final String pck : info.getUsedExportedPackages()) {
@@ -944,15 +1039,17 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
}
}
}
-
}
- private void postProcessBinDirectory(final ApisJarContext ctx, final ArtifactInfo info, final File dir,
- final String pck) {
+ private void postProcessBinDirectory(
+ final ApisJarContext ctx, final ArtifactInfo info, final File dir, final String pck) {
boolean hasJavaFile = false;
for (final File child : dir.listFiles()) {
if (child.isDirectory()) {
- postProcessBinDirectory(ctx, info, child,
+ postProcessBinDirectory(
+ ctx,
+ info,
+ child,
pck.isEmpty() ? child.getName() : pck.concat(".").concat(child.getName()));
} else if (child.getName().endsWith(ArtifactType.APIS.getContentExtension())) {
hasJavaFile = true;
@@ -984,9 +1081,15 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
* @param skipSourceDeflate Flag to skip deflating the source
* @throws MojoExecutionException
*/
- private void processBinary(final ApisJarContext ctx, final ArtifactInfo info, final File binFile,
- final Artifact binArtifact, final String[] embeddedBundles, final boolean skipBinDeflate,
- final boolean skipSourceDeflate) throws MojoExecutionException {
+ private void processBinary(
+ final ApisJarContext ctx,
+ final ArtifactInfo info,
+ final File binFile,
+ final Artifact binArtifact,
+ final String[] embeddedBundles,
+ final boolean skipBinDeflate,
+ final boolean skipSourceDeflate)
+ throws MojoExecutionException {
if (!skipBinDeflate) {
// deflate all bundles first, in order to copy APIs and resources later,
// depending to the region
@@ -1007,7 +1110,6 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
// deflate
this.deflate(info.getBinDirectory(), binFile, deflateIncludes.toArray(new String[deflateIncludes.size()]));
-
}
// renaming potential name-collapsing resources
this.renameResources(ctx, info, binArtifact.getId());
@@ -1020,7 +1122,6 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
info.addSourceInfo("USE CACHE FROM PREVIOUS BUILD");
}
}
-
}
private List<String> getIncludeResourcePatterns(final ApisJarContext ctx, final ArtifactId id) {
@@ -1043,13 +1144,23 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
return pattern;
}
- private void postProcessSourcesDirectory(final ApisJarContext ctx, final ArtifactInfo info,
- final Set<String> foundPackages, final File dir, final String readEncoding, final String pck)
+ private void postProcessSourcesDirectory(
+ final ApisJarContext ctx,
+ final ArtifactInfo info,
+ final Set<String> foundPackages,
+ final File dir,
+ final String readEncoding,
+ final String pck)
throws MojoExecutionException {
boolean hasSourceFile = false;
for (final File child : dir.listFiles()) {
if (child.isDirectory()) {
- postProcessSourcesDirectory(ctx, info, foundPackages, child, readEncoding,
+ postProcessSourcesDirectory(
+ ctx,
+ info,
+ foundPackages,
+ child,
+ readEncoding,
pck.isEmpty() ? child.getName() : pck.concat(".").concat(child.getName()));
} else if (child.getName().endsWith(ArtifactType.SOURCES.getContentExtension())) {
hasSourceFile = true;
@@ -1071,8 +1182,12 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
}
}
- private void computeWrappedBundles(final ApisJarContext ctx, final ArtifactInfo info,
- final String[] embeddedBundles, final boolean skipBinDeflate, final boolean skipSourceDeflate)
+ private void computeWrappedBundles(
+ final ApisJarContext ctx,
+ final ArtifactInfo info,
+ final String[] embeddedBundles,
+ final boolean skipBinDeflate,
+ final boolean skipSourceDeflate)
throws MojoExecutionException {
for (final String jarName : embeddedBundles) {
if (".".equals(jarName)) {
@@ -1087,7 +1202,8 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
try (final JarInputStream jis = new JarInputStream(new FileInputStream(wrappedJar))) {
JarEntry jarEntry = null;
while ((jarEntry = jis.getNextJarEntry()) != null) {
- if (!jarEntry.isDirectory() && pomPropertiesPattern.matcher(jarEntry.getName()).matches()) {
+ if (!jarEntry.isDirectory()
+ && pomPropertiesPattern.matcher(jarEntry.getName()).matches()) {
getLog().debug("Loading Maven GAV from " + wrappedJar + '!' + jarEntry.getName());
properties.load(jis);
break;
@@ -1111,8 +1227,8 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
classifier = inferClassifier(jarName, artifactId, version);
}
- Artifact syntheticArtifact = new Artifact(
- new ArtifactId(groupId, artifactId, version, classifier, null));
+ Artifact syntheticArtifact =
+ new Artifact(new ArtifactId(groupId, artifactId, version, classifier, null));
final File bundleFile = getArtifactFile(syntheticArtifact.getId());
processBinary(ctx, info, bundleFile, syntheticArtifact, null, skipBinDeflate, skipSourceDeflate);
@@ -1122,16 +1238,13 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
// Guess the classifier based on the file name
String inferClassifier(String bundleName, String artifactId, String version) {
- if (bundleName == null || artifactId == null || version == null)
- return null;
+ if (bundleName == null || artifactId == null || version == null) return null;
int idx = bundleName.lastIndexOf('/');
- if (idx >= 0)
- bundleName = bundleName.substring(idx + 1);
+ if (idx >= 0) bundleName = bundleName.substring(idx + 1);
int edx = bundleName.lastIndexOf('.');
- if (edx > 0)
- bundleName = bundleName.substring(0, edx);
+ if (edx > 0) bundleName = bundleName.substring(0, edx);
// bundleName is now the bare name without extension
String synthesized = artifactId + "-" + version;
@@ -1139,8 +1252,8 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
String suffix = bundleName.substring(synthesized.length());
if (suffix.length() > 1 && suffix.startsWith("-")) {
String classifier = suffix.substring(1);
- getLog().debug(
- "Inferred classifier of '" + artifactId + ":" + version + "' to be '" + classifier + "'");
+ getLog().debug("Inferred classifier of '" + artifactId + ":" + version + "' to be '" + classifier
+ + "'");
return classifier;
}
}
@@ -1168,7 +1281,7 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
unArchiver.setDestDirectory(destDirectory);
final IncludeExcludeFileSelector selector = new IncludeExcludeFileSelector();
selector.setIncludes(includes);
- unArchiver.setFileSelectors(new FileSelector[] { selector });
+ unArchiver.setFileSelectors(new FileSelector[] {selector});
unArchiver.setOverwrite(false);
unArchiver.extract();
} catch (final NoSuchArchiverException e) {
@@ -1236,8 +1349,12 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
getLog().debug(patterns + " resources in " + info.getBinDirectory() + " successfully renamed");
}
- private boolean downloadSourceAndDeflate(final ApisJarContext ctx, final ArtifactInfo info,
- final ArtifactId sourcesArtifactId, final boolean allowFallback) throws MojoExecutionException {
+ private boolean downloadSourceAndDeflate(
+ final ApisJarContext ctx,
+ final ArtifactInfo info,
+ final ArtifactId sourcesArtifactId,
+ final boolean allowFallback)
+ throws MojoExecutionException {
boolean failed = false;
try {
final URL url = retrieve(sourcesArtifactId);
@@ -1246,8 +1363,8 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
deflate(info.getSourceDirectory(), sourcesBundle, info.getUsedExportedPackageIncludes());
} else {
if (!allowFallback) {
- throw new MojoExecutionException("Unable to download sources for " + info.getId().toMvnId()
- + " due to missing artifact " + sourcesArtifactId.toMvnId());
+ throw new MojoExecutionException("Unable to download sources for "
+ + info.getId().toMvnId() + " due to missing artifact " + sourcesArtifactId.toMvnId());
}
getLog().warn("Unable to download sources for " + info.getId().toMvnId() + " due to missing artifact "
+ sourcesArtifactId.toMvnId() + ", trying source checkout next...");
@@ -1257,8 +1374,8 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
throw mee;
} catch (final Throwable t) {
if (!allowFallback) {
- throw new MojoExecutionException("Unable to download sources for " + info.getId().toMvnId()
- + " due to missing artifact " + sourcesArtifactId.toMvnId());
+ throw new MojoExecutionException("Unable to download sources for "
+ + info.getId().toMvnId() + " due to missing artifact " + sourcesArtifactId.toMvnId());
}
getLog().warn("Unable to download sources for " + info.getId().toMvnId() + " from "
+ sourcesArtifactId.toMvnId() + " due to " + t.getMessage() + ", trying source checkout next...");
@@ -1288,9 +1405,10 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
if (sourceClassifier == null) {
sourceClassifier = "sources"; // default
}
- final ArtifactId sourcesArtifactId = artifact.getId().changeClassifier(sourceClassifier).changeType("jar");
- if (downloadSourceAndDeflate(ctx, info, sourcesArtifactId,
- artifact.getMetadata().get(ApisUtil.SCM_CLASSIFIER) == null)) {
+ final ArtifactId sourcesArtifactId =
+ artifact.getId().changeClassifier(sourceClassifier).changeType("jar");
+ if (downloadSourceAndDeflate(
+ ctx, info, sourcesArtifactId, artifact.getMetadata().get(ApisUtil.SCM_CLASSIFIER) == null)) {
final String connection = checkoutSourcesFromSCM(ctx, info, artifact);
info.addSourceInfo(connection);
} else {
@@ -1320,7 +1438,9 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
getLog().debug("POM " + pomArtifactId.toMvnId() + " successfully retrieved, reading the model...");
// read model
- model = modelBuilder.buildRawModel(pomFile, ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL, false).get();
+ model = modelBuilder
+ .buildRawModel(pomFile, ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL, false)
+ .get();
getLog().debug("POM model " + pomArtifactId.toMvnId() + " successfully read");
// cache model
@@ -1329,8 +1449,9 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
return model;
}
- private String checkoutSourcesFromSCM(final ApisJarContext ctx, final ArtifactInfo info,
- final Artifact sourceArtifact) throws MojoExecutionException {
+ private String checkoutSourcesFromSCM(
+ final ApisJarContext ctx, final ArtifactInfo info, final Artifact sourceArtifact)
+ throws MojoExecutionException {
// fallback to Artifacts SCM metadata first
String connection = sourceArtifact.getMetadata().get(ApisUtil.SCM_LOCATION);
String tag = sourceArtifact.getMetadata().get(ApisUtil.SCM_TAG);
@@ -1349,14 +1470,15 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
if (tag == null) {
tag = scm.getTag();
// Maven uses "HEAD" as default value
- if ( "HEAD".equals(tag) ) {
+ if ("HEAD".equals(tag)) {
tag = null;
}
}
}
if (connection == null) {
- getLog().warn("Ignoring sources for artifact " + sourceArtifact.getId().toMvnId() + " : SCM not defined in "
+ getLog().warn("Ignoring sources for artifact "
+ + sourceArtifact.getId().toMvnId() + " : SCM not defined in "
+ sourceArtifact.getId().toMvnId() + " bundle neither in " + pomModel.getId() + " POM file.");
return null;
}
@@ -1369,7 +1491,8 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
scmVersion = new ScmTag(tag);
}
- File basedir = new File(ctx.getCheckedOutSourcesDir(), sourceArtifact.getId().toMvnName());
+ File basedir = new File(
+ ctx.getCheckedOutSourcesDir(), sourceArtifact.getId().toMvnName());
if (basedir.exists()) {
getLog().debug("Source checkout directory " + basedir + " already exists");
} else {
@@ -1385,12 +1508,15 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
result = scmManager.checkOut(repository, fileSet, scmVersion, true);
}
} catch (ScmException se) {
- throw new MojoExecutionException("An error occurred while checking sources from " + repository
- + " for artifact " + sourceArtifact.getId().toMvnId() + " model", se);
+ throw new MojoExecutionException(
+ "An error occurred while checking sources from " + repository + " for artifact "
+ + sourceArtifact.getId().toMvnId() + " model",
+ se);
}
if (!result.isSuccess()) {
- getLog().warn("Ignoring sources for artifact " + sourceArtifact.getId().toMvnId()
+ getLog().warn("Ignoring sources for artifact "
+ + sourceArtifact.getId().toMvnId()
+ " : An error occurred while checking out sources from " + connection + ": "
+ result.getProviderMessage());
return null;
@@ -1405,7 +1531,8 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
for (String pomFileLocation : pomScanner.getIncludedFiles()) {
final File pomFile = new File(basedir, pomFileLocation);
final Model model = modelBuilder
- .buildRawModel(pomFile, ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL, false).get();
+ .buildRawModel(pomFile, ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL, false)
+ .get();
if (sourceArtifact.getId().getArtifactId().equals(model.getArtifactId())) {
basedir = pomFile.getParentFile();
@@ -1420,14 +1547,15 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
// there could be just resources artifacts
if (!javaSources.exists()) {
- getLog().warn(
- "Ignoring sources for artifact " + sourceArtifact.getId().toMvnId() + " : SCM checkout for "
- + sourceArtifact.getId().toMvnId() + " does not contain any source.");
+ getLog().warn("Ignoring sources for artifact "
+ + sourceArtifact.getId().toMvnId() + " : SCM checkout for "
+ + sourceArtifact.getId().toMvnId() + " does not contain any source.");
return null;
}
}
- final File sourceDirectory = new File(ctx.getDeflatedSourcesDir(), info.getId().toMvnName());
+ final File sourceDirectory =
+ new File(ctx.getDeflatedSourcesDir(), info.getId().toMvnName());
info.setSourceDirectory(sourceDirectory);
sourceDirectory.mkdir();
@@ -1450,12 +1578,17 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
return tag == null ? connection : connection.concat("@").concat(tag);
} catch (ScmRepositoryException se) {
- throw new MojoExecutionException("An error occurred while reading SCM from " + connection
- + " connection for bundle " + sourceArtifact.getId(), se);
+ throw new MojoExecutionException(
+ "An error occurred while reading SCM from " + connection + " connection for bundle "
+ + sourceArtifact.getId(),
+ se);
} catch (NoSuchScmProviderException nsspe) {
- getLog().warn("Ignoring sources for artifact " + sourceArtifact.getId().toMvnId()
- + " : bundle points to an SCM connection " + connection
- + " which does not specify a valid or supported SCM provider", nsspe);
+ getLog().warn(
+ "Ignoring sources for artifact "
+ + sourceArtifact.getId().toMvnId()
+ + " : bundle points to an SCM connection " + connection
+ + " which does not specify a valid or supported SCM provider",
+ nsspe);
return null;
}
}
@@ -1467,43 +1600,54 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
return providedCapabilities;
}
- /**
- * Compute provided capabilities for a single region
- *
- * @return List of packages exported by this bundle and used in the region
- */
- private Set<Clause> computeProvidedCapabilities(final ApiRegion apiRegion, final Clause[] providedCapabilities,
- final Artifact bundle) {
- final Set<Clause> result = new LinkedHashSet<>();
-
- for (final Clause providedCapability : providedCapabilities) {
- // only consider "osgi.service" capabilities per region (https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.namespaces.html#service.namespaces-osgi.service.namespace)
- // because those can be mapped to Java packages
- if (ServiceNamespace.SERVICE_NAMESPACE.equals(providedCapability.getName())) {
- String serviceObjectClasses = providedCapability.getAttribute(ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE+":List<String>");
- if (serviceObjectClasses == null) {
- serviceObjectClasses = providedCapability.getAttribute(ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE);
- if (serviceObjectClasses == null) {
- throw new IllegalArgumentException("Could not find mandatory attribute '" + ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE + "' in clause '" + providedCapability + "' of bundle " + bundle.getId());
- }
- }
- if (areServiceObjectClassesContainedInRegion(apiRegion, serviceObjectClasses, bundle)) {
- result.add(providedCapability);
- } else {
- getLog().debug("Skip capability " + providedCapability.getName() + " for region " + apiRegion.getName() + " as related service object does not belong to this region!");
- }
- } else {
- getLog().debug("Skip capability " + providedCapability.getName() + " for region " + apiRegion.getName() + " as relation to region could only be automatically established for package related capabilities!");
- }
- }
- return result;
+ /**
+ * Compute provided capabilities for a single region
+ *
+ * @return List of packages exported by this bundle and used in the region
+ */
+ private Set<Clause> computeProvidedCapabilities(
+ final ApiRegion apiRegion, final Clause[] providedCapabilities, final Artifact bundle) {
+ final Set<Clause> result = new LinkedHashSet<>();
+
+ for (final Clause providedCapability : providedCapabilities) {
+ // only consider "osgi.service" capabilities per region
+ // (https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.namespaces.html#service.namespaces-osgi.service.namespace)
+ // because those can be mapped to Java packages
+ if (ServiceNamespace.SERVICE_NAMESPACE.equals(providedCapability.getName())) {
+ String serviceObjectClasses = providedCapability.getAttribute(
+ ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE + ":List<String>");
+ if (serviceObjectClasses == null) {
+ serviceObjectClasses =
+ providedCapability.getAttribute(ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE);
+ if (serviceObjectClasses == null) {
+ throw new IllegalArgumentException("Could not find mandatory attribute '"
+ + ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE + "' in clause '"
+ + providedCapability + "' of bundle " + bundle.getId());
+ }
+ }
+ if (areServiceObjectClassesContainedInRegion(apiRegion, serviceObjectClasses, bundle)) {
+ result.add(providedCapability);
+ } else {
+ getLog().debug("Skip capability " + providedCapability.getName() + " for region "
+ + apiRegion.getName() + " as related service object does not belong to this region!");
+ }
+ } else {
+ getLog().debug(
+ "Skip capability " + providedCapability.getName() + " for region " + apiRegion.getName()
+ + " as relation to region could only be automatically established for package related capabilities!");
+ }
+ }
+ return result;
}
- private boolean areServiceObjectClassesContainedInRegion(final ApiRegion apiRegion, String serviceObjectClasses, final Artifact bundle) {
- // this is a comma separated list (https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.namespaces.html#service.namespaces-osgi.service.namespace)
+ private boolean areServiceObjectClassesContainedInRegion(
+ final ApiRegion apiRegion, String serviceObjectClasses, final Artifact bundle) {
+ // this is a comma separated list
+ // (https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.namespaces.html#service.namespaces-osgi.service.namespace)
for (String serviceObjectClass : serviceObjectClasses.split(",")) {
String relevantPackage = serviceObjectClass.substring(0, serviceObjectClass.lastIndexOf("."));
- if (apiRegion.getExportByName(relevantPackage) == null || ApisUtil.getIgnoredPackages(bundle).contains(relevantPackage)) {
+ if (apiRegion.getExportByName(relevantPackage) == null
+ || ApisUtil.getIgnoredPackages(bundle).contains(relevantPackage)) {
return false;
}
}
@@ -1541,12 +1685,13 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
}
return sb.toString();
}
-
- private void addFileSets(final ApiRegion apiRegion,
- final ArtifactType archiveType,
- final Collection<ArtifactInfo> infos,
- final JarArchiver jarArchiver,
- final List<Source> sources) {
+
+ private void addFileSets(
+ final ApiRegion apiRegion,
+ final ArtifactType archiveType,
+ final Collection<ArtifactInfo> infos,
+ final JarArchiver jarArchiver,
+ final List<Source> sources) {
for (final ArtifactInfo info : infos) {
final File dir = archiveType == ArtifactType.APIS ? info.getBinDirectory() : info.getSourceDirectory();
@@ -1558,32 +1703,33 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
fileSet.setIncludingEmptyDirectories(false);
fileSet.setIncludes(usedExportedPackageIncludes);
- if ( jarArchiver != null ) {
+ if (jarArchiver != null) {
jarArchiver.addFileSet(fileSet);
}
- if ( sources != null ) {
+ if (sources != null) {
sources.add(new DirectorySource(fileSet));
}
}
}
}
- private void addResources(final Collection<ArtifactInfo> infos,
- final List<File> resources,
- final JarArchiver jarArchiver,
- final List<Source> sources) {
+ private void addResources(
+ final Collection<ArtifactInfo> infos,
+ final List<File> resources,
+ final JarArchiver jarArchiver,
+ final List<Source> sources) {
for (final ArtifactInfo info : infos) {
- if ( info.getBinDirectory() != null ) {
- final int prefixLength = info.getBinDirectory().getAbsolutePath().length() + 1;
+ if (info.getBinDirectory() != null) {
+ final int prefixLength =
+ info.getBinDirectory().getAbsolutePath().length() + 1;
for (final File resource : info.getIncludedResources()) {
final String name = resource.getAbsolutePath().substring(prefixLength);
getLog().debug("Adding resource " + name);
- if ( jarArchiver != null ) {
+ if (jarArchiver != null) {
jarArchiver.addFile(resource, name);
-
}
- if ( sources != null ) {
+ if (sources != null) {
sources.add(new FileSource(info.getBinDirectory(), resource));
}
}
@@ -1600,7 +1746,7 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
ds.setIncludes("**/*.*");
ds.scan();
- if ( jarArchiver != null ) {
+ if (jarArchiver != null) {
for (String includedFile : ds.getIncludedFiles()) {
jarArchiver.addFile(new File(rsrc, includedFile), includedFile);
}
@@ -1608,11 +1754,11 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
if (sources != null) {
final DefaultFileSet fileSet = new DefaultFileSet(rsrc);
fileSet.setIncludingEmptyDirectories(false);
- fileSet.setIncludes(new String[] { "**/*.*" });
+ fileSet.setIncludes(new String[] {"**/*.*"});
sources.add(new DirectorySource(fileSet));
}
} else {
- if ( jarArchiver != null ) {
+ if (jarArchiver != null) {
jarArchiver.addFile(rsrc, rsrc.getName());
}
if (sources != null) {
@@ -1623,14 +1769,15 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
}
}
- private void runProcessor(final ApisJarContext ctx,
- final ApiRegion apiRegion,
- final ArtifactType archiveType,
- final List<File> resources,
- final List<Map.Entry<String, File>> additionalResources,
- final Collection<ArtifactInfo> infos) {
+ private void runProcessor(
+ final ApisJarContext ctx,
+ final ApiRegion apiRegion,
+ final ArtifactType archiveType,
+ final List<File> resources,
+ final List<Map.Entry<String, File>> additionalResources,
+ final Collection<ArtifactInfo> infos) {
final List<Processor> processors = ApisUtil.getProcessors(this.includeProviderTypeResource);
- if ( !processors.isEmpty() ) {
+ if (!processors.isEmpty()) {
final List<Source> sources = new ArrayList<>();
this.addFileSets(apiRegion, archiveType, infos, null, sources);
@@ -1664,7 +1811,7 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
public Log getLog() {
return ApisJarMojo.this.getLog();
}
-
+
@Override
public File getOutputDirectory() {
return mainOutputDir;
@@ -1673,9 +1820,9 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
@Override
public void addResource(final String name, final File file) {
additionalResources.add(new AbstractMap.SimpleImmutableEntry<>(name, file));
- }
+ }
};
- if ( archiveType == ArtifactType.APIS ) {
+ if (archiveType == ArtifactType.APIS) {
getLog().info("Running processor " + p.getName() + " on binaries...");
p.processBinaries(pc, sources);
} else {
@@ -1686,8 +1833,12 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
}
}
- private File createArchive(final ApisJarContext ctx, final ApiRegion apiRegion, final ArtifactType archiveType,
- final List<File> resources, final Collection<ArtifactInfo> infos,
+ private File createArchive(
+ final ApisJarContext ctx,
+ final ApiRegion apiRegion,
+ final ArtifactType archiveType,
+ final List<File> resources,
+ final Collection<ArtifactInfo> infos,
final List<Map.Entry<String, File>> additionalResources,
final List<String> report)
throws MojoExecutionException {
@@ -1705,21 +1856,22 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
// add included resources
this.addResources(infos, resources, jarArchiver, null);
if (additionalResources != null) {
- for(final Map.Entry<String, File> s : additionalResources) {
+ for (final Map.Entry<String, File> s : additionalResources) {
getLog().debug("Adding resource " + s.getKey());
jarArchiver.addFile(s.getValue(), s.getKey());
}
}
// check for license report
- if ( ctx.getConfig().getLicenseReport() != null ) {
+ if (ctx.getConfig().getLicenseReport() != null) {
final File out = this.createLicenseReport(ctx, apiRegion, infos, report);
jarArchiver.addFile(out, ctx.getConfig().getLicenseReport());
}
final ArtifactId targetId = this.buildArtifactId(ctx, apiRegion, archiveType);
- final String artifactName = ctx.getConfig().getApiName() != null ? ctx.getConfig().getApiName() :
- String.format("%s-%s", targetId.getArtifactId(), targetId.getClassifier());
+ final String artifactName = ctx.getConfig().getApiName() != null
+ ? ctx.getConfig().getApiName()
+ : String.format("%s-%s", targetId.getArtifactId(), targetId.getClassifier());
MavenArchiveConfiguration archiveConfiguration = new MavenArchiveConfiguration();
archiveConfiguration.setAddMavenDescriptor(false);
@@ -1728,25 +1880,30 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
String symbolicName = artifactName.replace('-', '.');
archiveConfiguration.addManifestEntry("Export-Package", getApiExportClauses(apiRegion, infos));
archiveConfiguration.addManifestEntry("Bundle-Description", project.getDescription());
- archiveConfiguration.addManifestEntry("Bundle-Version", targetId.getOSGiVersion().toString());
+ archiveConfiguration.addManifestEntry(
+ "Bundle-Version", targetId.getOSGiVersion().toString());
archiveConfiguration.addManifestEntry("Bundle-ManifestVersion", "2");
archiveConfiguration.addManifestEntry("Bundle-SymbolicName", symbolicName);
archiveConfiguration.addManifestEntry("Bundle-Name", artifactName);
final Set<String> nodeTypes = new HashSet<>();
- for(final ArtifactInfo info : infos) {
- nodeTypes.addAll(info.getNodeTypes());
+ for (final ArtifactInfo info : infos) {
+ nodeTypes.addAll(info.getNodeTypes());
}
if (!nodeTypes.isEmpty()) {
archiveConfiguration.addManifestEntry("Sling-Nodetypes", String.join(",", nodeTypes));
}
if (project.getOrganization() != null) {
- archiveConfiguration.addManifestEntry("Bundle-Vendor", project.getOrganization().getName());
+ archiveConfiguration.addManifestEntry(
+ "Bundle-Vendor", project.getOrganization().getName());
}
// add provide capability headers to make dependent bundle resolvable with the apis-jar
- archiveConfiguration.addManifestEntry(Constants.PROVIDE_CAPABILITY, getApiProvideCapabilityClauses(apiRegion.getName(), infos));
- archiveConfiguration.addManifestEntry("Require-Capability", "osgi.unresolvable;filter:=\"(&(must.not.resolve=*)(!(must.not.resolve=*)))\",osgi.ee;filter:=\"(&(osgi.ee=JavaSE/compact2)(version=1.8))\"");
+ archiveConfiguration.addManifestEntry(
+ Constants.PROVIDE_CAPABILITY, getApiProvideCapabilityClauses(apiRegion.getName(), infos));
+ archiveConfiguration.addManifestEntry(
+ "Require-Capability",
+ "osgi.unresolvable;filter:=\"(&(must.not.resolve=*)(!(must.not.resolve=*)))\",osgi.ee;filter:=\"(&(osgi.ee=JavaSE/compact2)(version=1.8))\"");
}
archiveConfiguration.addManifestEntry("Implementation-Version", targetId.getVersion());
archiveConfiguration.addManifestEntry("Specification-Version", targetId.getVersion());
@@ -1754,8 +1911,10 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
archiveConfiguration.addManifestEntry("Implementation-Title", artifactName);
archiveConfiguration.addManifestEntry("Specification-Title", artifactName);
if (project.getOrganization() != null) {
- archiveConfiguration.addManifestEntry("Implementation-Vendor", project.getOrganization().getName());
- archiveConfiguration.addManifestEntry("Specification-Vendor", project.getOrganization().getName());
+ archiveConfiguration.addManifestEntry(
+ "Implementation-Vendor", project.getOrganization().getName());
+ archiveConfiguration.addManifestEntry(
+ "Specification-Vendor", project.getOrganization().getName());
}
// replace/add manifest entries with the one provided in manifestProperties configuration
@@ -1771,26 +1930,28 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
projectHelper.attachArtifact(project, targetId.getType(), targetId.getClassifier(), target);
}
} catch (Exception e) {
- throw new MojoExecutionException("An error occurred while creating APIs "
- + target
- +" archive", e);
+ throw new MojoExecutionException("An error occurred while creating APIs " + target + " archive", e);
}
return target;
}
- private ArtifactId buildArtifactId(final ApisJarContext ctx, final ApiRegion apiRegion, final ArtifactType artifactType) {
+ private ArtifactId buildArtifactId(
+ final ApisJarContext ctx, final ApiRegion apiRegion, final ArtifactType artifactType) {
final StringBuilder classifierBuilder = new StringBuilder();
if (ctx.getFeatureId().getClassifier() != null) {
- classifierBuilder.append(ctx.getConfig().mapApiClassifier(ctx.getFeatureId().getClassifier()))
- .append('-');
- }
- final String finalClassifier = classifierBuilder.append(ctx.getConfig().mapApiRegionName(apiRegion.getName()))
- .append('-')
- .append(artifactType.getId())
- .toString();
-
- return new ArtifactId(this.project.getGroupId(),
+ classifierBuilder
+ .append(ctx.getConfig().mapApiClassifier(ctx.getFeatureId().getClassifier()))
+ .append('-');
+ }
+ final String finalClassifier = classifierBuilder
+ .append(ctx.getConfig().mapApiRegionName(apiRegion.getName()))
+ .append('-')
+ .append(artifactType.getId())
+ .toString();
+
+ return new ArtifactId(
+ this.project.getGroupId(),
this.project.getArtifactId(),
ctx.getConfig().getApiVersion() != null ? ctx.getConfig().getApiVersion() : this.project.getVersion(),
finalClassifier,
@@ -1802,13 +1963,14 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
* @param ctx The context
* @param apiRegion The region
*/
- private void createDependenciesFile(final ApisJarContext ctx, final ApiRegion apiRegion) throws MojoExecutionException {
+ private void createDependenciesFile(final ApisJarContext ctx, final ApiRegion apiRegion)
+ throws MojoExecutionException {
final Collection<ArtifactInfo> infos = ctx.getArtifactInfos(apiRegion.getName(), false);
final List<ArtifactId> dependencies = new ArrayList<>();
- for(final ArtifactInfo info : infos) {
- if ( info.isUseAsDependencyPerRegion(apiRegion.getName()) ) {
+ for (final ArtifactInfo info : infos) {
+ if (info.isUseAsDependencyPerRegion(apiRegion.getName())) {
dependencies.addAll(info.getDependencyArtifacts());
}
}
@@ -1817,10 +1979,10 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
final ArtifactId targetId = this.buildArtifactId(ctx, apiRegion, ArtifactType.DEPENDENCIES);
final File target = new File(mainOutputDir, targetId.toMvnName());
- if ( !dependencies.isEmpty() ) {
+ if (!dependencies.isEmpty()) {
getLog().info("Writing dependencies file ".concat(target.getAbsolutePath()));
- try ( final Writer w = new FileWriter(target)) {
- for(final ArtifactId id : dependencies) {
+ try (final Writer w = new FileWriter(target)) {
+ for (final ArtifactId id : dependencies) {
w.write(id.toMvnId());
w.write(System.lineSeparator());
}
@@ -1832,13 +1994,12 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
}
} else {
getLog().info("No dependencies found");
- if ( target.exists() ) {
+ if (target.exists()) {
target.delete();
}
}
}
-
/**
* Generate the javadoc
* @param ctx The generation context
@@ -1850,28 +2011,30 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
* @return A collection of artifacts used for the generation or {@code null} if no packages found
* @throws MojoExecutionException on error
*/
- private Collection<ArtifactInfo> generateJavadoc(final ApisJarContext ctx,
+ private Collection<ArtifactInfo> generateJavadoc(
+ final ApisJarContext ctx,
final String regionName,
final JavadocLinks links,
final File javadocDir,
final RegionSupport regionSupport,
final boolean useDependencies)
- throws MojoExecutionException {
+ throws MojoExecutionException {
javadocDir.mkdirs();
final Collection<ArtifactInfo> usedInfos = new ArrayList<>();
final List<String> sourceDirectories = new ArrayList<>();
final Set<String> javadocPackages = new HashSet<>();
- for(final ArtifactInfo info : ctx.getArtifactInfos(regionName, useDependencies)) {
+ for (final ArtifactInfo info : ctx.getArtifactInfos(regionName, useDependencies)) {
boolean addDirectory = false;
- for(final Clause clause : info.getUsedExportedPackages(regionName)) {
- if ( !ctx.getPackagesWithoutSources().contains(clause.getName()) && !links.getLinkedPackages().contains(clause.getName())) {
+ for (final Clause clause : info.getUsedExportedPackages(regionName)) {
+ if (!ctx.getPackagesWithoutSources().contains(clause.getName())
+ && !links.getLinkedPackages().contains(clause.getName())) {
addDirectory = true;
javadocPackages.add(clause.getName());
}
}
- if ( addDirectory && info.getSourceDirectory() != null ) {
+ if (addDirectory && info.getSourceDirectory() != null) {
usedInfos.add(info);
sourceDirectories.add(info.getSourceDirectory().getAbsolutePath());
}
@@ -1882,17 +2045,19 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
}
// handle additional packages
- if ( !useDependencies) {
- for(final Artifact artifact : ApisUtil.getAdditionalJavadocArtifacts(ctx, regionName) ) {
+ if (!useDependencies) {
+ for (final Artifact artifact : ApisUtil.getAdditionalJavadocArtifacts(ctx, regionName)) {
final boolean infoExists = ctx.getArtifactInfo(artifact.getId()) != null;
- final ArtifactInfo info = infoExists ? ctx.getArtifactInfo(artifact.getId()) : ctx.addArtifactInfo(artifact);
+ final ArtifactInfo info =
+ infoExists ? ctx.getArtifactInfo(artifact.getId()) : ctx.addArtifactInfo(artifact);
- final Set<Clause> exportedPackages = regionSupport.getAllPublicPackages(ctx, artifact, getArtifactFile(artifact.getId()));
+ final Set<Clause> exportedPackages =
+ regionSupport.getAllPublicPackages(ctx, artifact, getArtifactFile(artifact.getId()));
final Iterator<Clause> iter = exportedPackages.iterator();
final Set<String> exportedPackageNames = new LinkedHashSet<>();
- while ( iter.hasNext() ) {
+ while (iter.hasNext()) {
final Clause c = iter.next();
- if ( javadocPackages.contains(c.getName()) ) {
+ if (javadocPackages.contains(c.getName())) {
iter.remove();
} else {
javadocPackages.add(c.getName());
@@ -1900,11 +2065,12 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
}
}
- if ( !exportedPackages.isEmpty() ) {
+ if (!exportedPackages.isEmpty()) {
info.setUsedExportedPackages(regionName, exportedPackages, "");
- if ( !infoExists ) {
+ if (!infoExists) {
info.setUsedExportedPackages(exportedPackageNames);
- info.setSourceDirectory(new File(ctx.getDeflatedSourcesDir(), info.getId().toMvnName()));
+ info.setSourceDirectory(new File(
+ ctx.getDeflatedSourcesDir(), info.getId().toMvnName()));
}
usedInfos.add(info);
@@ -1913,15 +2079,16 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
}
} else {
final Collection<ArtifactInfo> infos = ctx.getArtifactInfos(regionName, true);
- for(final ArtifactInfo i : ctx.getArtifactInfos(regionName, false)) {
- if ( !infos.contains(i) ) {
+ for (final ArtifactInfo i : ctx.getArtifactInfos(regionName, false)) {
+ if (!infos.contains(i)) {
boolean addDirectory = false;
- for(final Clause clause : i.getUsedExportedPackages(regionName)) {
- if ( !ctx.getPackagesWithoutSources().contains(clause.getName()) && !links.getLinkedPackages().contains(clause.getName())) {
+ for (final Clause clause : i.getUsedExportedPackages(regionName)) {
+ if (!ctx.getPackagesWithoutSources().contains(clause.getName())
+ && !links.getLinkedPackages().contains(clause.getName())) {
addDirectory = true;
}
}
- if ( addDirectory && i.getSourceDirectory() != null ) {
+ if (addDirectory && i.getSourceDirectory() != null) {
sourceDirectories.add(i.getSourceDirectory().getAbsolutePath());
}
}
@@ -1929,53 +2096,60 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
}
final JavadocExecutor javadocExecutor = new JavadocExecutor(javadocDir.getParentFile())
- .addArgument("-public")
- .addArgument("-encoding", false)
- .addArgument("UTF-8")
- .addArgument("-charset", false)
- .addArgument("UTF-8")
- .addArgument("-docencoding", false)
- .addArgument("UTF-8")
- .addArgument("-d", false)
- .addArgument(javadocDir.getAbsolutePath())
- .addArgument("-sourcepath", false)
- .addArgument(String.join(File.pathSeparator, sourceDirectories));
-
- javadocExecutor.addArgument("-source", false)
- .addArgument(ctx.getConfig().getJavadocSourceLevel());
-
- final String versionSuffix = ctx.getConfig().getApiVersion() != null ? ctx.getConfig().getApiVersion() : ctx.getFeatureId().getVersion();
+ .addArgument("-public")
+ .addArgument("-encoding", false)
+ .addArgument("UTF-8")
+ .addArgument("-charset", false)
+ .addArgument("UTF-8")
+ .addArgument("-docencoding", false)
+ .addArgument("UTF-8")
+ .addArgument("-d", false)
+ .addArgument(javadocDir.getAbsolutePath())
+ .addArgument("-sourcepath", false)
+ .addArgument(String.join(File.pathSeparator, sourceDirectories));
+
+ javadocExecutor
+ .addArgument("-source", false)
+ .addArgument(ctx.getConfig().getJavadocSourceLevel());
+
+ final String versionSuffix = ctx.getConfig().getApiVersion() != null
+ ? ctx.getConfig().getApiVersion()
+ : ctx.getFeatureId().getVersion();
if (!StringUtils.isBlank(project.getName())) {
- javadocExecutor.addArgument("-doctitle", false)
- .addQuotedArgument(project.getName().trim().concat(" ").concat(versionSuffix));
+ javadocExecutor
+ .addArgument("-doctitle", false)
+ .addQuotedArgument(project.getName().trim().concat(" ").concat(versionSuffix));
}
if (!StringUtils.isBlank(project.getDescription())) {
- javadocExecutor.addArgument("-windowtitle", false)
- .addQuotedArgument(project.getDescription().trim().concat(" ").concat(versionSuffix));
+ javadocExecutor
+ .addArgument("-windowtitle", false)
+ .addQuotedArgument(
+ project.getDescription().trim().concat(" ").concat(versionSuffix));
}
if (!StringUtils.isBlank(project.getInceptionYear())
&& project.getOrganization() != null
&& !StringUtils.isBlank(project.getOrganization().getName())) {
- javadocExecutor.addArgument("-bottom", false)
- .addQuotedArgument(String.format("Copyright © %s - %s %s. All Rights Reserved",
- project.getInceptionYear().trim(),
- Calendar.getInstance().get(Calendar.YEAR),
- project.getOrganization().getName().trim()));
+ javadocExecutor
+ .addArgument("-bottom", false)
+ .addQuotedArgument(String.format(
+ "Copyright © %s - %s %s. All Rights Reserved",
+ project.getInceptionYear().trim(),
+ Calendar.getInstance().get(Calendar.YEAR),
+ project.getOrganization().getName().trim()));
}
- if ( !links.getJavadocLinks().isEmpty()) {
+ if (!links.getJavadocLinks().isEmpty()) {
javadocExecutor.addArguments("-link", links.getJavadocLinks());
}
// classpath
- final Collection<String> classpath = ApisUtil.getJavadocClassPath(getLog(), repositorySystem, mavenSession,
- ctx, regionName);
+ final Collection<String> classpath =
+ ApisUtil.getJavadocClassPath(getLog(), repositorySystem, mavenSession, ctx, regionName);
if (!classpath.isEmpty()) {
- javadocExecutor.addArgument("-classpath", false)
- .addArgument(classpath, File.pathSeparator);
+ javadocExecutor.addArgument("-classpath", false).addArgument(classpath, File.pathSeparator);
}
// turn off doclint
@@ -1983,10 +2157,10 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
javadocExecutor.addArgument("--allow-script-in-comments");
- if ( !this.javadocIndex ) {
+ if (!this.javadocIndex) {
javadocExecutor.addArgument("-noindex");
}
- if ( !this.javadocTree ) {
+ if (!this.javadocTree) {
javadocExecutor.addArgument("-notree");
}
@@ -1998,26 +2172,29 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
return usedInfos;
}
- private File createLicenseReport(final ApisJarContext ctx,
+ private File createLicenseReport(
+ final ApisJarContext ctx,
final ApiRegion region,
final Collection<ArtifactInfo> infos,
- final List<String> report) throws MojoExecutionException {
+ final List<String> report)
+ throws MojoExecutionException {
final File out = new File(this.getTmpDir(), region.getName() + "-license-report.txt");
- if ( !out.exists() ) {
+ if (!out.exists()) {
final List<String> output = new ArrayList<>();
output.add(ctx.getConfig().getLicenseReportHeader());
output.add("");
- for(final ArtifactInfo info : infos) {
+ for (final ArtifactInfo info : infos) {
final String licenseDefault = ctx.getConfig().getLicenseDefault(info.getId());
final StringBuilder sb = new StringBuilder(info.getId().toMvnId());
boolean exclude = false;
- if ( licenseDefault != null ) {
- if ( licenseDefault.isEmpty()) {
+ if (licenseDefault != null) {
+ if (licenseDefault.isEmpty()) {
exclude = true;
- getLog().debug("Excluding from license report " + info.getId().toMvnId());
+ getLog().debug("Excluding from license report "
+ + info.getId().toMvnId());
} else {
sb.append(" - License(s) : ");
sb.append(licenseDefault);
@@ -2025,21 +2202,26 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
} else {
final List<License> licenses = this.getLicenses(ctx, info);
- if ( !licenses.isEmpty() ) {
+ if (!licenses.isEmpty()) {
sb.append(" - License(s) : ");
- sb.append(String.join(", ",
+ sb.append(String.join(
+ ", ",
licenses.stream()
- .map(l -> l.getName().concat(" (").concat(l.getUrl()).concat(")"))
+ .map(l -> l.getName()
+ .concat(" (")
+ .concat(l.getUrl())
+ .concat(")"))
.collect(Collectors.toList())));
} else {
- report.add("No license info found for ".concat(info.getId().toMvnId()));
+ report.add(
+ "No license info found for ".concat(info.getId().toMvnId()));
}
}
- if ( !exclude ) {
+ if (!exclude) {
output.add(sb.toString());
}
}
- if ( ctx.getConfig().getLicenseReportFooter() != null ) {
+ if (ctx.getConfig().getLicenseReportFooter() != null) {
output.add("");
output.add(ctx.getConfig().getLicenseReportFooter());
}
@@ -2055,20 +2237,25 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
private List<License> getLicenses(final ApisJarContext ctx, final ArtifactInfo info) {
getLog().debug("Getting license for " + info.getId().toMvnId());
List<License> result = info.getLicenses();
- if ( result == null ) {
+ if (result == null) {
try {
ArtifactId id = info.getId();
do {
final Model model = getArtifactPom(ctx, id);
final List<License> ll = model.getLicenses();
- if ( ll != null && !ll.isEmpty() ) {
+ if (ll != null && !ll.isEmpty()) {
getLog().debug("Found license for " + id.toMvnId());
result = ll;
} else {
- if ( model.getParent() != null ) {
- final ArtifactId newId = new ArtifactId(model.getParent().getGroupId(), model.getParent().getArtifactId(), model.getParent().getVersion(), null, "pom");
- if ( newId.equals(id) ) {
+ if (model.getParent() != null) {
+ final ArtifactId newId = new ArtifactId(
+ model.getParent().getGroupId(),
+ model.getParent().getArtifactId(),
+ model.getParent().getVersion(),
+ null,
+ "pom");
+ if (newId.equals(id)) {
break;
} else {
id = newId;
@@ -2077,11 +2264,11 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
break;
}
}
- } while (result == null);
+ } while (result == null);
} catch (MojoExecutionException m) {
// nothing to do
}
- if ( result == null ) {
+ if (result == null) {
result = Collections.emptyList();
}
info.setLicenses(result);
@@ -2090,28 +2277,31 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
return result;
}
- private List<ArtifactInfo> getAdditionalJavadocArtifacts(final ApisJarContext ctx, final ApiRegion region, final RegionSupport regionSupport)
- throws MojoExecutionException {
+ private List<ArtifactInfo> getAdditionalJavadocArtifacts(
+ final ApisJarContext ctx, final ApiRegion region, final RegionSupport regionSupport)
+ throws MojoExecutionException {
final List<ArtifactInfo> result = new ArrayList<>();
- for(final Artifact artifact : ApisUtil.getAdditionalJavadocArtifacts(ctx, region.getName()) ) {
+ for (final Artifact artifact : ApisUtil.getAdditionalJavadocArtifacts(ctx, region.getName())) {
final ArtifactInfo info = new ArtifactInfo(artifact);
- final Set<Clause> exportedPackages = regionSupport.getAllPublicPackages(ctx, artifact, getArtifactFile(artifact.getId()));
+ final Set<Clause> exportedPackages =
+ regionSupport.getAllPublicPackages(ctx, artifact, getArtifactFile(artifact.getId()));
final Set<String> exportedPackageNames = new LinkedHashSet<>();
final Iterator<Clause> clauseIter = exportedPackages.iterator();
- while ( clauseIter.hasNext() ) {
+ while (clauseIter.hasNext()) {
final Clause c = clauseIter.next();
- if ( region.getAllExportByName(c.getName()) == null ) {
+ if (region.getAllExportByName(c.getName()) == null) {
exportedPackageNames.add(c.getName());
} else {
clauseIter.remove();
}
}
- if ( !exportedPackages.isEmpty() ) {
+ if (!exportedPackages.isEmpty()) {
info.setUsedExportedPackages(region.getName(), exportedPackages, "");
info.setUsedExportedPackages(exportedPackageNames);
- info.setSourceDirectory(new File(ctx.getDeflatedSourcesDir(), info.getId().toMvnName()));
+ info.setSourceDirectory(
+ new File(ctx.getDeflatedSourcesDir(), info.getId().toMvnName()));
final boolean skipSourceDeflate = info.getSourceDirectory().exists();
if (skipSourceDeflate) {
getLog().debug("Source for artifact " + info.getId().toMvnName() + " already deflated");
@@ -2125,4 +2315,3 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
return result;
}
}
-
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/ApplyDefaultConfigMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/ApplyDefaultConfigMojo.java
index fd91563..39d51ca 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/ApplyDefaultConfigMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/ApplyDefaultConfigMojo.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -34,9 +36,7 @@ import org.apache.sling.feature.maven.ProjectHelper;
/**
* This mojo applies default configurations to selected features.
*/
-@Mojo(name = "apply-default-config",
- defaultPhase = LifecyclePhase.PROCESS_RESOURCES,
- threadSafe = true)
+@Mojo(name = "apply-default-config", defaultPhase = LifecyclePhase.PROCESS_RESOURCES, threadSafe = true)
public class ApplyDefaultConfigMojo extends AbstractIncludingFeatureMojo {
/**
@@ -66,42 +66,48 @@ public class ApplyDefaultConfigMojo extends AbstractIncludingFeatureMojo {
String configurationApiClassifier;
private ConfigurationApi getDefaultConfigurationApi() throws MojoExecutionException {
- if ( this.configurationApiClassifier != null && this.configurationApiDependency != null ) {
- throw new MojoExecutionException("Only one of configurationApiDependency or configurationApiClassifier can be specified, but not both.");
+ if (this.configurationApiClassifier != null && this.configurationApiDependency != null) {
+ throw new MojoExecutionException(
+ "Only one of configurationApiDependency or configurationApiClassifier can be specified, but not both.");
}
ConfigurationApi defaultApi = null;
- if ( this.configurationApiClassifier != null ) {
+ if (this.configurationApiClassifier != null) {
final Map<String, Feature> projectFeatures = ProjectHelper.getAssembledFeatures(this.project);
- for(final Feature f : projectFeatures.values()) {
- if ( this.configurationApiClassifier.equals(f.getId().getClassifier()) ) {
+ for (final Feature f : projectFeatures.values()) {
+ if (this.configurationApiClassifier.equals(f.getId().getClassifier())) {
defaultApi = ConfigurationApi.getConfigurationApi(f);
- if ( defaultApi == null ) {
- throw new MojoExecutionException("Specified feature with classifier " + this.configurationApiClassifier + " does not contain configuration api");
+ if (defaultApi == null) {
+ throw new MojoExecutionException("Specified feature with classifier "
+ + this.configurationApiClassifier + " does not contain configuration api");
}
break;
}
}
- if ( defaultApi == null ) {
- throw new MojoExecutionException("Specified feature with classifier + " + this.configurationApiClassifier + " does not exist in project.");
+ if (defaultApi == null) {
+ throw new MojoExecutionException("Specified feature with classifier + "
+ + this.configurationApiClassifier + " does not exist in project.");
}
- } else if ( this.configurationApiDependency != null ) {
+ } else if (this.configurationApiDependency != null) {
final ArtifactId depId = ProjectHelper.toArtifactId(this.configurationApiDependency);
if (ProjectHelper.isLocalProjectArtifact(this.project, depId)) {
throw new MojoExecutionException(
- "configurationApiDependency configuration is used to select a local feature: " + depId.toMvnId());
+ "configurationApiDependency configuration is used to select a local feature: "
+ + depId.toMvnId());
}
- final Feature f = ProjectHelper.getOrResolveFeature(this.project, this.mavenSession,
- this.artifactHandlerManager, this.repoSystem, depId);
+ final Feature f = ProjectHelper.getOrResolveFeature(
+ this.project, this.mavenSession, this.artifactHandlerManager, this.repoSystem, depId);
defaultApi = ConfigurationApi.getConfigurationApi(f);
- if ( defaultApi == null ) {
- throw new MojoExecutionException("Specified feature " + depId.toMvnId() + " does not contain configuration api");
+ if (defaultApi == null) {
+ throw new MojoExecutionException(
+ "Specified feature " + depId.toMvnId() + " does not contain configuration api");
}
}
- if ( defaultApi != null ) {
- getLog().info("Using configured configuration-api from " +
- (this.configurationApiClassifier != null ? "classifier " + this.configurationApiClassifier
- : " dependency " + ProjectHelper.toString(this.configurationApiDependency)));
+ if (defaultApi != null) {
+ getLog().info("Using configured configuration-api from "
+ + (this.configurationApiClassifier != null
+ ? "classifier " + this.configurationApiClassifier
+ : " dependency " + ProjectHelper.toString(this.configurationApiDependency)));
}
return defaultApi;
@@ -120,17 +126,19 @@ public class ApplyDefaultConfigMojo extends AbstractIncludingFeatureMojo {
// check if configuration api is set
final ConfigurationApi api = defaultApi != null ? defaultApi : ConfigurationApi.getConfigurationApi(f);
- if ( api != null ) {
+ if (api != null) {
final FeatureValidator validator = new FeatureValidator();
validator.setFeatureProvider(new BaseFeatureProvider());
final FeatureValidationResult result = validator.validate(f, api);
- if ( !result.isValid() && failOnValidationError ) {
- throw new MojoExecutionException("Unable to apply default configuration to invalid feature ".concat(f.getId().toMvnId()));
+ if (!result.isValid() && failOnValidationError) {
+ throw new MojoExecutionException("Unable to apply default configuration to invalid feature "
+ .concat(f.getId().toMvnId()));
}
- if ( validator.applyDefaultValues(f, result) ) {
- getLog().info("Applied default configurations to feature ".concat(f.getId().toMvnId()));
+ if (validator.applyDefaultValues(f, result)) {
+ getLog().info("Applied default configurations to feature "
+ .concat(f.getId().toMvnId()));
ProjectHelper.createTmpFeatureFile(project, f, true);
}
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/Archive.java b/src/main/java/org/apache/sling/feature/maven/mojos/Archive.java
index 8761107..6c11955 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/Archive.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/Archive.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -51,7 +53,7 @@ public class Archive extends FeatureSelectionConfig {
@Override
public String toString() {
- return "Archive [classifier=" + classifier + ", type=" + type + ", getFilesExcludes()=" + getFilesExcludes() + ", getSelections()="
- + getSelections() + ", attach()=" + attach + "]";
+ return "Archive [classifier=" + classifier + ", type=" + type + ", getFilesExcludes()=" + getFilesExcludes()
+ + ", getSelections()=" + getSelections() + ", attach()=" + attach + "]";
}
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/AttachFeatureArchivesMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/AttachFeatureArchivesMojo.java
index d17ec72..5e6c034 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/AttachFeatureArchivesMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/AttachFeatureArchivesMojo.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -49,8 +51,7 @@ import org.apache.sling.feature.maven.ProjectHelper;
name = "attach-featurearchives",
defaultPhase = LifecyclePhase.PACKAGE,
requiresDependencyResolution = ResolutionScope.TEST,
- threadSafe = true
- )
+ threadSafe = true)
public class AttachFeatureArchivesMojo extends AbstractIncludingFeatureMojo {
private static final String DEFAULT_CLASSIFIER = "far";
@@ -83,7 +84,8 @@ public class AttachFeatureArchivesMojo extends AbstractIncludingFeatureMojo {
checkPreconditions();
if (archives == null || archives.size() == 0) {
// by default create an archive of each feature individually
- for (final Map.Entry<String, Feature> entry : ProjectHelper.getFeatures(this.project).entrySet()) {
+ for (final Map.Entry<String, Feature> entry :
+ ProjectHelper.getFeatures(this.project).entrySet()) {
final boolean add;
if (ProjectHelper.isAggregate(entry.getKey())) {
add = ProjectHelper.isAttachAggregate(entry.getKey());
@@ -92,9 +94,11 @@ public class AttachFeatureArchivesMojo extends AbstractIncludingFeatureMojo {
}
if (add) {
- final String classifier = entry.getValue().getId().getClassifier() == null ? DEFAULT_CLASSIFIER
+ final String classifier = entry.getValue().getId().getClassifier() == null
+ ? DEFAULT_CLASSIFIER
: entry.getValue().getId().getClassifier().concat(DEFAULT_CLASSIFIER);
- createArchive(Collections.singletonList(entry.getValue()), classifier, Archive.DEFAULT_EXTENSION, true);
+ createArchive(
+ Collections.singletonList(entry.getValue()), classifier, Archive.DEFAULT_EXTENSION, true);
}
}
} else {
@@ -144,8 +148,11 @@ public class AttachFeatureArchivesMojo extends AbstractIncludingFeatureMojo {
* @param type The type to use for the archive
* @param attach Whether the archive should be attached to the project
*/
- private void createArchive(final List<Feature> features, final String classifier, final String type, final boolean attach) throws MojoExecutionException {
- final ArtifactId archiveId = features.get(0).getId().changeClassifier(classifier).changeType(type);
+ private void createArchive(
+ final List<Feature> features, final String classifier, final String type, final boolean attach)
+ throws MojoExecutionException {
+ final ArtifactId archiveId =
+ features.get(0).getId().changeClassifier(classifier).changeType(type);
// write the feature model archive
final File outputFile = new File(
@@ -153,40 +160,43 @@ public class AttachFeatureArchivesMojo extends AbstractIncludingFeatureMojo {
outputFile.getParentFile().mkdirs();
getLog().info("Creating feature archive " + outputFile.getName());
- try ( final FileOutputStream fos = new FileOutputStream(outputFile);
- final JarOutputStream jos = ArchiveWriter.write(fos,
- createBaseManifest(features.size() == 1 ? features.get(0) : null), id -> {
-
- try {
- return ProjectHelper.getOrResolveArtifact(project, mavenSession, artifactHandlerManager,
- repoSystem, id).getFile().toURI().toURL();
- } catch (final MalformedURLException e) {
- getLog().debug("Malformed url " + e.getMessage(), e);
- // ignore
- return null;
- }
- }
- , features.toArray(new Feature[features.size()]))) {
+ try (final FileOutputStream fos = new FileOutputStream(outputFile);
+ final JarOutputStream jos = ArchiveWriter.write(
+ fos,
+ createBaseManifest(features.size() == 1 ? features.get(0) : null),
+ id -> {
+ try {
+ return ProjectHelper.getOrResolveArtifact(
+ project, mavenSession, artifactHandlerManager, repoSystem, id)
+ .getFile()
+ .toURI()
+ .toURL();
+ } catch (final MalformedURLException e) {
+ getLog().debug("Malformed url " + e.getMessage(), e);
+ // ignore
+ return null;
+ }
+ },
+ features.toArray(new Feature[features.size()]))) {
// handle license etc.
final File classesDir = new File(this.project.getBuild().getOutputDirectory());
- if ( classesDir.exists() ) {
+ if (classesDir.exists()) {
final File metaInfDir = new File(classesDir, "META-INF");
- for(final String name : new String[] {"LICENSE", "NOTICE", "DEPENDENCIES"}) {
+ for (final String name : new String[] {"LICENSE", "NOTICE", "DEPENDENCIES"}) {
final File f = new File(metaInfDir, name);
- if ( f.exists() ) {
+ if (f.exists()) {
final JarEntry artifactEntry = new JarEntry("META-INF/" + name);
jos.putNextEntry(artifactEntry);
final byte[] buffer = new byte[8192];
try (final InputStream is = new FileInputStream(f)) {
int l = 0;
- while ( (l = is.read(buffer)) > 0 ) {
+ while ((l = is.read(buffer)) > 0) {
jos.write(buffer, 0, l);
}
}
jos.closeEntry();
-
}
}
}
@@ -196,7 +206,7 @@ public class AttachFeatureArchivesMojo extends AbstractIncludingFeatureMojo {
"Unable to write feature model archive to " + outputFile + " : " + e.getMessage(), e);
}
- if ( attach ) {
+ if (attach) {
// attach it as an additional artifact
projectHelper.attachArtifact(project, archiveId.getType(), archiveId.getClassifier(), outputFile);
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/AttachFeaturesMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/AttachFeaturesMojo.java
index 3fbff68..1ed7c3d 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/AttachFeaturesMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/AttachFeaturesMojo.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -43,11 +45,11 @@ import org.osgi.framework.Constants;
/**
* Attach the feature as a project artifact.
*/
-@Mojo(name = "attach-features",
+@Mojo(
+ name = "attach-features",
defaultPhase = LifecyclePhase.PACKAGE,
- requiresDependencyResolution = ResolutionScope.TEST,
- threadSafe = true
- )
+ requiresDependencyResolution = ResolutionScope.TEST,
+ threadSafe = true)
public class AttachFeaturesMojo extends AbstractFeatureMojo {
/**
* Attach main features (source)
@@ -58,8 +60,7 @@ public class AttachFeaturesMojo extends AbstractFeatureMojo {
/**
* Attach test features (source)
*/
- @Parameter(name = "attachTestFeatures",
- defaultValue = "false")
+ @Parameter(name = "attachTestFeatures", defaultValue = "false")
private boolean attachTestFeatures;
/**
@@ -87,43 +88,47 @@ public class AttachFeaturesMojo extends AbstractFeatureMojo {
/** Not found entry */
private static final Map.Entry<String, String> NOT_FOUND = new AbstractMap.SimpleImmutableEntry<>("NULL", "NULL");
- private void attach(final Feature feature)
- throws MojoExecutionException {
+ private void attach(final Feature feature) throws MojoExecutionException {
final String classifier = feature.getId().getClassifier();
boolean changed = false;
// check for metadata
- if ( this.includeBundleMetadata ) {
- for(final Artifact bundle : feature.getBundles()) {
- if ( bundle.getMetadata().get(Constants.BUNDLE_SYMBOLICNAME) == null ) {
- Map.Entry<String, String> value = METADATA_CACHE.get(bundle.getId().toMvnId());
- if ( value == null ) {
- final org.apache.maven.artifact.Artifact source = ProjectHelper.getOrResolveArtifact(this.project,
- this.mavenSession,
- this.artifactHandlerManager,
- this.repoSystem,
- bundle.getId());
-
+ if (this.includeBundleMetadata) {
+ for (final Artifact bundle : feature.getBundles()) {
+ if (bundle.getMetadata().get(Constants.BUNDLE_SYMBOLICNAME) == null) {
+ Map.Entry<String, String> value =
+ METADATA_CACHE.get(bundle.getId().toMvnId());
+ if (value == null) {
+ final org.apache.maven.artifact.Artifact source = ProjectHelper.getOrResolveArtifact(
+ this.project,
+ this.mavenSession,
+ this.artifactHandlerManager,
+ this.repoSystem,
+ bundle.getId());
+
try (final JarFile jarFile = new JarFile(source.getFile())) {
- final String symbolicName = jarFile.getManifest().getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
- final String version = jarFile.getManifest().getMainAttributes().getValue(Constants.BUNDLE_VERSION);
- if ( symbolicName != null && version != null ) {
+ final String symbolicName =
+ jarFile.getManifest().getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
+ final String version =
+ jarFile.getManifest().getMainAttributes().getValue(Constants.BUNDLE_VERSION);
+ if (symbolicName != null && version != null) {
final int idx = symbolicName.indexOf(";");
- value = new AbstractMap.SimpleImmutableEntry<>(idx == -1 ? symbolicName : symbolicName.substring(0, idx), version);
+ value = new AbstractMap.SimpleImmutableEntry<>(
+ idx == -1 ? symbolicName : symbolicName.substring(0, idx), version);
}
} catch (final IOException e) {
// we ignore this
}
- if ( value == null ) {
+ if (value == null) {
value = NOT_FOUND;
}
METADATA_CACHE.put(bundle.getId().toMvnId(), value);
- }
- if ( value != NOT_FOUND ) {
- bundle.getMetadata().put(Constants.BUNDLE_SYMBOLICNAME, value.getKey());
- bundle.getMetadata().put(Constants.BUNDLE_VERSION, value.getValue());
- changed = true;
- }
+ }
+ if (value != NOT_FOUND) {
+ bundle.getMetadata().put(Constants.BUNDLE_SYMBOLICNAME, value.getKey());
+ bundle.getMetadata().put(Constants.BUNDLE_VERSION, value.getValue());
+ changed = true;
+ }
}
}
}
@@ -132,13 +137,11 @@ public class AttachFeaturesMojo extends AbstractFeatureMojo {
final File outputFile = ProjectHelper.createTmpFeatureFile(project, feature, changed);
// if this project is a feature, it's the main artifact
- if ( project.getPackaging().equals(FeatureConstants.PACKAGING_FEATURE)
- && classifier == null) {
+ if (project.getPackaging().equals(FeatureConstants.PACKAGING_FEATURE) && classifier == null) {
project.getArtifact().setFile(outputFile);
} else {
// otherwise attach it as an additional artifact
- projectHelper.attachArtifact(project, FeatureConstants.PACKAGING_FEATURE,
- classifier, outputFile);
+ projectHelper.attachArtifact(project, FeatureConstants.PACKAGING_FEATURE, classifier, outputFile);
}
}
@@ -147,8 +150,8 @@ public class AttachFeaturesMojo extends AbstractFeatureMojo {
checkPreconditions();
final List<String> featureUrls = new ArrayList<>();
this.attachClassifierFeatures(ProjectHelper.getFeatures(this.project), featureUrls, this.attachMainFeatures);
- this.attachClassifierFeatures(ProjectHelper.getTestFeatures(this.project), featureUrls,
- this.attachTestFeatures);
+ this.attachClassifierFeatures(
+ ProjectHelper.getTestFeatures(this.project), featureUrls, this.attachTestFeatures);
if (this.createReferenceFile) {
this.createReferenceFile(featureUrls);
@@ -158,7 +161,7 @@ public class AttachFeaturesMojo extends AbstractFeatureMojo {
private void createReferenceFile(final List<String> featureUrls) throws MojoExecutionException {
if (featureUrls.isEmpty()) {
getLog().warn(
- "Create reference file is enabled but no features are attached. Skipping reference file generation.");
+ "Create reference file is enabled but no features are attached. Skipping reference file generation.");
} else {
String fileName = "references";
if (this.referenceFileClassifier != null) {
@@ -184,8 +187,8 @@ public class AttachFeaturesMojo extends AbstractFeatureMojo {
* Attach all features
* @throws MojoExecutionException
*/
- void attachClassifierFeatures(final Map<String, Feature> features, final List<String> featureUrls,
- final boolean addSourceFeatures)
+ void attachClassifierFeatures(
+ final Map<String, Feature> features, final List<String> featureUrls, final boolean addSourceFeatures)
throws MojoExecutionException {
for (final Map.Entry<String, Feature> entry : features.entrySet()) {
final boolean add;
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/CollectArtifactsMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/CollectArtifactsMojo.java
index d5ea2e0..b842ba8 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/CollectArtifactsMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/CollectArtifactsMojo.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -29,11 +31,7 @@ import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.sling.feature.Feature;
-@Mojo(
- name = "collect-artifacts",
- requiresProject = false,
- threadSafe = true
-)
+@Mojo(name = "collect-artifacts", requiresProject = false, threadSafe = true)
public final class CollectArtifactsMojo extends AbstractRepositoryMojo {
private final Pattern gavPattern = Pattern.compile("([^: ]+):([^: ]+)(:([^: ]*)(:([^: ]+))?)?:([^: ]+)");
@@ -47,9 +45,9 @@ public final class CollectArtifactsMojo extends AbstractRepositoryMojo {
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
- final File artifactDir ;
+ final File artifactDir;
// this strange looking line checks whether this is outside of a maven project
- if ( this.project.getBuild().getDirectory().contains( "${project.basedir}" ) ) {
+ if (this.project.getBuild().getDirectory().contains("${project.basedir}")) {
artifactDir = new File(repositoryDir);
} else {
artifactDir = new File(this.project.getBuild().getDirectory(), repositoryDir);
@@ -68,9 +66,10 @@ public final class CollectArtifactsMojo extends AbstractRepositoryMojo {
Matcher gavMatcher = gavPattern.matcher(gav);
if (!gavMatcher.matches()) {
- getLog().warn("Wrong GAV coordinates "
- + gav
- + " specified on 'features' property, expected format is groupId:artifactId[:packaging[:classifier]]:version");
+ getLog().warn(
+ "Wrong GAV coordinates "
+ + gav
+ + " specified on 'features' property, expected format is groupId:artifactId[:packaging[:classifier]]:version");
}
final Dependency dep = new Dependency();
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/EmbedFeaturesMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/EmbedFeaturesMojo.java
index fa5448b..eee2d04 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/EmbedFeaturesMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/EmbedFeaturesMojo.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -34,10 +36,11 @@ import org.apache.sling.feature.io.json.FeatureJSONWriter;
/**
* Embed the features in the resources
*/
-@Mojo(name = "embed-features", defaultPhase = LifecyclePhase.PREPARE_PACKAGE,
- requiresDependencyResolution = ResolutionScope.TEST,
- threadSafe = true
- )
+@Mojo(
+ name = "embed-features",
+ defaultPhase = LifecyclePhase.PREPARE_PACKAGE,
+ requiresDependencyResolution = ResolutionScope.TEST,
+ threadSafe = true)
public class EmbedFeaturesMojo extends AbstractIncludingFeatureMojo {
/**
@@ -57,18 +60,18 @@ public class EmbedFeaturesMojo extends AbstractIncludingFeatureMojo {
@Parameter(defaultValue = "${project.build.outputDirectory}", readonly = true)
private File buildOutputDirectory;
- private void include(final File directory, final Feature feature)
- throws MojoExecutionException {
+ private void include(final File directory, final Feature feature) throws MojoExecutionException {
// write the feature
final String classifier = feature.getId().getClassifier();
- final File outputFile = new File(directory,
- classifier == null ? "feature.json" : "feature-" + classifier + ".json");
+ final File outputFile =
+ new File(directory, classifier == null ? "feature.json" : "feature-" + classifier + ".json");
outputFile.getParentFile().mkdirs();
- try ( final Writer writer = new FileWriter(outputFile)) {
+ try (final Writer writer = new FileWriter(outputFile)) {
FeatureJSONWriter.write(writer, feature);
} catch (final IOException e) {
- throw new MojoExecutionException("Unable to write feature " + feature.getId().toMvnId() + " to " + outputFile, e);
+ throw new MojoExecutionException(
+ "Unable to write feature " + feature.getId().toMvnId() + " to " + outputFile, e);
}
}
@@ -76,8 +79,8 @@ public class EmbedFeaturesMojo extends AbstractIncludingFeatureMojo {
public void execute() throws MojoExecutionException, MojoFailureException {
checkPreconditions();
- final Map<String, Feature> features = embed == null ? this.selectAllFeatureFilesAndAggregates()
- : this.getSelectedFeatures(embed);
+ final Map<String, Feature> features =
+ embed == null ? this.selectAllFeatureFilesAndAggregates() : this.getSelectedFeatures(embed);
if (features.isEmpty()) {
getLog().info("No features to embed");
} else {
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/ExtractExtensionMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/ExtractExtensionMojo.java
index 31322ab..4436d74 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/ExtractExtensionMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/ExtractExtensionMojo.java
@@ -1,21 +1,29 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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 java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Map;
+
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
@@ -26,15 +34,7 @@ import org.apache.sling.feature.Extension;
import org.apache.sling.feature.ExtensionType;
import org.apache.sling.feature.Feature;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Map;
-
-@Mojo(name = "extract-extension",
- defaultPhase = LifecyclePhase.PACKAGE,
- threadSafe = true)
+@Mojo(name = "extract-extension", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true)
public class ExtractExtensionMojo extends AbstractIncludingFeatureMojo {
@Parameter(name = "selection", required = true)
FeatureSelectionConfig selection;
@@ -72,19 +72,19 @@ public class ExtractExtensionMojo extends AbstractIncludingFeatureMojo {
try (Writer wr = new FileWriter(new File(dir, fileName))) {
switch (ext.getType()) {
- case ARTIFACTS:
- // List the artifacts as text
- for (Artifact a : ext.getArtifacts()) {
- wr.write(a.getId().toMvnId());
- wr.write(System.lineSeparator());
- }
- break;
- case JSON:
- wr.write(ext.getJSON());
- break;
- case TEXT:
- wr.write(ext.getText());
- break;
+ case ARTIFACTS:
+ // List the artifacts as text
+ for (Artifact a : ext.getArtifacts()) {
+ wr.write(a.getId().toMvnId());
+ wr.write(System.lineSeparator());
+ }
+ break;
+ case JSON:
+ wr.write(ext.getJSON());
+ break;
+ case TEXT:
+ wr.write(ext.getText());
+ break;
}
} catch (IOException ex) {
throw new MojoExecutionException("Problem writing feature" + outputDir, ex);
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
index 5441c78..5a25ec7 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/FeatureLauncherMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/FeatureLauncherMojo.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -40,11 +42,7 @@ import org.apache.sling.feature.io.json.FeatureJSONWriter;
/**
* Launches the given Feature File
*/
-@Mojo(
- name = "launch-features",
- requiresProject = true,
- threadSafe = true
-)
+@Mojo(name = "launch-features", requiresProject = true, threadSafe = true)
public class FeatureLauncherMojo extends AbstractIncludingFeatureMojo {
public static final String CFG_FEATURE_ARCHIVE_FILES = "featureArchiveFiles";
@@ -147,27 +145,29 @@ public class FeatureLauncherMojo extends AbstractIncludingFeatureMojo {
checkPreconditions();
List<String> arguments = new ArrayList<>();
getLog().info("Feature Selection: " + selection);
- if(featureArchiveFiles != null && !featureArchiveFiles.isEmpty()) {
+ if (featureArchiveFiles != null && !featureArchiveFiles.isEmpty()) {
for (File file : featureArchiveFiles) {
handleFile(arguments, file, "-f");
}
}
- ArtifactRepository artifactRepository = this.mavenSession.getProjectBuildingRequest().getLocalRepository();
+ ArtifactRepository artifactRepository =
+ this.mavenSession.getProjectBuildingRequest().getLocalRepository();
String localPath = artifactRepository.getBasedir();
- if(featureArchiveClassifiers != null && !featureArchiveClassifiers.isEmpty()) {
+ if (featureArchiveClassifiers != null && !featureArchiveClassifiers.isEmpty()) {
for (String featureArchiveClassifier : featureArchiveClassifiers) {
ArtifactId id = new ArtifactId(
- this.project.getGroupId(), this.project.getArtifactId(),
- this.project.getVersion(), featureArchiveClassifier,
- "far"
- );
+ this.project.getGroupId(),
+ this.project.getArtifactId(),
+ this.project.getVersion(),
+ featureArchiveClassifier,
+ "far");
String artifactPath = id.toMvnPath();
getLog().info("Artifact Maven Path: " + artifactPath);
File file = new File(localPath, artifactPath);
handleFile(arguments, file, "-f");
}
}
- if(featureArchiveIds != null && !featureArchiveIds.isEmpty()) {
+ if (featureArchiveIds != null && !featureArchiveIds.isEmpty()) {
for (String featureArchive : featureArchiveIds) {
ArtifactId id = ArtifactId.parse(featureArchive);
if (id != null) {
@@ -178,17 +178,18 @@ public class FeatureLauncherMojo extends AbstractIncludingFeatureMojo {
}
}
}
- if(selection != null && !selection.getSelections().isEmpty()) {
+ if (selection != null && !selection.getSelections().isEmpty()) {
final Collection<Feature> features = getSelectedFeatures(selection).values();
getLog().info("Features from Selection: " + features);
for (Feature feature : features) {
- // Loop over all features found, create a temporary file, write the features there and add them to the launcher's file list
+ // Loop over all features found, create a temporary file, write the features there and add them to the
+ // launcher's file list
File folder;
- try {
- folder = Files.createTempDirectory("features").toFile();
- } catch (IOException e1) {
- throw new MojoExecutionException("Failed to create temp directory", e1);
- }
+ try {
+ folder = Files.createTempDirectory("features").toFile();
+ } catch (IOException e1) {
+ throw new MojoExecutionException("Failed to create temp directory", e1);
+ }
ArtifactId id = feature.getId();
File featureFile = new File(folder, id.toMvnId().replaceAll(":", "-") + ".json");
// TODO: Do we need to support Prototypes etc?
@@ -205,7 +206,7 @@ public class FeatureLauncherMojo extends AbstractIncludingFeatureMojo {
handleString(arguments, repositoryUrl, "-u");
handleStringList(arguments, frameworkProperties, "-D");
handleStringList(arguments, variableValues, "-V");
- if(verbose) {
+ if (verbose) {
arguments.add("-v");
}
handleFile(arguments, cacheDirectory, "-c");
@@ -221,13 +222,15 @@ public class FeatureLauncherMojo extends AbstractIncludingFeatureMojo {
void launch(String[] arguments) throws MojoExecutionException {
try {
- Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(
- "org.apache.sling.feature.launcher.impl.Main"
- );
+ Class<?> clazz = Thread.currentThread()
+ .getContextClassLoader()
+ .loadClass("org.apache.sling.feature.launcher.impl.Main");
Method main = clazz.getMethod("main", String[].class);
main.invoke(null, (Object) arguments);
} catch (ClassNotFoundException | NoSuchMethodException e) {
- throw new MojoExecutionException("Failed to load Feature Launcher or Method not available, make sure the Launcher Dependency is added to the Plugin", e);
+ throw new MojoExecutionException(
+ "Failed to load Feature Launcher or Method not available, make sure the Launcher Dependency is added to the Plugin",
+ e);
} catch (InvocationTargetException e) {
throw new MojoExecutionException("Invocation of Launcher's Main.main() failed", e.getCause());
} catch (IllegalAccessException | IllegalArgumentException e) {
@@ -236,8 +239,8 @@ public class FeatureLauncherMojo extends AbstractIncludingFeatureMojo {
}
private void handleStringList(List<String> arguments, String[] list, String parameter) {
- if(list != null) {
- for(String item: list) {
+ if (list != null) {
+ for (String item : list) {
arguments.add(parameter);
arguments.add(item);
}
@@ -245,14 +248,14 @@ public class FeatureLauncherMojo extends AbstractIncludingFeatureMojo {
}
private void handleString(List<String> arguments, String item, String parameter) {
- if(item != null && !item.isEmpty()) {
+ if (item != null && !item.isEmpty()) {
arguments.add(parameter);
arguments.add(item);
}
}
private void handleFile(List<String> arguments, File file, String parameter) {
- if(file != null) {
+ if (file != null) {
arguments.add(parameter);
arguments.add(file.getAbsolutePath());
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/FeatureSelectionConfig.java b/src/main/java/org/apache/sling/feature/maven/mojos/FeatureSelectionConfig.java
index 0711a5f..131eddd 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/FeatureSelectionConfig.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/FeatureSelectionConfig.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -26,7 +28,10 @@ import org.apache.sling.feature.maven.ProjectHelper;
public class FeatureSelectionConfig {
enum SelectionType {
- FILES_INCLUDE, CLASSIFIER, ARTIFACT, REFS_INCLUDE
+ FILES_INCLUDE,
+ CLASSIFIER,
+ ARTIFACT,
+ REFS_INCLUDE
}
static class Selection {
@@ -51,12 +56,9 @@ public class FeatureSelectionConfig {
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (getClass() != obj.getClass()) return false;
Selection other = (Selection) obj;
return Objects.equals(instruction, other.instruction) && type == other.type;
}
@@ -71,8 +73,7 @@ public class FeatureSelectionConfig {
private final List<String> filesExcludes = new ArrayList<>();
- public FeatureSelectionConfig() {
- }
+ public FeatureSelectionConfig() {}
public void setFilesInclude(final String val) {
selections.add(new Selection(SelectionType.FILES_INCLUDE, val));
@@ -92,7 +93,8 @@ public class FeatureSelectionConfig {
}
public void setIncludeArtifact(final Dependency a) {
- selections.add(new Selection(SelectionType.ARTIFACT, ProjectHelper.toArtifactId(a).toMvnId()));
+ selections.add(new Selection(
+ SelectionType.ARTIFACT, ProjectHelper.toArtifactId(a).toMvnId()));
}
public void setIncludeClassifier(final String classifier) {
@@ -120,12 +122,9 @@ public class FeatureSelectionConfig {
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (getClass() != obj.getClass()) return false;
FeatureSelectionConfig other = (FeatureSelectionConfig) obj;
return Objects.equals(filesExcludes, other.filesExcludes) && Objects.equals(selections, other.selections);
}
@@ -134,4 +133,4 @@ public class FeatureSelectionConfig {
public String toString() {
return "FeatureSelectionConfig [selections=" + selections + ", filesExcludes=" + filesExcludes + "]";
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/FeaturesDiffMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/FeaturesDiffMojo.java
index 893d328..4c49c5a 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/FeaturesDiffMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/FeaturesDiffMojo.java
@@ -1,24 +1,23 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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 static org.apache.sling.feature.diff.FeatureDiff.compareFeatures;
-import static org.apache.sling.feature.io.json.FeatureJSONWriter.write;
-
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
@@ -51,14 +50,17 @@ import org.eclipse.aether.resolution.VersionRangeResolutionException;
import org.eclipse.aether.resolution.VersionRangeResult;
import org.eclipse.aether.version.Version;
+import static org.apache.sling.feature.diff.FeatureDiff.compareFeatures;
+import static org.apache.sling.feature.io.json.FeatureJSONWriter.write;
+
/**
* Compares different versions of the same Feature Model.
*/
-@Mojo(name = "features-diff",
- defaultPhase = LifecyclePhase.PACKAGE,
- requiresDependencyResolution = ResolutionScope.TEST,
- threadSafe = true
-)
+@Mojo(
+ name = "features-diff",
+ defaultPhase = LifecyclePhase.PACKAGE,
+ requiresDependencyResolution = ResolutionScope.TEST,
+ threadSafe = true)
public final class FeaturesDiffMojo extends AbstractIncludingFeatureMojo {
@Parameter
@@ -79,7 +81,8 @@ public final class FeaturesDiffMojo extends AbstractIncludingFeatureMojo {
final Collection<Feature> features = getSelectedFeatures(selection).values();
if (features.isEmpty()) {
- getLog().debug("There are no assciated Feature files to current project, plugin execution will be interrupted");
+ getLog().debug(
+ "There are no assciated Feature files to current project, plugin execution will be interrupted");
return;
}
@@ -104,24 +107,23 @@ public final class FeaturesDiffMojo extends AbstractIncludingFeatureMojo {
getLog().info("Comparing current " + current + " to previous " + previous);
- Feature featureDiff = compareFeatures(new DiffRequest()
- .setPrevious(previous)
- .setCurrent(current));
+ Feature featureDiff =
+ compareFeatures(new DiffRequest().setPrevious(previous).setCurrent(current));
- File outputDiffFile = new File(mainOutputDir, featureDiff.getId().getClassifier().concat(".json"));
+ File outputDiffFile =
+ new File(mainOutputDir, featureDiff.getId().getClassifier().concat(".json"));
getLog().info("Rendering differences to file " + outputDiffFile);
try (FileWriter writer = new FileWriter(outputDiffFile)) {
write(writer, featureDiff);
} catch (IOException e) {
- throw new MojoExecutionException("An error occurred while serializing Feature diff to " + outputDiffFile, e);
+ throw new MojoExecutionException(
+ "An error occurred while serializing Feature diff to " + outputDiffFile, e);
}
- projectHelper.attachArtifact(project,
- FeatureConstants.PACKAGING_FEATURE,
- featureDiff.getId().getClassifier(),
- outputDiffFile);
+ projectHelper.attachArtifact(
+ project, FeatureConstants.PACKAGING_FEATURE, featureDiff.getId().getClassifier(), outputDiffFile);
}
private Feature getPreviousFeature(Feature current) throws MojoExecutionException, MojoFailureException {
@@ -132,20 +134,24 @@ public final class FeaturesDiffMojo extends AbstractIncludingFeatureMojo {
throw new MojoFailureException("Invalid comparison version: " + e.getMessage());
}
- org.eclipse.aether.artifact.Artifact previousArtifact = new DefaultArtifact(current.getId().getGroupId(),
- current.getId().getArtifactId(),
- current.getId().getType(),
- current.getId().getClassifier(),
- comparisonVersion);
+ org.eclipse.aether.artifact.Artifact previousArtifact = new DefaultArtifact(
+ current.getId().getGroupId(),
+ current.getId().getArtifactId(),
+ current.getId().getType(),
+ current.getId().getClassifier(),
+ comparisonVersion);
try {
-
+
if (!range.isSelectedVersionKnown(RepositoryUtils.toArtifact(previousArtifact))) {
getLog().debug("Searching for versions in range: " + comparisonVersion);
- VersionRangeRequest vrr = new VersionRangeRequest(previousArtifact, project.getRemoteProjectRepositories(), null);
+ VersionRangeRequest vrr =
+ new VersionRangeRequest(previousArtifact, project.getRemoteProjectRepositories(), null);
VersionRangeResult vrResult = repoSystem.resolveVersionRange(mavenSession.getRepositorySession(), vrr);
// filter out snapshots
- Optional<Version> version = vrResult.getVersions().stream().filter(v -> !ArtifactUtils.isSnapshot(v.toString())).reduce((first, second) -> second);
+ Optional<Version> version = vrResult.getVersions().stream()
+ .filter(v -> !ArtifactUtils.isSnapshot(v.toString()))
+ .reduce((first, second) -> second);
previousArtifact.setVersion(version.map(Version::toString).orElse(null));
}
} catch (OverConstrainedVersionException ocve) {
@@ -161,8 +167,10 @@ public final class FeaturesDiffMojo extends AbstractIncludingFeatureMojo {
File featureFile = null;
try {
- ArtifactRequest artifactRequest = new ArtifactRequest(previousArtifact, project.getRemoteProjectRepositories(), null);
- ArtifactResult artifactResult = repoSystem.resolveArtifact(mavenSession.getRepositorySession(), artifactRequest);
+ ArtifactRequest artifactRequest =
+ new ArtifactRequest(previousArtifact, project.getRemoteProjectRepositories(), null);
+ ArtifactResult artifactResult =
+ repoSystem.resolveArtifact(mavenSession.getRepositorySession(), artifactRequest);
featureFile = artifactResult.getArtifact().getFile();
} catch (org.eclipse.aether.resolution.ArtifactResolutionException e) {
getLog().warn("Artifact " + previousArtifact + " cannot be resolved : " + e.getMessage(), e);
@@ -175,8 +183,8 @@ public final class FeaturesDiffMojo extends AbstractIncludingFeatureMojo {
try (FileReader reader = new FileReader(featureFile)) {
return FeatureJSONReader.read(reader, featureFile.getAbsolutePath());
} catch (IOException e) {
- throw new MojoExecutionException("An error occurred while reading the " + featureFile + " Feature file:", e);
+ throw new MojoExecutionException(
+ "An error occurred while reading the " + featureFile + " Feature file:", e);
}
}
-
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/IncludeArtifactMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/IncludeArtifactMojo.java
index 8696676..58b772c 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/IncludeArtifactMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/IncludeArtifactMojo.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -68,9 +70,11 @@ import org.apache.sling.feature.maven.ProjectHelper;
* allows to add extension files like 'repoinit' etc to be added to provide them with
* the module.
*/
-@Mojo(name = "include-artifact", defaultPhase = LifecyclePhase.PREPARE_PACKAGE, requiresDependencyResolution = ResolutionScope.COMPILE,
- threadSafe = true
- )
+@Mojo(
+ name = "include-artifact",
+ defaultPhase = LifecyclePhase.PREPARE_PACKAGE,
+ requiresDependencyResolution = ResolutionScope.COMPILE,
+ threadSafe = true)
public class IncludeArtifactMojo extends AbstractIncludingFeatureMojo {
public static final String CFG_CLASSIFIER = "includeArtifactClassifier";
@@ -138,7 +142,8 @@ public class IncludeArtifactMojo extends AbstractIncludingFeatureMojo {
Feature found = null;
String key = null;
for (final Map.Entry<String, Feature> entry : featuresMap.entrySet()) {
- if (includeArtifactClassifier != null && includeArtifactClassifier.equals(entry.getValue().getId().getClassifier())) {
+ if (includeArtifactClassifier != null
+ && includeArtifactClassifier.equals(entry.getValue().getId().getClassifier())) {
key = entry.getKey();
found = entry.getValue();
break;
@@ -146,21 +151,29 @@ public class IncludeArtifactMojo extends AbstractIncludingFeatureMojo {
}
File file = null;
if (found == null) {
- found = new Feature(new ArtifactId(this.project.getGroupId(), this.project.getArtifactId(),
- this.project.getVersion(), includeArtifactClassifier, FeatureConstants.PACKAGING_FEATURE));
+ found = new Feature(new ArtifactId(
+ this.project.getGroupId(),
+ this.project.getArtifactId(),
+ this.project.getVersion(),
+ includeArtifactClassifier,
+ FeatureConstants.PACKAGING_FEATURE));
file = new File(
- this.getTmpDir(),
- "feature" + (includeArtifactClassifier == null ? "" : "-" + includeArtifactClassifier) + ".json");
+ this.getTmpDir(),
+ "feature" + (includeArtifactClassifier == null ? "" : "-" + includeArtifactClassifier) + ".json");
key = file.getAbsolutePath();
ProjectHelper.getFeatures(this.project).put(key, found);
ProjectHelper.getAssembledFeatures(this.project).put(key, found);
}
- final Artifact art = new Artifact(new ArtifactId(this.project.getGroupId(), this.project.getArtifactId(),
- this.project.getVersion(), includeClassifier, includeType != null ? includeType : this.project.getArtifact().getType()));
+ final Artifact art = new Artifact(new ArtifactId(
+ this.project.getGroupId(),
+ this.project.getArtifactId(),
+ this.project.getVersion(),
+ includeClassifier,
+ includeType != null ? includeType : this.project.getArtifact().getType()));
- if(jarStartOrder > 0) {
+ if (jarStartOrder > 0) {
art.setStartOrder(jarStartOrder);
}
@@ -169,13 +182,15 @@ public class IncludeArtifactMojo extends AbstractIncludingFeatureMojo {
}
includeArtifact(found, includeArtifactExtension, art);
- includeArtifact(ProjectHelper.getAssembledFeatures(this.project).get(key), includeArtifactExtension,
+ includeArtifact(
+ ProjectHelper.getAssembledFeatures(this.project).get(key),
+ includeArtifactExtension,
art.copy(art.getId()));
addDependencies(found);
if (file != null) {
- try ( final Writer writer = new FileWriter(file)) {
+ try (final Writer writer = new FileWriter(file)) {
FeatureJSONWriter.write(writer, found);
} catch (final IOException ioe) {
throw new MojoExecutionException("Unable to write feature", ioe);
@@ -203,15 +218,18 @@ public class IncludeArtifactMojo extends AbstractIncludingFeatureMojo {
private void addDependencies(Feature feature) {
// Add Dependencies if configured so
- for(String includeDependencyScope: includeDependenciesWithScope) {
+ for (String includeDependencyScope : includeDependenciesWithScope) {
List<Dependency> dependencies = project.getDependencies();
- for(Dependency dependency: dependencies) {
- if(includeDependencyScope.equals(dependency.getScope())) {
+ for (Dependency dependency : dependencies) {
+ if (includeDependencyScope.equals(dependency.getScope())) {
ArtifactId id = new ArtifactId(
- dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), dependency.getClassifier(), dependency.getType()
- );
+ dependency.getGroupId(),
+ dependency.getArtifactId(),
+ dependency.getVersion(),
+ dependency.getClassifier(),
+ dependency.getType());
Artifact artifact = new Artifact(id);
- if(bundlesStartOrder >= 0) {
+ if (bundlesStartOrder >= 0) {
artifact.setStartOrder(bundlesStartOrder);
}
feature.getBundles().add(artifact);
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/InfoMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/InfoMojo.java
index 388c62b..412fd4d 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/InfoMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/InfoMojo.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -137,29 +139,32 @@ public class InfoMojo extends AbstractIncludingFeatureMojo {
public void execute() throws MojoExecutionException, MojoFailureException {
final boolean isStandalone = "standalone-pom".equals(project.getArtifactId());
- if ( outputExportedPackages != null ) {
+ if (outputExportedPackages != null) {
getLog().warn("Deprecated configuration 'outputExportedPackages' is used. Please use 'reports' instead.");
}
- if ( featureFile != null ) {
+ if (featureFile != null) {
getLog().warn("Deprecated configuration 'featureFile' is used. Change to 'infoFeatureFiles'");
- if ( infoFeatureFiles == null ) {
+ if (infoFeatureFiles == null) {
infoFeatureFiles = featureFile.getAbsolutePath();
} else {
infoFeatureFiles = infoFeatureFiles.concat(",").concat(featureFile.getAbsolutePath());
}
}
- if ( isStandalone && infoFeatureFiles == null ) {
- throw new MojoExecutionException("Required configuration for standalone execution is missing. Please specify 'infoFeatureFiles'.");
+ if (isStandalone && infoFeatureFiles == null) {
+ throw new MojoExecutionException(
+ "Required configuration for standalone execution is missing. Please specify 'infoFeatureFiles'.");
}
OutputFormat format = OutputFormat.FILE;
try {
format = OutputFormat.valueOf(outputFormat.toUpperCase());
- } catch ( final IllegalArgumentException iae) {
- throw new MojoExecutionException("Invalid value for 'outputFormat', allowed values are file, log or singlefile, configured : ".concat(outputFormat));
+ } catch (final IllegalArgumentException iae) {
+ throw new MojoExecutionException(
+ "Invalid value for 'outputFormat', allowed values are file, log or singlefile, configured : "
+ .concat(outputFormat));
}
final List<Reporter> reporters = getReporters(this.reports);
- if ( reporters.isEmpty() ) {
+ if (reporters.isEmpty()) {
getLog().warn("No reporters specified.");
return;
}
@@ -169,10 +174,18 @@ public class InfoMojo extends AbstractIncludingFeatureMojo {
final ArtifactProvider am = setupArtifactProvider();
final Scanner scanner = setupScanner(am);
final IncludeExcludeMatcher matcher;
- if ( this.artifactIncludesList != null && !this.artifactIncludesList.isEmpty()) {
- matcher = new IncludeExcludeMatcher(Stream.of(this.artifactIncludesList.split(",")).map(v -> v.trim()).collect(Collectors.toList()),
- this.artifactExcludesList == null ? null : Stream.of(this.artifactExcludesList.split(",")).map(v -> v.trim()).collect(Collectors.toList()),
- null, false);
+ if (this.artifactIncludesList != null && !this.artifactIncludesList.isEmpty()) {
+ matcher = new IncludeExcludeMatcher(
+ Stream.of(this.artifactIncludesList.split(","))
+ .map(v -> v.trim())
+ .collect(Collectors.toList()),
+ this.artifactExcludesList == null
+ ? null
+ : Stream.of(this.artifactExcludesList.split(","))
+ .map(v -> v.trim())
+ .collect(Collectors.toList()),
+ null,
+ false);
} else {
matcher = null;
}
@@ -205,7 +218,7 @@ public class InfoMojo extends AbstractIncludingFeatureMojo {
}
};
final Map<String, Map<String, List<String>>> allReports = new HashMap<>();
- for(final Reporter reporter : reporters) {
+ for (final Reporter reporter : reporters) {
getLog().info("Generating report ".concat(reporter.getName().concat("...")));
reporter.generateReport(ctx);
allReports.put(reporter.getName(), new HashMap<>(reportsFromSingleReporter));
@@ -213,9 +226,9 @@ public class InfoMojo extends AbstractIncludingFeatureMojo {
}
final File directory;
- if ( outputDirectory != null ) {
+ if (outputDirectory != null) {
directory = outputDirectory;
- } else if ( isStandalone ) {
+ } else if (isStandalone) {
// wired code to get the current directory, but its needed
directory = Paths.get(".").toAbsolutePath().getParent().toFile();
} else {
@@ -240,7 +253,7 @@ public class InfoMojo extends AbstractIncludingFeatureMojo {
directory.mkdirs();
allReports.entrySet().forEach(entry -> {
final List<String> result = new ArrayList<>();
- for(final List<String> value : entry.getValue().values()) {
+ for (final List<String> value : entry.getValue().values()) {
result.addAll(value);
}
Collections.sort(result);
@@ -269,7 +282,7 @@ public class InfoMojo extends AbstractIncludingFeatureMojo {
}
private List<Reporter> getReporters(final String reports) throws MojoExecutionException {
- if ( reports == null ) {
+ if (reports == null) {
throw new MojoExecutionException("No reports configured.");
}
final List<Reporter> available = new ArrayList<>();
@@ -280,9 +293,9 @@ public class InfoMojo extends AbstractIncludingFeatureMojo {
available.add(new ScriptsImportPackagesReporter());
final List<Reporter> result = new ArrayList<>();
- for(final String r : reports.split(",")) {
- for(final Reporter current : available) {
- if ( current.getName().equals(r.trim())) {
+ for (final String r : reports.split(",")) {
+ for (final Reporter current : available) {
+ if (current.getName().equals(r.trim())) {
result.add(current);
break;
}
@@ -296,17 +309,18 @@ public class InfoMojo extends AbstractIncludingFeatureMojo {
* Select the features to process
* @throws MojoExecutionException
*/
- private List<Feature> selectFeatures(final String infoFeatureFiles) throws MojoExecutionException {
+ private List<Feature> selectFeatures(final String infoFeatureFiles) throws MojoExecutionException {
final List<Feature> result = new ArrayList<>();
- if ( infoFeatureFiles != null ) {
- for(final String file : infoFeatureFiles.split(",")) {
+ if (infoFeatureFiles != null) {
+ for (final String file : infoFeatureFiles.split(",")) {
final File f = new File(file.trim());
result.add(readFeature(f));
}
} else {
checkPreconditions();
- final Map<String, Feature> features = infoFeatures == null ? this.selectAllFeatureFiles() : this.getSelectedFeatures(infoFeatures);
+ final Map<String, Feature> features =
+ infoFeatures == null ? this.selectAllFeatureFiles() : this.getSelectedFeatures(infoFeatures);
for (final Feature f : features.values()) {
result.add(f);
}
@@ -321,9 +335,11 @@ public class InfoMojo extends AbstractIncludingFeatureMojo {
public URL provide(final ArtifactId id) {
getLog().info("Searching " + id.toMvnId());
try {
- return ProjectHelper
- .getOrResolveArtifact(project, mavenSession, artifactHandlerManager, repoSystem, id)
- .getFile().toURI().toURL();
+ return ProjectHelper.getOrResolveArtifact(
+ project, mavenSession, artifactHandlerManager, repoSystem, id)
+ .getFile()
+ .toURI()
+ .toURL();
} catch (final MalformedURLException e) {
getLog().debug("Malformed url " + e.getMessage(), e);
// ignore
@@ -338,8 +354,8 @@ public class InfoMojo extends AbstractIncludingFeatureMojo {
try {
return new Scanner(am);
} catch (final IOException e) {
- throw new MojoExecutionException("A fatal error occurred while setting up the Scanner, see error cause:",
- e);
+ throw new MojoExecutionException(
+ "A fatal error occurred while setting up the Scanner, see error cause:", e);
}
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/JarDecompressor.java b/src/main/java/org/apache/sling/feature/maven/mojos/JarDecompressor.java
index ba92789..6811b31 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/JarDecompressor.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/JarDecompressor.java
@@ -1,23 +1,23 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.commons.io.FileUtils;
-
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -35,12 +35,13 @@ import java.util.zip.CRC32;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
+import org.apache.commons.io.FileUtils;
+
class JarDecompressor {
private static final int BUFFER_SIZE = 16384;
static void copyDecompress(File in, File out) throws IOException {
- if (decompress(in, out))
- return;
+ if (decompress(in, out)) return;
// It's a signed jar, just copy it as-is...
FileUtils.copyFile(in, out);
@@ -49,7 +50,7 @@ class JarDecompressor {
// Returns false if the input file is a signed jar which should not be decompressed
private static boolean decompress(File in, File out) throws IOException {
try (JarInputStream jis = new JarInputStream(new FileInputStream(in));
- ZipOutputStream jos = new JarOutputStream(new FileOutputStream(out))) {
+ ZipOutputStream jos = new JarOutputStream(new FileOutputStream(out))) {
jos.setMethod(ZipOutputStream.STORED);
writeManifestIfPresent(jis, jos);
@@ -57,11 +58,9 @@ class JarDecompressor {
byte[] buffer = new byte[BUFFER_SIZE];
JarEntry je = null;
while ((je = jis.getNextJarEntry()) != null) {
- if (JarFile.MANIFEST_NAME.equals(je.getName()))
- continue;
+ if (JarFile.MANIFEST_NAME.equals(je.getName())) continue;
- if (je.getName().startsWith("META-INF/") &&
- je.getName().endsWith(".SF")) {
+ if (je.getName().startsWith("META-INF/") && je.getName().endsWith(".SF")) {
// This is a signed jar, don't decompress it.
return false;
}
@@ -96,7 +95,6 @@ class JarDecompressor {
if (!tmpFile.delete()) {
throw new IOException("Could not delete temp file " + tmpFile);
}
-
}
}
return true;
@@ -148,8 +146,7 @@ class JarDecompressor {
private static void writeManifestIfPresent(JarInputStream jis, ZipOutputStream jos) throws IOException {
Manifest manifest = jis.getManifest();
- if (manifest == null)
- return;
+ if (manifest == null) return;
ZipEntry e = new ZipEntry(JarFile.MANIFEST_NAME);
crcEntryManifestEntry(e, manifest);
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/Repository.java b/src/main/java/org/apache/sling/feature/maven/mojos/Repository.java
index a013f56..e9db6d9 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/Repository.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/Repository.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/RepositoryMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/RepositoryMojo.java
index 9280324..f943667 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/RepositoryMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/RepositoryMojo.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -35,8 +37,7 @@ import org.apache.sling.feature.Feature;
name = "repository",
defaultPhase = LifecyclePhase.PACKAGE,
requiresDependencyResolution = ResolutionScope.TEST,
- threadSafe = true
- )
+ threadSafe = true)
public class RepositoryMojo extends AbstractRepositoryMojo {
@Parameter
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/Scan.java b/src/main/java/org/apache/sling/feature/maven/mojos/Scan.java
index 1c2435a..f7c9796 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/Scan.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/Scan.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -51,15 +53,15 @@ public class Scan extends FeatureSelectionConfig {
return this.excludeTasks.isEmpty() ? null : this.excludeTasks;
}
- public Map<String, Map<String,String>> getTaskConfiguration() {
- final Map<String, Map<String,String>> result = new HashMap<>();
+ public Map<String, Map<String, String>> getTaskConfiguration() {
+ final Map<String, Map<String, String>> result = new HashMap<>();
for (final Map.Entry<String, Properties> entry : taskConfiguration.entrySet()) {
result.put(entry.getKey(), ProjectHelper.propertiesToMap(entry.getValue()));
}
return result;
}
- public void setTaskConfiguration(String task, Map<String,String> config) {
+ public void setTaskConfiguration(String task, Map<String, String> config) {
Properties p = new Properties();
config.forEach(p::setProperty);
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/UpdateVersionsMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/UpdateVersionsMojo.java
index 6f0b834..160a979 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/UpdateVersionsMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/UpdateVersionsMojo.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -67,10 +69,7 @@ import org.codehaus.plexus.util.StringUtils;
/**
* Update the bundles/artifact versions
*/
-@Mojo(
- name = "update-feature-versions",
- threadSafe = true
- )
+@Mojo(name = "update-feature-versions", threadSafe = true)
public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
private static final int INFO_PAD_SIZE = 95;
@@ -141,24 +140,25 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
private Map<String, Feature> getFeatures() throws MojoExecutionException {
final String[] selection = this.classifiers == null ? null : this.classifiers.split(",");
final Map<String, Feature> features = new LinkedHashMap<>();
- for (final Map.Entry<String, Feature> entry : this.selectAllFeatureFiles().entrySet()) {
+ for (final Map.Entry<String, Feature> entry :
+ this.selectAllFeatureFiles().entrySet()) {
boolean selected = true;
- if ( selection != null ) {
+ if (selection != null) {
selected = false;
final String classifier = entry.getValue().getId().getClassifier();
- for(final String c : selection) {
- if ( classifier == null ) {
- if ( ":".equals(c) ) {
+ for (final String c : selection) {
+ if (classifier == null) {
+ if (":".equals(c)) {
selected = true;
break;
}
- } else if ( classifier.trim().equals(c)) {
+ } else if (classifier.trim().equals(c)) {
selected = true;
break;
}
}
}
- if ( selected ) {
+ if (selected) {
features.put(entry.getKey(), ProjectHelper.getFeatures(project).get(entry.getKey()));
}
}
@@ -174,9 +174,8 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
* @param artifacts The artifacts to check
* @param cfg The configuration
*/
- private void addDependencies(final Set<ArtifactHolder> dependencies,
- final List<Artifact> artifacts,
- final UpdateConfig cfg) {
+ private void addDependencies(
+ final Set<ArtifactHolder> dependencies, final List<Artifact> artifacts, final UpdateConfig cfg) {
for (final Artifact a : artifacts) {
final String include = shouldHandle(a.getId(), cfg);
if (include != null) {
@@ -216,7 +215,7 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
// we need to read the raw file
try (final Reader r = new FileReader(new File(fileName))) {
final String json = JSONFeatures.read(r, JSONFeatures.PLACEHOLDER_ID, fileName);
- try ( final Reader featureReader = new StringReader(json)) {
+ try (final Reader featureReader = new StringReader(json)) {
return FeatureJSONReader.read(featureReader, fileName);
}
} catch (final IOException e) {
@@ -296,8 +295,8 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
throw new MojoExecutionException("Unable to write feature file " + entry.getValue(), e);
}
}
- }
- }
+ }
+ }
boolean printedHeader = false;
for (final Map.Entry<String, UpdateResult> entry : results.entrySet()) {
@@ -339,7 +338,8 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
if (!entry.getValue().propertyUpdates.isEmpty()) {
getLog().info(" The following properties in the pom should be updated:");
- for (final Map.Entry<String, String> prop : entry.getValue().propertyUpdates.entrySet()) {
+ for (final Map.Entry<String, String> prop :
+ entry.getValue().propertyUpdates.entrySet()) {
final String left = " Property '" + prop.getKey() + "' to ...";
final String right = prop.getValue();
if (right.length() + left.length() > INFO_PAD_SIZE) {
@@ -394,7 +394,7 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
boolean match = false;
int index = 0;
- for(final String[] m : matches) {
+ for (final String[] m : matches) {
match = match(id.getGroupId(), m[0]);
if (match && m.length > 1) {
match = match(id.getArtifactId(), m[1]);
@@ -429,30 +429,29 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
return null;
}
- private String update(final Artifact artifact, final Set<ArtifactHolder> updates)
- throws MojoExecutionException {
- getLog().debug("Searching for updates of " + artifact.getId().toMvnId());
+ private String update(final Artifact artifact, final Set<ArtifactHolder> updates) throws MojoExecutionException {
+ getLog().debug("Searching for updates of " + artifact.getId().toMvnId());
// check updates
String found = null;
for (final ArtifactHolder entry : updates) {
- if (artifact.getId().equals(entry.getArtifact().getId()) ) {
+ if (artifact.getId().equals(entry.getArtifact().getId())) {
found = entry.getUpdate();
break;
}
- }
+ }
- String updated = null;
- if ( found != null ) {
+ String updated = null;
+ if (found != null) {
getLog().debug("Updating " + artifact.getId().toMvnId() + " to " + found);
updated = found;
- } else {
+ } else {
getLog().debug("No newer version found for " + artifact.getId().toMvnId());
}
- return updated;
- }
+ return updated;
+ }
public static final class UpdateConfig {
public List<String[]> includes;
@@ -463,21 +462,25 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
Set<ArtifactHolder> updateInfos;
public Scope defaultScope;
- }
+ }
- public static final class ArtifactUpdate {
- public Extension extension;
- public Artifact artifact;
- public String newVersion;
- }
+ public static final class ArtifactUpdate {
+ public Extension extension;
+ public Artifact artifact;
+ public String newVersion;
+ }
public static final class UpdateResult {
public List<ArtifactUpdate> updates;
public Map<String, String> propertyUpdates = new HashMap<>();
}
- private boolean updateVersions(final String fileName, final Feature rawFeature, final UpdateResult result,
- final Map<String, Set<String>> globalPropertyUpdates) throws MojoExecutionException {
+ private boolean updateVersions(
+ final String fileName,
+ final Feature rawFeature,
+ final UpdateResult result,
+ final Map<String, Set<String>> globalPropertyUpdates)
+ throws MojoExecutionException {
// update artifacts
final Iterator<ArtifactUpdate> iter = result.updates.iterator();
while (iter.hasNext()) {
@@ -487,7 +490,10 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
if (update.extension == null) {
container = rawFeature.getBundles();
} else {
- container = rawFeature.getExtensions().getByName(update.extension.getName()).getArtifacts();
+ container = rawFeature
+ .getExtensions()
+ .getByName(update.extension.getName())
+ .getArtifacts();
}
final int pos = container.indexOf(update.artifact);
final Artifact oldArtifact = pos == -1 ? null : container.get(pos);
@@ -496,12 +502,17 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
final Artifact same = container.getSame(update.artifact.getId());
boolean found = same != null;
if (same != null) {
- if (!same.getId().getVersion().startsWith("${") || !same.getId().getVersion().endsWith("}")) {
+ if (!same.getId().getVersion().startsWith("${")
+ || !same.getId().getVersion().endsWith("}")) {
found = false;
} else {
- final String propName = same.getId().getVersion().substring(2,
- same.getId().getVersion().length() - 1);
- if (!update.artifact.getId().getVersion().equals(this.project.getProperties().get(propName))) {
+ final String propName = same.getId()
+ .getVersion()
+ .substring(2, same.getId().getVersion().length() - 1);
+ if (!update.artifact
+ .getId()
+ .getVersion()
+ .equals(this.project.getProperties().get(propName))) {
found = false;
} else {
Set<String> versions = globalPropertyUpdates.get(propName);
@@ -521,7 +532,8 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
iter.remove();
} else {
// oldArtifact is not null (removeExact returned true)
- final Artifact newArtifact = new Artifact(update.artifact.getId().changeVersion(update.newVersion));
+ final Artifact newArtifact =
+ new Artifact(update.artifact.getId().changeVersion(update.newVersion));
newArtifact.getMetadata().putAll(oldArtifact.getMetadata());
container.add(pos, newArtifact);
}
@@ -539,8 +551,8 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
* @param cfg
* @throws MojoExecutionException
*/
- private void addUpdates(final List<ArtifactUpdate> updates, final Extension ext, final Artifacts artifacts,
- final UpdateConfig cfg)
+ private void addUpdates(
+ final List<ArtifactUpdate> updates, final Extension ext, final Artifacts artifacts, final UpdateConfig cfg)
throws MojoExecutionException {
for (final Artifact a : artifacts) {
if (shouldHandle(a.getId(), cfg) != null) {
@@ -579,15 +591,13 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
}
/**
- * Create a holder
+ * Create a holder
* @param artifact The artifact
* @param scope The scope
* @param newVersion The optional new version
* @return The holder
*/
- private ArtifactHolder createArtifactHolder(final Artifact artifact,
- final Scope scope,
- final String newVersion) {
+ private ArtifactHolder createArtifactHolder(final Artifact artifact, final Scope scope, final String newVersion) {
return new ArtifactHolder(artifact, scope, newVersion);
}
@@ -595,38 +605,44 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
* Lookup the version updates
* @param dependencies The set of dependencies to check for version updates
*/
- private void lookupVersionUpdates( final Set<ArtifactHolder> dependencies )
- throws MojoExecutionException {
+ private void lookupVersionUpdates(final Set<ArtifactHolder> dependencies) throws MojoExecutionException {
- final List<Callable<Void>> requestsForDetails = new ArrayList<>( dependencies.size() );
- for ( final ArtifactHolder dependency : dependencies ) {
- requestsForDetails.add( () -> {
+ final List<Callable<Void>> requestsForDetails = new ArrayList<>(dependencies.size());
+ for (final ArtifactHolder dependency : dependencies) {
+ requestsForDetails.add(() -> {
final ArtifactId id = dependency.getArtifact().getId();
- getLog().debug( "Checking " + id.getGroupId() + ":" + id.getArtifactId() + " for updates newer than " + id.getVersion() );
-
- final ArtifactHandler handler = artifactHandlerManager.getArtifactHandler( id.getType() );
-
- final org.apache.maven.artifact.Artifact artifact = new DefaultArtifact( id.getGroupId(), id.getArtifactId(), id.getVersion(), org.apache.maven.artifact.Artifact.SCOPE_PROVIDED,
- id.getType(), id.getClassifier(), handler);
- dependency.setVersions(artifactMetadataSource.retrieveAvailableVersions( artifact,
- this.mavenSession.getLocalRepository(), this.remoteArtifactRepositories ));
+ getLog().debug("Checking " + id.getGroupId() + ":" + id.getArtifactId() + " for updates newer than "
+ + id.getVersion());
+
+ final ArtifactHandler handler = artifactHandlerManager.getArtifactHandler(id.getType());
+
+ final org.apache.maven.artifact.Artifact artifact = new DefaultArtifact(
+ id.getGroupId(),
+ id.getArtifactId(),
+ id.getVersion(),
+ org.apache.maven.artifact.Artifact.SCOPE_PROVIDED,
+ id.getType(),
+ id.getClassifier(),
+ handler);
+ dependency.setVersions(artifactMetadataSource.retrieveAvailableVersions(
+ artifact, this.mavenSession.getLocalRepository(), this.remoteArtifactRepositories));
return null;
});
}
// Lookup details in parallel...
- final ExecutorService executor = Executors.newFixedThreadPool( 5 );
+ final ExecutorService executor = Executors.newFixedThreadPool(5);
try {
- final List<Future<Void>> responseForDetails = executor.invokeAll( requestsForDetails );
+ final List<Future<Void>> responseForDetails = executor.invokeAll(requestsForDetails);
// Construct the final results...
- for ( final Future<Void> details : responseForDetails ) {
+ for (final Future<Void> details : responseForDetails) {
details.get();
}
- } catch ( final ExecutionException | InterruptedException ie ) {
- throw new MojoExecutionException( "Unable to acquire metadata for dependencies " + dependencies
- + ": " + ie.getMessage(), ie );
+ } catch (final ExecutionException | InterruptedException ie) {
+ throw new MojoExecutionException(
+ "Unable to acquire metadata for dependencies " + dependencies + ": " + ie.getMessage(), ie);
} finally {
executor.shutdownNow();
}
@@ -677,7 +693,7 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
* The current version.
*/
private final ArtifactVersion currentVersion;
-
+
/**
* The update scope to use
*/
@@ -699,7 +715,7 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
* @param updateScope The update scope.
* @param newVersion optional new version info
*/
- public ArtifactHolder( final Artifact artifact, final Scope updateScope, final String newVersion ) {
+ public ArtifactHolder(final Artifact artifact, final Scope updateScope, final String newVersion) {
this.artifact = artifact;
this.updateScope = updateScope;
this.currentVersion = new DefaultArtifactVersion(artifact.getId().getVersion());
@@ -720,71 +736,74 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
*/
public void setVersions(final List<ArtifactVersion> versions) {
// filter out snapshots
- for ( final ArtifactVersion candidate : versions ) {
- if ( ArtifactUtils.isSnapshot( candidate.toString() ) ) {
+ for (final ArtifactVersion candidate : versions) {
+ if (ArtifactUtils.isSnapshot(candidate.toString())) {
continue;
}
- this.versions.add( candidate );
+ this.versions.add(candidate);
}
}
- private final ArtifactVersion getNewestVersion( ArtifactVersion lowerBound,
- ArtifactVersion upperBound,
- boolean includeLower, boolean includeUpper ) {
+ private final ArtifactVersion getNewestVersion(
+ ArtifactVersion lowerBound, ArtifactVersion upperBound, boolean includeLower, boolean includeUpper) {
ArtifactVersion latest = null;
- for ( final ArtifactVersion candidate : this.versions ) {
- final int lower = lowerBound == null ? -1 : lowerBound.compareTo( candidate );
- final int upper = upperBound == null ? +1 : upperBound.compareTo( candidate );
- if ( lower > 0 || upper < 0 ) {
+ for (final ArtifactVersion candidate : this.versions) {
+ final int lower = lowerBound == null ? -1 : lowerBound.compareTo(candidate);
+ final int upper = upperBound == null ? +1 : upperBound.compareTo(candidate);
+ if (lower > 0 || upper < 0) {
continue;
}
- if ( ( !includeLower && lower == 0 ) || ( !includeUpper && upper == 0 ) ) {
+ if ((!includeLower && lower == 0) || (!includeUpper && upper == 0)) {
continue;
}
- if ( ArtifactUtils.isSnapshot( candidate.toString() ) ) {
+ if (ArtifactUtils.isSnapshot(candidate.toString())) {
continue;
}
- if ( latest == null ) {
+ if (latest == null) {
latest = candidate;
- } else if ( latest.compareTo( candidate ) < 0 ) {
+ } else if (latest.compareTo(candidate) < 0) {
latest = candidate;
}
-
}
return latest;
}
public final String getUpdate() {
- if ( this.newVersion != null ) {
+ if (this.newVersion != null) {
return this.newVersion;
}
ArtifactVersion v = null;
- switch ( updateScope ) {
- case SUBINCREMENTAL :
- v = getSegmentCount( currentVersion ) < 3 ? null
- : this.getNewestVersion( currentVersion,
- incrementSegment( currentVersion, 2 ),
- false, false );
+ switch (updateScope) {
+ case SUBINCREMENTAL:
+ v = getSegmentCount(currentVersion) < 3
+ ? null
+ : this.getNewestVersion(currentVersion, incrementSegment(currentVersion, 2), false, false);
break;
- case INCREMENTAL :
- v = getSegmentCount( currentVersion ) < 3 ? null
- : this.getNewestVersion( incrementSegment( currentVersion, 2 ),
- incrementSegment( currentVersion, 1 ),
- true, false );
+ case INCREMENTAL:
+ v = getSegmentCount(currentVersion) < 3
+ ? null
+ : this.getNewestVersion(
+ incrementSegment(currentVersion, 2),
+ incrementSegment(currentVersion, 1),
+ true,
+ false);
break;
- case MINOR :
- v = getSegmentCount( currentVersion ) < 2 ? null
- : this.getNewestVersion( incrementSegment( currentVersion, 1 ),
- incrementSegment( currentVersion, 0 ),
- true, false );
+ case MINOR:
+ v = getSegmentCount(currentVersion) < 2
+ ? null
+ : this.getNewestVersion(
+ incrementSegment(currentVersion, 1),
+ incrementSegment(currentVersion, 0),
+ true,
+ false);
break;
- case MAJOR :
- v = getSegmentCount( currentVersion ) < 1 ? null
- : this.getNewestVersion( incrementSegment( currentVersion, 0 ),
- null, true, false );
+ case MAJOR:
+ v = getSegmentCount(currentVersion) < 1
+ ? null
+ : this.getNewestVersion(incrementSegment(currentVersion, 0), null, true, false);
break;
- case ANY :
- v = this.getNewestVersion( currentVersion, null, false, false );
+ case ANY:
+ v = this.getNewestVersion(currentVersion, null, false, false);
break;
}
return v != null ? v.toString() : null;
@@ -796,71 +815,71 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
}
}
- private static final Pattern SNAPSHOT_PATTERN = Pattern.compile( "(-((\\d{8}\\.\\d{6})-(\\d+))|(SNAPSHOT))$" );
+ private static final Pattern SNAPSHOT_PATTERN = Pattern.compile("(-((\\d{8}\\.\\d{6})-(\\d+))|(SNAPSHOT))$");
- private static final int getSegmentCount( final ArtifactVersion v ) {
- if ( v == null ) {
+ private static final int getSegmentCount(final ArtifactVersion v) {
+ if (v == null) {
return 0;
}
- if ( ArtifactUtils.isSnapshot( v.toString() ) ) {
- return innerGetSegmentCount( stripSnapshot( v ) );
+ if (ArtifactUtils.isSnapshot(v.toString())) {
+ return innerGetSegmentCount(stripSnapshot(v));
}
- return innerGetSegmentCount( v );
+ return innerGetSegmentCount(v);
}
- private static ArtifactVersion incrementSegment( final ArtifactVersion v, final int segment ) {
- if ( ArtifactUtils.isSnapshot( v.toString() ) ) {
- return copySnapshot( v, innerIncrementSegment( stripSnapshot( v ), segment ) );
+ private static ArtifactVersion incrementSegment(final ArtifactVersion v, final int segment) {
+ if (ArtifactUtils.isSnapshot(v.toString())) {
+ return copySnapshot(v, innerIncrementSegment(stripSnapshot(v), segment));
}
- return innerIncrementSegment( v, segment );
+ return innerIncrementSegment(v, segment);
}
- private static int innerGetSegmentCount( final ArtifactVersion v ) {
+ private static int innerGetSegmentCount(final ArtifactVersion v) {
// if the version does not match the maven rules, then we have only one segment
// i.e. the qualifier
- if ( v.getBuildNumber() != 0 ) {
+ if (v.getBuildNumber() != 0) {
// the version was successfully parsed, and we have a build number
// have to have four segments
return 4;
}
- if ( ( v.getMajorVersion() != 0 || v.getMinorVersion() != 0 || v.getIncrementalVersion() != 0 )
- && v.getQualifier() != null ) {
+ if ((v.getMajorVersion() != 0 || v.getMinorVersion() != 0 || v.getIncrementalVersion() != 0)
+ && v.getQualifier() != null) {
// the version was successfully parsed, and we have a qualifier
// have to have four segments
return 4;
}
final String version = v.toString();
- if ( version.indexOf( '-' ) != -1 ) {
+ if (version.indexOf('-') != -1) {
// the version has parts and was not parsed successfully
// have to have one segment
- return version.equals( v.getQualifier() ) ? 1 : 4;
+ return version.equals(v.getQualifier()) ? 1 : 4;
}
- if ( version.indexOf( '.' ) != -1 ) {
+ if (version.indexOf('.') != -1) {
// the version has parts and was not parsed successfully
// have to have one segment
- return version.equals( v.getQualifier() ) ? 1 : 3;
+ return version.equals(v.getQualifier()) ? 1 : 3;
}
- if ( StringUtils.isEmpty( version ) ) {
+ if (StringUtils.isEmpty(version)) {
return 3;
}
try {
- Integer.parseInt( version );
+ Integer.parseInt(version);
return 3;
- } catch ( final NumberFormatException e ) {
+ } catch (final NumberFormatException e) {
return 1;
}
}
- private static ArtifactVersion innerIncrementSegment( final ArtifactVersion v, final int segment ) {
- int segmentCount = innerGetSegmentCount( v );
- if ( segment < 0 || segment >= segmentCount ) {
- throw new IllegalArgumentException( v.toString() );
+ private static ArtifactVersion innerIncrementSegment(final ArtifactVersion v, final int segment) {
+ int segmentCount = innerGetSegmentCount(v);
+ if (segment < 0 || segment >= segmentCount) {
+ throw new IllegalArgumentException(v.toString());
}
String version = v.toString();
- if ( segmentCount == 1 ) {
+ if (segmentCount == 1) {
// only the qualifier
- version = alphaNumIncrement( version );
- return new DefaultArtifactVersion( version );
+ version = alphaNumIncrement(version);
+ return new DefaultArtifactVersion(version);
} else {
int major = v.getMajorVersion();
int minor = v.getMinorVersion();
@@ -868,15 +887,15 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
int build = v.getBuildNumber();
String qualifier = v.getQualifier();
- int minorIndex = version.indexOf( '.' );
+ int minorIndex = version.indexOf('.');
boolean haveMinor = minorIndex != -1;
- int incrementalIndex = haveMinor ? version.indexOf( '.', minorIndex + 1 ) : -1;
+ int incrementalIndex = haveMinor ? version.indexOf('.', minorIndex + 1) : -1;
boolean haveIncremental = incrementalIndex != -1;
- int buildIndex = version.indexOf( '-' );
+ int buildIndex = version.indexOf('-');
boolean haveBuild = buildIndex != -1 && qualifier == null;
boolean haveQualifier = buildIndex != -1 && qualifier != null;
- switch ( segment ) {
+ switch (segment) {
case 0:
major++;
minor = 0;
@@ -888,7 +907,7 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
minor++;
incremental = 0;
build = 0;
- if ( haveQualifier && qualifier.endsWith( "SNAPSHOT" ) ) {
+ if (haveQualifier && qualifier.endsWith("SNAPSHOT")) {
qualifier = "SNAPSHOT";
}
break;
@@ -898,82 +917,84 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
qualifier = null;
break;
case 3:
- if ( haveQualifier ) {
- qualifier = qualifierIncrement( qualifier );
+ if (haveQualifier) {
+ qualifier = qualifierIncrement(qualifier);
} else {
build++;
}
break;
}
final StringBuilder result = new StringBuilder();
- result.append( major );
- if ( haveMinor || minor > 0 || incremental > 0 ) {
- result.append( '.' );
- result.append( minor );
+ result.append(major);
+ if (haveMinor || minor > 0 || incremental > 0) {
+ result.append('.');
+ result.append(minor);
}
- if ( haveIncremental || incremental > 0 ) {
- result.append( '.' );
- result.append( incremental );
+ if (haveIncremental || incremental > 0) {
+ result.append('.');
+ result.append(incremental);
}
- if ( haveQualifier && qualifier != null ) {
- result.append( '-' );
- result.append( qualifier );
- } else if ( haveBuild || build > 0 ) {
- result.append( '-' );
- result.append( build );
+ if (haveQualifier && qualifier != null) {
+ result.append('-');
+ result.append(qualifier);
+ } else if (haveBuild || build > 0) {
+ result.append('-');
+ result.append(build);
}
- return new DefaultArtifactVersion( result.toString() );
+ return new DefaultArtifactVersion(result.toString());
}
}
- private static String qualifierIncrement( final String qualifier ) {
- if ( qualifier.toLowerCase().startsWith( "alpha" ) ) {
- return qualifier.substring( 0, 5 ) + alphaNumIncrement( qualifier.substring( 5 ) );
+ private static String qualifierIncrement(final String qualifier) {
+ if (qualifier.toLowerCase().startsWith("alpha")) {
+ return qualifier.substring(0, 5) + alphaNumIncrement(qualifier.substring(5));
}
- if ( qualifier.toLowerCase().startsWith( "beta" ) ) {
- return qualifier.substring( 0, 4 ) + alphaNumIncrement( qualifier.substring( 4 ) );
+ if (qualifier.toLowerCase().startsWith("beta")) {
+ return qualifier.substring(0, 4) + alphaNumIncrement(qualifier.substring(4));
}
- if ( qualifier.toLowerCase().startsWith( "milestone" ) ) {
- return qualifier.substring( 0, 8 ) + alphaNumIncrement( qualifier.substring( 8 ) );
+ if (qualifier.toLowerCase().startsWith("milestone")) {
+ return qualifier.substring(0, 8) + alphaNumIncrement(qualifier.substring(8));
}
- if ( qualifier.toLowerCase().startsWith( "cr" ) || qualifier.toLowerCase().startsWith( "rc" ) || qualifier.toLowerCase().startsWith( "sp" ) ) {
- return qualifier.substring( 0, 2 ) + alphaNumIncrement( qualifier.substring( 2 ) );
+ if (qualifier.toLowerCase().startsWith("cr")
+ || qualifier.toLowerCase().startsWith("rc")
+ || qualifier.toLowerCase().startsWith("sp")) {
+ return qualifier.substring(0, 2) + alphaNumIncrement(qualifier.substring(2));
}
- return alphaNumIncrement( qualifier );
+ return alphaNumIncrement(qualifier);
}
- private static String alphaNumIncrement( String token ) {
+ private static String alphaNumIncrement(String token) {
String newToken;
int i = token.length();
boolean done = false;
newToken = token;
- while ( !done && i > 0 ) {
+ while (!done && i > 0) {
i--;
- char c = token.charAt( i );
- if ( '0' <= c && c < '9' ) {
+ char c = token.charAt(i);
+ if ('0' <= c && c < '9') {
c++;
- newToken = newToken.substring( 0, i ) + c + ( i + 1 < newToken.length() ? newToken.substring( i + 1 ) : "" );
+ newToken = newToken.substring(0, i) + c + (i + 1 < newToken.length() ? newToken.substring(i + 1) : "");
done = true;
- } else if ( c == '9' ) {
+ } else if (c == '9') {
c = '0';
- newToken = newToken.substring( 0, i ) + c + ( i + 1 < newToken.length() ? newToken.substring( i + 1 ) : "" );
- } else if ( 'A' <= c && c < 'Z' ) {
+ newToken = newToken.substring(0, i) + c + (i + 1 < newToken.length() ? newToken.substring(i + 1) : "");
+ } else if ('A' <= c && c < 'Z') {
c++;
- newToken = newToken.substring( 0, i ) + c + ( i + 1 < newToken.length() ? newToken.substring( i + 1 ) : "" );
+ newToken = newToken.substring(0, i) + c + (i + 1 < newToken.length() ? newToken.substring(i + 1) : "");
done = true;
- } else if ( c == 'Z' ) {
+ } else if (c == 'Z') {
c = 'A';
- newToken = newToken.substring( 0, i ) + c + ( i + 1 < newToken.length() ? newToken.substring( i + 1 ) : "" );
- } else if ( 'a' <= c && c < 'z' ) {
+ newToken = newToken.substring(0, i) + c + (i + 1 < newToken.length() ? newToken.substring(i + 1) : "");
+ } else if ('a' <= c && c < 'z') {
c++;
- newToken = newToken.substring( 0, i ) + c + ( i + 1 < newToken.length() ? newToken.substring( i + 1 ) : "" );
+ newToken = newToken.substring(0, i) + c + (i + 1 < newToken.length() ? newToken.substring(i + 1) : "");
done = true;
- } else if ( c == 'z' ) {
+ } else if (c == 'z') {
c = 'a';
- newToken = newToken.substring( 0, i ) + c + ( i + 1 < newToken.length() ? newToken.substring( i + 1 ) : "" );
+ newToken = newToken.substring(0, i) + c + (i + 1 < newToken.length() ? newToken.substring(i + 1) : "");
}
}
- if ( done ) {
+ if (done) {
return newToken;
} else {
// ok this is roll-over time
@@ -981,15 +1002,15 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
boolean lastAlpha = false;
boolean lastUpper = false;
i = token.length();
- while ( !lastAlpha && !lastNumeric && i > 0 ) {
+ while (!lastAlpha && !lastNumeric && i > 0) {
i--;
- char c = token.charAt( i );
- lastAlpha = Character.isLetter( c );
- lastUpper = c == Character.toUpperCase( c );
- lastNumeric = Character.isDigit( c );
+ char c = token.charAt(i);
+ lastAlpha = Character.isLetter(c);
+ lastUpper = c == Character.toUpperCase(c);
+ lastNumeric = Character.isDigit(c);
}
- if ( lastAlpha ) {
- if ( lastUpper ) {
+ if (lastAlpha) {
+ if (lastUpper) {
return token + 'A';
}
return token + 'a';
@@ -998,25 +1019,25 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
}
}
- private static ArtifactVersion stripSnapshot( ArtifactVersion v ) {
+ private static ArtifactVersion stripSnapshot(ArtifactVersion v) {
final String version = v.toString();
- final Matcher matcher = SNAPSHOT_PATTERN.matcher( version );
- if ( matcher.find() ) {
- return new DefaultArtifactVersion( version.substring( 0, matcher.start( 1 ) - 1 ) );
+ final Matcher matcher = SNAPSHOT_PATTERN.matcher(version);
+ if (matcher.find()) {
+ return new DefaultArtifactVersion(version.substring(0, matcher.start(1) - 1));
}
return v;
}
- private static ArtifactVersion copySnapshot( ArtifactVersion source, ArtifactVersion destination ) {
- if ( ArtifactUtils.isSnapshot( destination.toString() ) ) {
- destination = stripSnapshot( destination );
+ private static ArtifactVersion copySnapshot(ArtifactVersion source, ArtifactVersion destination) {
+ if (ArtifactUtils.isSnapshot(destination.toString())) {
+ destination = stripSnapshot(destination);
}
final Pattern matchSnapshotRegex = SNAPSHOT_PATTERN;
- final Matcher matcher = matchSnapshotRegex.matcher( source.toString() );
- if ( matcher.find() ) {
- return new DefaultArtifactVersion( destination.toString() + "-" + matcher.group( 0 ) );
+ final Matcher matcher = matchSnapshotRegex.matcher(source.toString());
+ if (matcher.find()) {
+ return new DefaultArtifactVersion(destination.toString() + "-" + matcher.group(0));
} else {
- return new DefaultArtifactVersion( destination.toString() + "-SNAPSHOT" );
+ return new DefaultArtifactVersion(destination.toString() + "-SNAPSHOT");
}
}
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisConfiguration.java b/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisConfiguration.java
index b198970..9c8176f 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisConfiguration.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisConfiguration.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.apis;
@@ -31,7 +33,6 @@ import jakarta.json.JsonObject;
import jakarta.json.JsonString;
import jakarta.json.JsonValue;
import jakarta.json.JsonValue.ValueType;
-
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import org.apache.sling.feature.ArtifactId;
@@ -165,8 +166,8 @@ public class ApisConfiguration {
public ApisConfiguration(final Feature feature) throws MojoExecutionException {
// check for extension
final Extension ext = feature.getExtensions().getByName(EXTENSION_NAME);
- if ( ext != null ) {
- if ( ext.getType() != ExtensionType.JSON) {
+ if (ext != null) {
+ if (ext.getType() != ExtensionType.JSON) {
throw new MojoExecutionException("Invalid extension type for " + ext.getName() + " : " + ext.getType());
}
final JsonObject json = ext.getJSONStructure().asJsonObject();
@@ -199,11 +200,12 @@ public class ApisConfiguration {
}
public void logConfiguration(final Log log) {
- if ( log.isInfoEnabled() ) {
+ if (log.isInfoEnabled()) {
log.info("Using configuration:");
log.info("- useApiDependencies : " + this.useApiDependencies);
- if ( this.useApiDependencies ) {
- log.info("- dependencyRepositories : " + (this.dependencyRepositories.isEmpty() ? "NONE" : this.dependencyRepositories.toString()));
+ if (this.useApiDependencies) {
+ log.info("- dependencyRepositories : "
+ + (this.dependencyRepositories.isEmpty() ? "NONE" : this.dependencyRepositories.toString()));
log.info("- useApiDependenciesForJavadoc : " + this.useApiDependenciesForJavadoc);
log.info("- generateJavadocForAllApi : " + this.generateJavadocForAllApi);
}
@@ -231,16 +233,16 @@ public class ApisConfiguration {
private String getStringOrArray(final JsonObject json, final String propName) {
String result = null;
final JsonValue val = json.containsKey(propName) ? json.get(propName) : null;
- if ( val != null ) {
- if ( val.getValueType() == ValueType.ARRAY ) {
+ if (val != null) {
+ if (val.getValueType() == ValueType.ARRAY) {
final StringBuilder sb = new StringBuilder();
- for(final JsonValue v : val.asJsonArray()) {
+ for (final JsonValue v : val.asJsonArray()) {
sb.append(v);
sb.append('\n');
}
result = sb.toString();
} else {
- result = ((JsonString)val).getString();
+ result = ((JsonString) val).getString();
}
}
return result;
@@ -248,18 +250,18 @@ public class ApisConfiguration {
private void add(final List<String> list, final JsonObject json, final String propName) {
final JsonArray array = json.containsKey(propName) ? json.getJsonArray(propName) : null;
- if ( array != null ) {
- for(final JsonValue val : array) {
- list.add(((JsonString)val).getString());
+ if (array != null) {
+ for (final JsonValue val : array) {
+ list.add(((JsonString) val).getString());
}
}
}
private void add(final Map<String, String> map, final JsonObject json, final String propName) {
final JsonObject obj = json.containsKey(propName) ? json.getJsonObject(propName) : null;
- if ( obj != null ) {
- for(final Map.Entry<String, JsonValue> entry : obj.entrySet()) {
- map.put(entry.getKey(), ((JsonString)entry.getValue()).getString());
+ if (obj != null) {
+ for (final Map.Entry<String, JsonValue> entry : obj.entrySet()) {
+ map.put(entry.getKey(), ((JsonString) entry.getValue()).getString());
}
}
}
@@ -353,105 +355,105 @@ public class ApisConfiguration {
}
public void setLicenseDefaults(final List<String> licenseDefaultsFromProjcect) throws MojoExecutionException {
- if ( this.licenseDefaults.isEmpty() && licenseDefaultsFromProjcect != null ) {
+ if (this.licenseDefaults.isEmpty() && licenseDefaultsFromProjcect != null) {
this.licenseDefaults.addAll(licenseDefaultsFromProjcect);
}
this.licenseDefaultMatcher = new IncludeExcludeMatcher(this.licenseDefaults, null, "=", true);
}
public void setLicenseReport(final String licenseReportFromProjcect) {
- if ( this.licenseReport == null ) {
+ if (this.licenseReport == null) {
this.licenseReport = licenseReportFromProjcect;
}
}
public void setLicenseReportHeader(final String licenseReportHeaderFromProjcect) {
- if ( this.licenseReportHeader == null ) {
+ if (this.licenseReportHeader == null) {
this.licenseReportHeader = licenseReportHeaderFromProjcect;
}
}
public void setLicenseReportFooter(final String licenseReportFooterFromProjcect) {
- if ( this.licenseReportFooter == null ) {
+ if (this.licenseReportFooter == null) {
this.licenseReportFooter = licenseReportFooterFromProjcect;
}
}
public void setJavadocLinks(final String[] javadocLinksFromProject) {
- if ( this.javadocLinks.isEmpty() && javadocLinksFromProject != null ) {
- for(final String v : javadocLinksFromProject) {
+ if (this.javadocLinks.isEmpty() && javadocLinksFromProject != null) {
+ for (final String v : javadocLinksFromProject) {
this.javadocLinks.add(v);
}
}
}
public void setJavadocClasspathRemovals(final List<String> javadocClasspathRemovalsFromProject) {
- if ( this.javadocClasspathRemovals.isEmpty() && javadocClasspathRemovalsFromProject != null ) {
+ if (this.javadocClasspathRemovals.isEmpty() && javadocClasspathRemovalsFromProject != null) {
this.javadocClasspathRemovals.addAll(javadocClasspathRemovalsFromProject);
}
}
public void setJavadocClasspathHighestVersions(final List<String> javadocClasspathHighestVersionsFromProject) {
- if ( this.javadocClasspathHighestVersions.isEmpty() && javadocClasspathHighestVersionsFromProject != null ) {
+ if (this.javadocClasspathHighestVersions.isEmpty() && javadocClasspathHighestVersionsFromProject != null) {
this.javadocClasspathHighestVersions.addAll(javadocClasspathHighestVersionsFromProject);
}
}
public void setJavadocClasspathTops(final List<String> javadocClasspathTopsFromProject) {
- if ( this.javadocClasspathTops.isEmpty() && javadocClasspathTopsFromProject != null ) {
+ if (this.javadocClasspathTops.isEmpty() && javadocClasspathTopsFromProject != null) {
this.javadocClasspathTops.addAll(javadocClasspathTopsFromProject);
}
}
public void setJavadocSourceLevel(final String javadocSourceLevelFromProject) {
- if ( this.javadocSourceLevel == null ) {
+ if (this.javadocSourceLevel == null) {
this.javadocSourceLevel = javadocSourceLevelFromProject;
}
}
public void setApiVersion(final String apiVersionFromProject) {
- if ( this.apiVersion == null ) {
+ if (this.apiVersion == null) {
this.apiVersion = apiVersionFromProject;
}
}
public void setBundleResources(final String[] includeResourcesFromProject) {
- if ( this.bundleResources.isEmpty() && includeResourcesFromProject != null ) {
- for(final String v : includeResourcesFromProject) {
+ if (this.bundleResources.isEmpty() && includeResourcesFromProject != null) {
+ for (final String v : includeResourcesFromProject) {
this.bundleResources.add(v);
}
}
}
public void setBundleResourceFolders(final String resourceFoldersFromProject) {
- if ( this.bundleResourceFolders.isEmpty() && resourceFoldersFromProject != null ) {
- for(final String v : resourceFoldersFromProject.split(",")) {
+ if (this.bundleResourceFolders.isEmpty() && resourceFoldersFromProject != null) {
+ for (final String v : resourceFoldersFromProject.split(",")) {
this.bundleResourceFolders.add(v.trim());
}
}
}
public void setRegionMappings(final Map<String, String> valuesFromProject) {
- if ( this.regionMappings.isEmpty() && valuesFromProject != null ) {
+ if (this.regionMappings.isEmpty() && valuesFromProject != null) {
this.regionMappings.putAll(valuesFromProject);
}
}
public void setClassifierMappings(final Map<String, String> valuesFromProject) {
- if ( this.classifierMappings.isEmpty() && valuesFromProject != null ) {
+ if (this.classifierMappings.isEmpty() && valuesFromProject != null) {
this.classifierMappings.putAll(valuesFromProject);
}
}
public void setManifestEntries(final Properties valuesFromProject) {
- if ( this.manifestEntries.isEmpty() && valuesFromProject != null ) {
+ if (this.manifestEntries.isEmpty() && valuesFromProject != null) {
this.manifestEntries.putAll(ProjectHelper.propertiesToMap(valuesFromProject));
}
}
public void setEnabledToggles(final String value) {
- if (value != null ) {
- for(final String name : value.split(",")) {
+ if (value != null) {
+ for (final String name : value.split(",")) {
enabledToggles.add(name.trim());
}
}
@@ -466,13 +468,15 @@ public class ApisConfiguration {
* @param javadocAdditionalExtensions A list of strings
*/
public void setAdditionalJavadocExtensions(final List<String> javadocAdditionalExtensions) {
- if ( javadocAdditionalExtensions != null ) {
- for(final String val : javadocAdditionalExtensions) {
+ if (javadocAdditionalExtensions != null) {
+ for (final String val : javadocAdditionalExtensions) {
final int sepPos = val.indexOf(":");
final String regionName = sepPos == -1 ? "*" : val.substring(0, sepPos);
- for(final String name : val.substring(sepPos+1).split(",")) {
- if ( !name.trim().isEmpty() ) {
- this.additionJavadocExtensionNames.computeIfAbsent(regionName, key -> new LinkedHashSet<>()).add(name.trim());
+ for (final String name : val.substring(sepPos + 1).split(",")) {
+ if (!name.trim().isEmpty()) {
+ this.additionJavadocExtensionNames
+ .computeIfAbsent(regionName, key -> new LinkedHashSet<>())
+ .add(name.trim());
}
}
}
@@ -537,16 +541,16 @@ public class ApisConfiguration {
return this.dependencyRepositories;
}
- /**
+ /**
* Set the dependency repositories
* @param list Comma separated list or {@code null}
*/
public void setDependencyRepositories(final String list) {
this.dependencyRepositories.clear();
- if ( list != null ) {
- for(String val : list.split(",") ) {
+ if (list != null) {
+ for (String val : list.split(",")) {
val = val.trim();
- if ( !val.endsWith("/") ) {
+ if (!val.endsWith("/")) {
val = val.concat("/");
}
this.dependencyRepositories.add(val);
@@ -555,7 +559,7 @@ public class ApisConfiguration {
}
public void setApiName(final String value) {
- if ( this.apiName == null ) {
+ if (this.apiName == null) {
this.apiName = value;
}
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisJarContext.java b/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisJarContext.java
index b16d26d..5936e75 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisJarContext.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisJarContext.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.apis;
@@ -112,7 +114,7 @@ public class ApisJarContext {
public String[] getUsedExportedPackageIncludes() {
final Set<String> includes = new HashSet<>();
- for(final String pck : usedExportedPackages) {
+ for (final String pck : usedExportedPackages) {
includes.add(pck.replace('.', '/').concat("/*"));
}
return includes.toArray(new String[includes.size()]);
@@ -122,9 +124,10 @@ public class ApisJarContext {
return this.usedExportedPackagesPerRegion.get(regionName);
}
- public void setUsedExportedPackages(final String regionName, final Set<Clause> usedExportedPackages, final String useAsDependency) {
+ public void setUsedExportedPackages(
+ final String regionName, final Set<Clause> usedExportedPackages, final String useAsDependency) {
this.usedExportedPackagesPerRegion.put(regionName, usedExportedPackages);
- if ( useAsDependency != null ) {
+ if (useAsDependency != null) {
this.useAsDependencyPerRegion.put(regionName, useAsDependency);
}
}
@@ -132,7 +135,7 @@ public class ApisJarContext {
public String[] getUsedExportedPackageIncludes(final String regionName) {
final Set<Clause> clauses = this.getUsedExportedPackages(regionName);
final Set<String> includes = new HashSet<>();
- for(final Clause clause : clauses) {
+ for (final Clause clause : clauses) {
includes.add(clause.getName().replace('.', '/').concat("/*"));
}
return includes.toArray(new String[includes.size()]);
@@ -182,14 +185,14 @@ public class ApisJarContext {
public List<ArtifactId> getDependencyArtifacts() throws MojoExecutionException {
final List<ArtifactId> dependencies = new ArrayList<>();
final List<ArtifactId> apiIds = ApisUtil.getApiIds(artifact);
- if ( apiIds != null ) {
- for(final ArtifactId id : apiIds) {
+ if (apiIds != null) {
+ for (final ArtifactId id : apiIds) {
dependencies.add(id);
}
} else {
final List<ArtifactId> sourceIds = ApisUtil.getSourceIds(artifact);
- if ( sourceIds != null ) {
- for(final ArtifactId id : sourceIds) {
+ if (sourceIds != null) {
+ for (final ArtifactId id : sourceIds) {
dependencies.add(id.changeClassifier(null));
}
} else {
@@ -200,13 +203,13 @@ public class ApisJarContext {
}
public void addSourceInfo(final ArtifactId id) {
- if ( id != null ) {
+ if (id != null) {
this.sources.add(id.toMvnId());
}
}
public void addSourceInfo(final String connection) {
- if ( connection != null ) {
+ if (connection != null) {
this.sources.add(connection);
}
}
@@ -236,10 +239,8 @@ public class ApisJarContext {
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!(obj instanceof ArtifactInfo))
- return false;
+ if (this == obj) return true;
+ if (!(obj instanceof ArtifactInfo)) return false;
ArtifactInfo other = (ArtifactInfo) obj;
return Objects.equals(artifact, other.artifact);
}
@@ -333,8 +334,8 @@ public class ApisJarContext {
}
public ArtifactInfo getArtifactInfo(final ArtifactId artifactId) {
- for(final ArtifactInfo i : this.infos) {
- if ( i.getArtifact().getId().equals(artifactId)) {
+ for (final ArtifactInfo i : this.infos) {
+ if (i.getArtifact().getId().equals(artifactId)) {
return i;
}
}
@@ -351,10 +352,10 @@ public class ApisJarContext {
public Collection<ArtifactInfo> getArtifactInfos(final String regionName, final boolean omitDependencyArtifacts) {
final Map<ArtifactId, ArtifactInfo> result = new TreeMap<>();
- for(final ArtifactInfo info : this.infos) {
+ for (final ArtifactInfo info : this.infos) {
final Set<Clause> pcks = info.getUsedExportedPackages(regionName);
- if ( pcks != null && !pcks.isEmpty() ) {
- if ( !omitDependencyArtifacts || !info.isUseAsDependencyPerRegion(regionName) ) {
+ if (pcks != null && !pcks.isEmpty()) {
+ if (!omitDependencyArtifacts || !info.isUseAsDependencyPerRegion(regionName)) {
result.put(info.getId(), info);
}
}
@@ -372,10 +373,13 @@ public class ApisJarContext {
*/
private boolean findDependencyArtifact(final Log log, final ArtifactId id) throws MojoExecutionException {
boolean result = true;
- if ( !this.getConfig().getDependencyRepositories().isEmpty() ) {
+ if (!this.getConfig().getDependencyRepositories().isEmpty()) {
result = false;
- log.debug("Trying to resolve ".concat(id.toMvnId()).concat(" from ").concat(this.getConfig().getDependencyRepositories().toString()));
- for(final String server : this.getConfig().getDependencyRepositories()) {
+ log.debug("Trying to resolve "
+ .concat(id.toMvnId())
+ .concat(" from ")
+ .concat(this.getConfig().getDependencyRepositories().toString()));
+ for (final String server : this.getConfig().getDependencyRepositories()) {
try {
final URL url = new URL(server.concat(id.toMvnPath()));
try {
@@ -385,9 +389,14 @@ public class ApisJarContext {
break;
} catch (IOException e) {
// not available
- log.debug("Missed ".concat(id.toMvnId()).concat(" at ").concat(url.toString()).concat(" : ").concat(e.toString()));
+ log.debug("Missed "
+ .concat(id.toMvnId())
+ .concat(" at ")
+ .concat(url.toString())
+ .concat(" : ")
+ .concat(e.toString()));
}
- } catch ( final MalformedURLException mue) {
+ } catch (final MalformedURLException mue) {
throw new MojoExecutionException("Unable to find dependency on ".concat(server), mue);
}
}
@@ -404,8 +413,8 @@ public class ApisJarContext {
*/
public boolean findDependencyArtifact(final Log log, final ArtifactInfo info) throws MojoExecutionException {
boolean result = true;
- for(final ArtifactId id : info.getDependencyArtifacts()) {
- if ( !findDependencyArtifact(log, id) ) {
+ for (final ArtifactId id : info.getDependencyArtifacts()) {
+ if (!findDependencyArtifact(log, id)) {
result = false;
break;
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisUtil.java b/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisUtil.java
index c907586..1df85d1 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisUtil.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisUtil.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.apis;
@@ -90,13 +92,14 @@ public class ApisUtil {
public static List<ArtifactId> getSourceIds(final Artifact artifact) throws MojoExecutionException {
final String val = artifact.getMetadata().get(SCM_IDS);
- if ( val != null ) {
+ if (val != null) {
final List<ArtifactId> result = new ArrayList<>();
- for(final String v : val.split(",")) {
+ for (final String v : val.split(",")) {
try {
final ArtifactId sourceId = ArtifactId.parse(v.trim());
- if ( sourceId.getClassifier() == null ) {
- throw new MojoExecutionException("Metadata " + SCM_IDS + " must specify classifier for source artifacts : " + sourceId.toMvnId());
+ if (sourceId.getClassifier() == null) {
+ throw new MojoExecutionException("Metadata " + SCM_IDS
+ + " must specify classifier for source artifacts : " + sourceId.toMvnId());
}
result.add(sourceId);
} catch (final IllegalArgumentException iae) {
@@ -110,9 +113,9 @@ public class ApisUtil {
public static List<ArtifactId> getApiIds(final Artifact artifact) throws MojoExecutionException {
final String val = artifact.getMetadata().get(API_IDS);
- if ( val != null ) {
+ if (val != null) {
final List<ArtifactId> result = new ArrayList<>();
- for(final String v : val.split(",")) {
+ for (final String v : val.split(",")) {
try {
final ArtifactId id = ArtifactId.parse(v.trim());
result.add(id);
@@ -127,11 +130,11 @@ public class ApisUtil {
public static List<String> getJavadocLinks(final Artifact artifact) {
final String val = artifact.getMetadata().get(JAVADOC_LINKS);
- if ( val != null ) {
+ if (val != null) {
final List<String> result = new ArrayList<>();
- for(String v : val.split(",")) {
+ for (String v : val.split(",")) {
v = v.trim();
- if ( v.endsWith("/") ) {
+ if (v.endsWith("/")) {
v = v.substring(0, v.length() - 1);
}
result.add(v);
@@ -141,21 +144,23 @@ public class ApisUtil {
return null;
}
- public static void getPackageList(String javadocUrl, final Set<String> linkedPackages,
- final Map<String, Set<String>> linkedPackagesMap) throws MojoExecutionException {
- if ( javadocUrl.endsWith("/") ) {
+ public static void getPackageList(
+ String javadocUrl, final Set<String> linkedPackages, final Map<String, Set<String>> linkedPackagesMap)
+ throws MojoExecutionException {
+ if (javadocUrl.endsWith("/")) {
javadocUrl = javadocUrl.substring(0, javadocUrl.length() - 1);
}
Set<String> result = linkedPackagesMap.get(javadocUrl);
- if ( result == null ) {
+ if (result == null) {
result = new HashSet<>();
linkedPackagesMap.put(javadocUrl, result);
final String urlString = javadocUrl.concat("/package-list");
try {
- final URL url = new URL(urlString);
- try (final LineNumberReader reader = new LineNumberReader(new InputStreamReader(url.openConnection().getInputStream(), StandardCharsets.UTF_8))) {
+ final URL url = new URL(urlString);
+ try (final LineNumberReader reader = new LineNumberReader(
+ new InputStreamReader(url.openConnection().getInputStream(), StandardCharsets.UTF_8))) {
String line = null;
- while ( (line = reader.readLine()) != null ) {
+ while ((line = reader.readLine()) != null) {
result.add(line.trim());
}
}
@@ -170,7 +175,7 @@ public class ApisUtil {
final Set<String> result = new HashSet<>();
final String ignore = bundle.getMetadata().get(ApisUtil.IGNORE_PACKAGES);
if (ignore != null) {
- for(final String p : ignore.split(",")) {
+ for (final String p : ignore.split(",")) {
result.add(p.trim());
}
}
@@ -184,17 +189,19 @@ public class ApisUtil {
*/
public static void validateSourceInfo(final Artifact artifact) throws MojoExecutionException {
int count = 0;
- if ( artifact.getMetadata().get(ApisUtil.SCM_LOCATION) != null ) {
+ if (artifact.getMetadata().get(ApisUtil.SCM_LOCATION) != null) {
count++;
}
- if ( artifact.getMetadata().get(ApisUtil.SCM_CLASSIFIER) != null ) {
+ if (artifact.getMetadata().get(ApisUtil.SCM_CLASSIFIER) != null) {
count++;
}
- if ( artifact.getMetadata().get(ApisUtil.SCM_IDS) != null ) {
+ if (artifact.getMetadata().get(ApisUtil.SCM_IDS) != null) {
count++;
}
- if ( count > 1 ) {
- throw new MojoExecutionException("Only one source configuration out of " + ApisUtil.SCM_CLASSIFIER + ", " + ApisUtil.SCM_IDS + " or " + ApisUtil.SCM_LOCATION + " is allowed for " + artifact.getId().toMvnId());
+ if (count > 1) {
+ throw new MojoExecutionException("Only one source configuration out of " + ApisUtil.SCM_CLASSIFIER + ", "
+ + ApisUtil.SCM_IDS + " or " + ApisUtil.SCM_LOCATION + " is allowed for "
+ + artifact.getId().toMvnId());
}
}
@@ -209,24 +216,26 @@ public class ApisUtil {
* @throws MojoExecutionException When an invalid artifact ID is found
* @return The computed javadoc classpath
*/
- public static Collection<String> getJavadocClassPath(final Log log,
+ public static Collection<String> getJavadocClassPath(
+ final Log log,
final RepositorySystem repositorySystem,
final MavenSession mavenSession,
final ApisJarContext ctx,
- final String regionName) throws MojoExecutionException {
+ final String regionName)
+ throws MojoExecutionException {
// classpath - reverse order to have highest versions first
final Map<ArtifactId, String> classpathMapping = new TreeMap<>(Comparator.reverseOrder());
classpathMapping.putAll(ctx.getJavadocClasspath());
- for(final ArtifactInfo info : ctx.getArtifactInfos(regionName, false)) {
+ for (final ArtifactInfo info : ctx.getArtifactInfos(regionName, false)) {
final String ids = info.getArtifact().getMetadata().get(ApisUtil.JAVADOC_CLASSPATH);
- if ( ids != null ) {
- for(final String s : ids.split(",")) {
+ if (ids != null) {
+ for (final String s : ids.split(",")) {
try {
final ArtifactId cpId = ArtifactId.parse(s.trim());
classpathMapping.putAll(buildJavadocClasspath(log, repositorySystem, mavenSession, cpId));
- } catch ( final IllegalArgumentException iae) {
+ } catch (final IllegalArgumentException iae) {
throw new MojoExecutionException("Invalid javadoc classpath artifact id " + s);
}
}
@@ -235,13 +244,15 @@ public class ApisUtil {
// filter classpath using rules
// remove
- if ( !ctx.getConfig().getJavadocClasspathRemovals().isEmpty()) {
- log.debug("Using javadoc classpath removal: ".concat(ctx.getConfig().getJavadocClasspathRemovals().toString()));
- final IncludeExcludeMatcher matcher = new IncludeExcludeMatcher(ctx.getConfig().getJavadocClasspathRemovals(), null, null, false);
+ if (!ctx.getConfig().getJavadocClasspathRemovals().isEmpty()) {
+ log.debug("Using javadoc classpath removal: "
+ .concat(ctx.getConfig().getJavadocClasspathRemovals().toString()));
+ final IncludeExcludeMatcher matcher =
+ new IncludeExcludeMatcher(ctx.getConfig().getJavadocClasspathRemovals(), null, null, false);
final Iterator<ArtifactId> iter = classpathMapping.keySet().iterator();
- while ( iter.hasNext() ) {
+ while (iter.hasNext()) {
final ArtifactId id = iter.next();
- if ( matcher.matches(id) != null ) {
+ if (matcher.matches(id) != null) {
log.debug("Removing from javadoc classpath: " + id.toMvnId());
iter.remove();
}
@@ -249,20 +260,22 @@ public class ApisUtil {
}
// highest
- if ( !ctx.getConfig().getJavadocClasspathHighestVersions() .isEmpty() ) {
- log.debug("Using javadoc classpath highest versions: ".concat(ctx.getConfig().getJavadocClasspathHighestVersions() .toString()));
- final IncludeExcludeMatcher matcher = new IncludeExcludeMatcher(ctx.getConfig().getJavadocClasspathHighestVersions() , null, null, false);
+ if (!ctx.getConfig().getJavadocClasspathHighestVersions().isEmpty()) {
+ log.debug("Using javadoc classpath highest versions: "
+ .concat(ctx.getConfig().getJavadocClasspathHighestVersions().toString()));
+ final IncludeExcludeMatcher matcher =
+ new IncludeExcludeMatcher(ctx.getConfig().getJavadocClasspathHighestVersions(), null, null, false);
final Map<ArtifactId, List<ArtifactId>> highest = new HashMap<>();
- for(final Map.Entry<ArtifactId, String> entry : classpathMapping.entrySet()) {
- if ( matcher.matches(entry.getKey()) != null ) {
+ for (final Map.Entry<ArtifactId, String> entry : classpathMapping.entrySet()) {
+ if (matcher.matches(entry.getKey()) != null) {
final ArtifactId key = entry.getKey().changeVersion("0");
highest.computeIfAbsent(key, k -> new ArrayList<>()).add(entry.getKey());
}
}
- for(final List<ArtifactId> versions : highest.values()) {
+ for (final List<ArtifactId> versions : highest.values()) {
Collections.sort(versions, Comparator.reverseOrder());
- for(int i=1; i<versions.size();i++) {
+ for (int i = 1; i < versions.size(); i++) {
final ArtifactId id = versions.get(i);
classpathMapping.remove(id);
log.debug("Removing from javadoc classpath: " + id.toMvnId());
@@ -272,31 +285,34 @@ public class ApisUtil {
// top
final List<String> classpath;
- if ( !ctx.getConfig().getJavadocClasspathTops().isEmpty()) {
- log.debug("Using javadoc classpath tops: ".concat(ctx.getConfig().getJavadocClasspathTops().toString()));
- final IncludeExcludeMatcher matcher = new IncludeExcludeMatcher(ctx.getConfig().getJavadocClasspathTops(), null, null, false);
+ if (!ctx.getConfig().getJavadocClasspathTops().isEmpty()) {
+ log.debug("Using javadoc classpath tops: "
+ .concat(ctx.getConfig().getJavadocClasspathTops().toString()));
+ final IncludeExcludeMatcher matcher =
+ new IncludeExcludeMatcher(ctx.getConfig().getJavadocClasspathTops(), null, null, false);
final List<String> tops = new ArrayList<>();
- final Iterator<Map.Entry<ArtifactId, String>> iter = classpathMapping.entrySet().iterator();
- while ( iter.hasNext() ) {
+ final Iterator<Map.Entry<ArtifactId, String>> iter =
+ classpathMapping.entrySet().iterator();
+ while (iter.hasNext()) {
final Map.Entry<ArtifactId, String> entry = iter.next();
- if ( matcher.matches(entry.getKey()) != null ) {
+ if (matcher.matches(entry.getKey()) != null) {
tops.add(0, entry.getValue());
iter.remove();
}
}
classpath = new ArrayList<>(classpathMapping.values());
- for(final String path : tops) {
+ for (final String path : tops) {
classpath.add(0, path);
}
} else {
classpath = new ArrayList<>(classpathMapping.values());
}
- if ( log.isDebugEnabled() ) {
+ if (log.isDebugEnabled()) {
log.debug("------------------------------------------------------------------");
log.debug("Javadoc classpath: ");
- for(final String cp : classpath) {
+ for (final String cp : classpath) {
log.debug("- " + cp);
}
log.debug("------------------------------------------------------------------");
@@ -305,37 +321,41 @@ public class ApisUtil {
return classpath;
}
- public static Map<ArtifactId, String> buildJavadocClasspath(final Log log, final RepositorySystem repositorySystem,
+ public static Map<ArtifactId, String> buildJavadocClasspath(
+ final Log log,
+ final RepositorySystem repositorySystem,
final MavenSession mavenSession,
final ArtifactId artifactId)
throws MojoExecutionException {
final Map<ArtifactId, String> javadocClasspath = new HashMap<>();
log.debug("Retrieving " + artifactId + " and related dependencies...");
- org.apache.maven.artifact.Artifact toBeResolvedArtifact = repositorySystem.createArtifactWithClassifier(artifactId.getGroupId(),
- artifactId.getArtifactId(),
- artifactId.getVersion(),
- artifactId.getType(),
- artifactId.getClassifier());
+ org.apache.maven.artifact.Artifact toBeResolvedArtifact = repositorySystem.createArtifactWithClassifier(
+ artifactId.getGroupId(),
+ artifactId.getArtifactId(),
+ artifactId.getVersion(),
+ artifactId.getType(),
+ artifactId.getClassifier());
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
- .setArtifact(toBeResolvedArtifact)
- .setServers(mavenSession.getRequest().getServers())
- .setMirrors(mavenSession.getRequest().getMirrors())
- .setProxies(mavenSession.getRequest().getProxies())
- .setLocalRepository(mavenSession.getLocalRepository())
- .setRemoteRepositories(mavenSession.getRequest().getRemoteRepositories())
- .setForceUpdate(false)
- .setResolveRoot(true)
- .setResolveTransitively(true)
- .setCollectionFilter(new ArtifactFilter() {
- // artifact filter
- @Override
- public boolean include(org.apache.maven.artifact.Artifact artifact) {
- if (org.apache.maven.artifact.Artifact.SCOPE_TEST.equals(artifact.getScope())) {
- return false;
- }
- return true;
- }});
+ .setArtifact(toBeResolvedArtifact)
+ .setServers(mavenSession.getRequest().getServers())
+ .setMirrors(mavenSession.getRequest().getMirrors())
+ .setProxies(mavenSession.getRequest().getProxies())
+ .setLocalRepository(mavenSession.getLocalRepository())
+ .setRemoteRepositories(mavenSession.getRequest().getRemoteRepositories())
+ .setForceUpdate(false)
+ .setResolveRoot(true)
+ .setResolveTransitively(true)
+ .setCollectionFilter(new ArtifactFilter() {
+ // artifact filter
+ @Override
+ public boolean include(org.apache.maven.artifact.Artifact artifact) {
+ if (org.apache.maven.artifact.Artifact.SCOPE_TEST.equals(artifact.getScope())) {
+ return false;
+ }
+ return true;
+ }
+ });
ArtifactResolutionResult result = repositorySystem.resolve(request);
@@ -374,7 +394,13 @@ public class ApisUtil {
for (org.apache.maven.artifact.Artifact resolvedArtifact : result.getArtifacts()) {
if (resolvedArtifact.getFile() != null) {
log.debug("Adding to javadoc classpath " + resolvedArtifact);
- javadocClasspath.put(new ArtifactId(resolvedArtifact.getGroupId(), resolvedArtifact.getArtifactId(), resolvedArtifact.getVersion(), resolvedArtifact.getClassifier(), resolvedArtifact.getType()),
+ javadocClasspath.put(
+ new ArtifactId(
+ resolvedArtifact.getGroupId(),
+ resolvedArtifact.getArtifactId(),
+ resolvedArtifact.getVersion(),
+ resolvedArtifact.getClassifier(),
+ resolvedArtifact.getType()),
resolvedArtifact.getFile().getAbsolutePath());
} else {
log.debug("Ignoring for javadoc classpath " + resolvedArtifact);
@@ -384,13 +410,14 @@ public class ApisUtil {
return javadocClasspath;
}
- private static <E extends ArtifactResolutionException> void reportWarningMessages(final Log log, final Collection<E> exceptions) {
+ private static <E extends ArtifactResolutionException> void reportWarningMessages(
+ final Log log, final Collection<E> exceptions) {
for (E exception : exceptions) {
log.warn(" - "
- + exception.getMessage()
- + " ("
- + exception.getArtifact().getId()
- + ")");
+ + exception.getMessage()
+ + " ("
+ + exception.getArtifact().getId()
+ + ")");
}
}
@@ -402,7 +429,7 @@ public class ApisUtil {
final ServiceLoader<Processor> loader = ServiceLoader.load(Processor.class);
final List<Processor> result = new ArrayList<>();
- for(final Processor p : loader) {
+ for (final Processor p : loader) {
result.add(p);
}
if (includeProviderTypeResource) {
@@ -419,31 +446,32 @@ public class ApisUtil {
* @return A tuple of packages containing files with the extension and packages with files not having the extension
* @throws MojoExecutionException If processing fails
*/
- public static Map.Entry<Set<String>, Set<String>> getPackages(final ApisJarContext ctx, final File file, final String extension)
- throws MojoExecutionException {
+ public static Map.Entry<Set<String>, Set<String>> getPackages(
+ final ApisJarContext ctx, final File file, final String extension) throws MojoExecutionException {
final Set<String> packages = new TreeSet<>();
final Set<String> otherPackages = new TreeSet<>();
final Set<String> excludes = new HashSet<>();
- for(final String v : ctx.getConfig().getBundleResourceFolders()) {
+ for (final String v : ctx.getConfig().getBundleResourceFolders()) {
excludes.add(v.concat("/"));
}
try (final JarInputStream jis = new JarInputStream(new FileInputStream(file))) {
JarEntry entry;
while ((entry = jis.getNextJarEntry()) != null) {
- if ( !entry.isDirectory() ) {
+ if (!entry.isDirectory()) {
boolean exclude = false;
- for(final String v : excludes) {
- if ( entry.getName().startsWith(v)) {
+ for (final String v : excludes) {
+ if (entry.getName().startsWith(v)) {
exclude = true;
break;
}
}
- if ( !exclude ) {
+ if (!exclude) {
final int lastPos = entry.getName().lastIndexOf('/');
if (lastPos != -1) {
- final String packageName = entry.getName().substring(0, lastPos).replace('/', '.');
+ final String packageName =
+ entry.getName().substring(0, lastPos).replace('/', '.');
if (entry.getName().endsWith(extension)) {
packages.add(packageName);
@@ -461,7 +489,10 @@ public class ApisUtil {
otherPackages.removeAll(packages);
- return Collections.singletonMap(packages, otherPackages).entrySet().iterator().next();
+ return Collections.singletonMap(packages, otherPackages)
+ .entrySet()
+ .iterator()
+ .next();
}
/**
@@ -471,12 +502,13 @@ public class ApisUtil {
* @return A list of artifacts, might be empty
* @throws MojoExecutionException If processing fails or configuration is invalid
*/
- public static List<Artifact> getAdditionalJavadocArtifacts(final ApisJarContext context, final String regionName) throws MojoExecutionException {
+ public static List<Artifact> getAdditionalJavadocArtifacts(final ApisJarContext context, final String regionName)
+ throws MojoExecutionException {
final List<Artifact> result = new ArrayList<>();
- for(final String extensionName : context.getConfig().getAdditionalJavadocExtensions(regionName)) {
+ for (final String extensionName : context.getConfig().getAdditionalJavadocExtensions(regionName)) {
final Extension extension = context.getFeature().getExtensions().getByName(extensionName);
- if ( extension != null ) {
- if ( extension.getType() != ExtensionType.ARTIFACTS ) {
+ if (extension != null) {
+ if (extension.getType() != ExtensionType.ARTIFACTS) {
throw new MojoExecutionException("Extension " + extensionName + " must be of type artifacts.");
}
result.addAll(extension.getArtifacts());
@@ -486,26 +518,29 @@ public class ApisUtil {
return result;
}
- public static void writeSourceReport(final boolean write, final Log log, final File reportFile, final List<ArtifactInfo> infos) throws MojoExecutionException {
+ public static void writeSourceReport(
+ final boolean write, final Log log, final File reportFile, final List<ArtifactInfo> infos)
+ throws MojoExecutionException {
if (write) {
- Collections.sort(infos, new Comparator<ArtifactInfo>(){
+ Collections.sort(infos, new Comparator<ArtifactInfo>() {
@Override
public int compare(ArtifactInfo o1, ArtifactInfo o2) {
return o1.getId().compareTo(o2.getId());
}
-
});
final List<String> output = new ArrayList<>();
for (final ArtifactInfo info : infos) {
if (info.getSources().isEmpty()) {
output.add("- ".concat(info.getId().toMvnId()).concat(" : NO SOURCES FOUND"));
} else {
- output.add(
- "- ".concat(info.getId().toMvnId()).concat(" : ").concat(info.getSources().toString()));
+ output.add("- "
+ .concat(info.getId().toMvnId())
+ .concat(" : ")
+ .concat(info.getSources().toString()));
}
}
- if ( output.isEmpty() ) {
+ if (output.isEmpty()) {
output.add("NO SOURCES FOUND");
}
log.info("--------------------------------------------------------");
@@ -518,7 +553,7 @@ public class ApisUtil {
throw new MojoExecutionException("Unable to write " + reportFile, e);
}
} else {
- if ( reportFile.exists() ) {
+ if (reportFile.exists()) {
reportFile.delete();
}
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/apis/ArtifactType.java b/src/main/java/org/apache/sling/feature/maven/mojos/apis/ArtifactType.java
index 709d239..fc695bd 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/apis/ArtifactType.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/apis/ArtifactType.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.apis;
@@ -53,4 +55,4 @@ public enum ArtifactType {
public String getExtension() {
return this.extension;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/apis/ClassFileProcessor.java b/src/main/java/org/apache/sling/feature/maven/mojos/apis/ClassFileProcessor.java
index 5005920..a760deb 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/apis/ClassFileProcessor.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/apis/ClassFileProcessor.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.apis;
@@ -21,20 +23,19 @@ import java.io.FileInputStream;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
-
-import org.apache.sling.feature.maven.mojos.apis.spi.Processor;
-import org.apache.sling.feature.maven.mojos.apis.spi.ProcessorContext;
-import org.apache.sling.feature.maven.mojos.apis.spi.Source;
-import org.osgi.annotation.versioning.ProviderType;
-
-import jakarta.json.Json;
-import jakarta.json.stream.JsonGenerator;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.bytecode.AnnotationsAttribute;
import javassist.bytecode.AttributeInfo;
import javassist.bytecode.ClassFile;
+import jakarta.json.Json;
+import jakarta.json.stream.JsonGenerator;
+import org.apache.sling.feature.maven.mojos.apis.spi.Processor;
+import org.apache.sling.feature.maven.mojos.apis.spi.ProcessorContext;
+import org.apache.sling.feature.maven.mojos.apis.spi.Source;
+import org.osgi.annotation.versioning.ProviderType;
+
public class ClassFileProcessor implements Processor {
private static final String NAME = "api-info.json";
@@ -44,21 +45,23 @@ public class ClassFileProcessor implements Processor {
try {
final String extension = ".class";
final List<String> providerTypes = new ArrayList<>();
- for(final Source s : sources) {
- for(final File f : s.getFiles()) {
+ for (final Source s : sources) {
+ for (final File f : s.getFiles()) {
final String pckName = getPackageName(s.getBaseDirectory(), f, extension);
if (pckName != null) {
processClassFile(pckName, s.getBaseDirectory(), f, providerTypes);
}
}
}
- final File out = new File(ctx.getOutputDirectory(), ctx.getApiRegion().getName().concat("-").concat(NAME));
+ final File out = new File(
+ ctx.getOutputDirectory(),
+ ctx.getApiRegion().getName().concat("-").concat(NAME));
if (!providerTypes.isEmpty()) {
out.getParentFile().mkdirs();
try (final JsonGenerator gen = Json.createGenerator(Files.newOutputStream(out.toPath()))) {
gen.writeStartObject();
gen.writeStartArray("providerTypes");
- for(final String p : providerTypes) {
+ for (final String p : providerTypes) {
gen.write(p);
}
gen.writeEnd();
@@ -80,10 +83,11 @@ public class ClassFileProcessor implements Processor {
private String getPackageName(final File baseDirectory, final File file, final String extension) {
final String name = file.getName();
- if ( name.endsWith(extension)) {
- final String path = file.getAbsolutePath().substring(baseDirectory.getAbsolutePath().length() + 1);
+ if (name.endsWith(extension)) {
+ final String path = file.getAbsolutePath()
+ .substring(baseDirectory.getAbsolutePath().length() + 1);
final int lastSlash = path.lastIndexOf(File.separatorChar);
- if ( lastSlash != -1 ) {
+ if (lastSlash != -1) {
final String pckName = path.substring(0, lastSlash).replace(File.separatorChar, '.');
return pckName;
}
@@ -91,18 +95,18 @@ public class ClassFileProcessor implements Processor {
return null;
}
- private void processClassFile(final String pckName,
- final File baseDirectory,
- final File f,
- final List<String> providerTypes) throws Exception {
+ private void processClassFile(
+ final String pckName, final File baseDirectory, final File f, final List<String> providerTypes)
+ throws Exception {
final CtClass cc = ClassPool.getDefault().makeClass(new FileInputStream(f));
try {
- cc.setName(pckName.concat(".").concat(f.getName().substring(0, f.getName().length()-6)));
+ cc.setName(pckName.concat(".")
+ .concat(f.getName().substring(0, f.getName().length() - 6)));
final ClassFile cfile = cc.getClassFile();
- for(final AttributeInfo attr : cfile.getAttributes()) {
+ for (final AttributeInfo attr : cfile.getAttributes()) {
if (attr instanceof AnnotationsAttribute) {
- final AnnotationsAttribute ann = (AnnotationsAttribute)attr;
- if (ann.getAnnotation(ProviderType.class.getName()) != null ) {
+ final AnnotationsAttribute ann = (AnnotationsAttribute) attr;
+ if (ann.getAnnotation(ProviderType.class.getName()) != null) {
providerTypes.add(cc.getName());
}
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/apis/DirectorySource.java b/src/main/java/org/apache/sling/feature/maven/mojos/apis/DirectorySource.java
index f16e37d..5cf2b41 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/apis/DirectorySource.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/apis/DirectorySource.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.apis;
@@ -40,30 +42,26 @@ public class DirectorySource implements Source {
@Override
public List<File> getFiles() {
final DirectoryScanner ds = new DirectoryScanner();
- ds.setBasedir( this.fileSet.getDirectory() );
+ ds.setBasedir(this.fileSet.getDirectory());
final String[] inc = this.fileSet.getIncludes();
- if ( inc != null && inc.length > 0 )
- {
- ds.setIncludes( inc );
+ if (inc != null && inc.length > 0) {
+ ds.setIncludes(inc);
}
final String[] exc = this.fileSet.getExcludes();
- if ( exc != null && exc.length > 0 )
- {
- ds.setExcludes( exc );
+ if (exc != null && exc.length > 0) {
+ ds.setExcludes(exc);
}
- if ( this.fileSet.isUsingDefaultExcludes() )
- {
+ if (this.fileSet.isUsingDefaultExcludes()) {
ds.addDefaultExcludes();
}
- ds.setCaseSensitive( this.fileSet.isCaseSensitive() );
- ds.setFollowSymlinks( false );
+ ds.setCaseSensitive(this.fileSet.isCaseSensitive());
+ ds.setFollowSymlinks(false);
ds.scan();
final List<File> result = new ArrayList<>();
- for(final String file : ds.getIncludedFiles()) {
+ for (final String file : ds.getIncludedFiles()) {
result.add(new File(this.fileSet.getDirectory(), file));
}
return result;
}
-
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/apis/FileSource.java b/src/main/java/org/apache/sling/feature/maven/mojos/apis/FileSource.java
index 98db079..57d8a40 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/apis/FileSource.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/apis/FileSource.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.apis;
@@ -22,7 +24,6 @@ import java.util.List;
import org.apache.sling.feature.maven.mojos.apis.spi.Source;
-
public class FileSource implements Source {
private final File directory;
@@ -43,5 +44,4 @@ public class FileSource implements Source {
public List<File> getFiles() {
return Collections.singletonList(this.file);
}
-
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/apis/JavadocExecutor.java b/src/main/java/org/apache/sling/feature/maven/mojos/apis/JavadocExecutor.java
index 1fd2ca2..0af30e4 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/apis/JavadocExecutor.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/apis/JavadocExecutor.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.apis;
@@ -95,7 +97,7 @@ public final class JavadocExecutor {
DefaultExecutor executor = new DefaultExecutor();
executor.setWorkingDirectory(workingDir);
if (ignoreErrors) {
- executor.setExitValues(new int[] { 1, 0, -1 });
+ executor.setExitValues(new int[] {1, 0, -1});
}
try {
executor.getStreamHandler().setProcessInputStream(new LoggerOutputStream(logger));
@@ -194,7 +196,5 @@ public final class JavadocExecutor {
flush();
super.close();
}
-
}
-
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/apis/JavadocLinks.java b/src/main/java/org/apache/sling/feature/maven/mojos/apis/JavadocLinks.java
index 53fea5e..d798958 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/apis/JavadocLinks.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/apis/JavadocLinks.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.apis;
@@ -33,29 +35,29 @@ public class JavadocLinks {
private final Set<String> docLinks = new HashSet<>();
- public void calculateLinks(final List<String> globalJavaDocLinks,
- final Collection<ArtifactInfo> infos,
- final Artifact framework) throws MojoExecutionException {
+ public void calculateLinks(
+ final List<String> globalJavaDocLinks, final Collection<ArtifactInfo> infos, final Artifact framework)
+ throws MojoExecutionException {
final Map<String, Set<String>> linkedPackagesMap = new HashMap<>();
this.docLinks.clear();
this.linkedGlobalPackages.clear();
- for(final String val : globalJavaDocLinks) {
+ for (final String val : globalJavaDocLinks) {
docLinks.add(val);
ApisUtil.getPackageList(val, linkedGlobalPackages, linkedPackagesMap);
}
- for(final ArtifactInfo info : infos) {
+ for (final ArtifactInfo info : infos) {
final List<String> links = ApisUtil.getJavadocLinks(info.getArtifact());
- if ( links != null ) {
- for(final String v : links) {
+ if (links != null) {
+ for (final String v : links) {
ApisUtil.getPackageList(v, linkedGlobalPackages, linkedPackagesMap);
docLinks.add(v);
}
}
}
- if ( framework != null ) {
+ if (framework != null) {
final List<String> links = ApisUtil.getJavadocLinks(framework);
- if ( links != null ) {
- for(final String v : links) {
+ if (links != null) {
+ for (final String v : links) {
ApisUtil.getPackageList(v, linkedGlobalPackages, linkedPackagesMap);
docLinks.add(v);
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/apis/RegionSupport.java b/src/main/java/org/apache/sling/feature/maven/mojos/apis/RegionSupport.java
index 5e5f860..31c49ea 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/apis/RegionSupport.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/apis/RegionSupport.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.apis;
@@ -51,11 +53,12 @@ public class RegionSupport {
private final boolean toggleApiOnly;
- public RegionSupport(final Log logger,
- final boolean incrementalApis,
- final boolean toggleApiOnly,
- final Set<String> includeRegions,
- final Set<String> excludeRegions) {
+ public RegionSupport(
+ final Log logger,
+ final boolean incrementalApis,
+ final boolean toggleApiOnly,
+ final Set<String> includeRegions,
+ final Set<String> excludeRegions) {
this.log = logger;
this.incrementalApis = incrementalApis;
this.includeRegions = includeRegions;
@@ -149,7 +152,7 @@ public class RegionSupport {
public List<ApiExport> getAllExports(final ApiRegion region, final Set<String> enabledToggles) {
final List<ApiExport> result = new ArrayList<>();
for (final ApiExport exp : region.listExports()) {
- if ( this.include(exp, enabledToggles) ) {
+ if (this.include(exp, enabledToggles)) {
result.add(exp);
}
}
@@ -158,11 +161,13 @@ public class RegionSupport {
private boolean include(final ApiExport exp, final Set<String> enabledToggles) {
boolean include = !toggleApiOnly;
- if ( toggleApiOnly ) {
+ if (toggleApiOnly) {
include = exp.getToggle() != null && enabledToggles.contains(exp.getToggle());
} else {
// if the package is behind a toggle, only include if toggle is enabled or if previous artifact is set
- if (exp.getToggle() != null && !enabledToggles.contains(exp.getToggle()) && exp.getPreviousArtifactId() == null) {
+ if (exp.getToggle() != null
+ && !enabledToggles.contains(exp.getToggle())
+ && exp.getPreviousArtifactId() == null) {
include = false;
}
}
@@ -179,10 +184,12 @@ public class RegionSupport {
* @return Set of packages exported by this bundle and used in any region
* @throws MojoExecutionException when the calculation cannot be made
*/
- public Set<String> computeAllUsedExportPackages(final ApiRegions apiRegions,
+ public Set<String> computeAllUsedExportPackages(
+ final ApiRegions apiRegions,
final Set<String> enabledToggles,
final Clause[] exportedPackages,
- final Artifact bundle) throws MojoExecutionException {
+ final Artifact bundle)
+ throws MojoExecutionException {
final Set<String> result = new HashSet<>();
// filter for each region
@@ -192,7 +199,7 @@ public class RegionSupport {
for (ApiRegion apiRegion : apiRegions.listRegions()) {
final ApiExport exp = apiRegion.getExportByName(packageName);
if (exp != null) {
- if ( this.include(exp, enabledToggles) ) {
+ if (this.include(exp, enabledToggles)) {
result.add(exportedPackage.getName());
}
}
@@ -205,7 +212,7 @@ public class RegionSupport {
return result;
}
- /**
+ /**
* Compute exports based on a single region
*
* @param apiRegion The API Region to use
@@ -214,9 +221,9 @@ public class RegionSupport {
* @return List of packages exported by this bundle and used in the region
* @throws MojoExecutionException When the computation cannot be done.
*/
- public Set<Clause> computeUsedExportPackagesPerRegion(final ApiRegion apiRegion,
- final Clause[] exportedPackages,
- final Set<String> allPackages) throws MojoExecutionException {
+ public Set<Clause> computeUsedExportPackagesPerRegion(
+ final ApiRegion apiRegion, final Clause[] exportedPackages, final Set<String> allPackages)
+ throws MojoExecutionException {
final Set<Clause> result = new HashSet<>();
@@ -253,8 +260,10 @@ public class RegionSupport {
}
return manifest;
} catch (final IOException e) {
- throw new MojoExecutionException("An error occurred while reading manifest from file " + bundleFile
- + " for artifact " + artifactId.toMvnId(), e);
+ throw new MojoExecutionException(
+ "An error occurred while reading manifest from file " + bundleFile + " for artifact "
+ + artifactId.toMvnId(),
+ e);
}
}
@@ -271,13 +280,14 @@ public class RegionSupport {
final Set<Clause> packages = new LinkedHashSet<>();
final Manifest manifest = getManifest(artifact.getId(), artifactFile);
- if ( manifest.getMainAttributes().getValue(Constants.BUNDLE_MANIFESTVERSION) != null ) {
- for(final Clause c : getExportedPackages(manifest)) {
+ if (manifest.getMainAttributes().getValue(Constants.BUNDLE_MANIFESTVERSION) != null) {
+ for (final Clause c : getExportedPackages(manifest)) {
packages.add(c);
}
} else {
- final Set<String> names = ApisUtil.getPackages(ctx, artifactFile, ArtifactType.APIS.getContentExtension()).getKey();
- for(final String n : names) {
+ final Set<String> names = ApisUtil.getPackages(ctx, artifactFile, ArtifactType.APIS.getContentExtension())
+ .getKey();
+ for (final String n : names) {
packages.add(new Clause(n, null, null));
}
}
@@ -292,7 +302,9 @@ public class RegionSupport {
* @param usedExportedPackagesPerRegion Used exported packages
* @return {@code null} if the artifact can be used as a dependency
*/
- public String calculateOmitDependenciesFlag(final ApiRegion region, final Clause[] exportedPackageClauses,
+ public String calculateOmitDependenciesFlag(
+ final ApiRegion region,
+ final Clause[] exportedPackageClauses,
final Set<Clause> usedExportedPackagesPerRegion) {
// check whether all packages are exported in this region
String reason = null;
@@ -312,7 +324,9 @@ public class RegionSupport {
// check deprecation - if deprecation is set, artifact can't be used as a
// dependency
final ApiExport exp = region.getAllExportByName(c.getName());
- if (exp != null && (exp.getDeprecation().getPackageInfo() != null || !exp.getDeprecation().getMemberInfos().isEmpty())) {
+ if (exp != null
+ && (exp.getDeprecation().getPackageInfo() != null
+ || !exp.getDeprecation().getMemberInfos().isEmpty())) {
final String msg = "Package (or parts) ".concat(c.getName()).concat(" marked as deprecated.");
reason = reason == null ? msg : reason.concat(" ").concat(msg);
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/apis/spi/Processor.java b/src/main/java/org/apache/sling/feature/maven/mojos/apis/spi/Processor.java
index 7b75a63..95c41fe 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/apis/spi/Processor.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/apis/spi/Processor.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.apis.spi;
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/apis/spi/ProcessorContext.java b/src/main/java/org/apache/sling/feature/maven/mojos/apis/spi/ProcessorContext.java
index 7b81d17..d47d71e 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/apis/spi/ProcessorContext.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/apis/spi/ProcessorContext.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.apis.spi;
@@ -68,10 +70,10 @@ public interface ProcessorContext {
File getOutputDirectory();
/**
- * Add a resource to the binary or source artifact.
+ * Add a resource to the binary or source artifact.
* @param name The name of the resource, might contain slashes
* @param file The file to add
* @since 1.8.0
*/
void addResource(String name, File file);
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/apis/spi/Source.java b/src/main/java/org/apache/sling/feature/maven/mojos/apis/spi/Source.java
index 4116f92..e51926c 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/apis/spi/Source.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/apis/spi/Source.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.apis.spi;
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/reports/ContentsReporter.java b/src/main/java/org/apache/sling/feature/maven/mojos/reports/ContentsReporter.java
index fa6c4fa..f5f78b8 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/reports/ContentsReporter.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/reports/ContentsReporter.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.reports;
@@ -45,14 +47,14 @@ public class ContentsReporter implements Reporter {
for (final Feature feature : ctx.getFeatures()) {
for (final Artifact bundle : feature.getBundles()) {
- if ( ctx.matches(bundle.getId())) {
+ if (ctx.matches(bundle.getId())) {
bundles.add(bundle.getId());
}
}
for (final Extension ext : feature.getExtensions()) {
if (ext.getType() == ExtensionType.ARTIFACTS) {
for (final Artifact artifact : ext.getArtifacts()) {
- if ( ctx.matches(artifact.getId())) {
+ if (ctx.matches(artifact.getId())) {
artifacts.add(artifact.getId());
}
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/reports/DuplicatesReporter.java b/src/main/java/org/apache/sling/feature/maven/mojos/reports/DuplicatesReporter.java
index 41528b9..82f241d 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/reports/DuplicatesReporter.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/reports/DuplicatesReporter.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.reports;
@@ -44,27 +46,42 @@ public class DuplicatesReporter implements Reporter {
final Map<String, Set<String>> configMap = new TreeMap<>();
final Map<String, Set<String>> propsMap = new TreeMap<>();
- for(final Feature feature : ctx.getFeatures()) {
- for(final Extension ext : feature.getExtensions()) {
- if ( ext.getType() == ExtensionType.ARTIFACTS ) {
- for(final Artifact a : ext.getArtifacts()) {
+ for (final Feature feature : ctx.getFeatures()) {
+ for (final Extension ext : feature.getExtensions()) {
+ if (ext.getType() == ExtensionType.ARTIFACTS) {
+ for (final Artifact a : ext.getArtifacts()) {
final String key = a.getId().changeVersion("0").toMvnId();
- artifactMap.computeIfAbsent(key, k -> new HashSet<>()).add(feature.getId().getClassifier().concat("(").concat(a.getId().getVersion()).concat(")"));
+ artifactMap
+ .computeIfAbsent(key, k -> new HashSet<>())
+ .add(feature.getId()
+ .getClassifier()
+ .concat("(")
+ .concat(a.getId().getVersion())
+ .concat(")"));
}
}
}
- for(final Artifact a : feature.getBundles()) {
+ for (final Artifact a : feature.getBundles()) {
final String key = a.getId().changeVersion("0").toMvnId();
- bundleMap.computeIfAbsent(key, k -> new HashSet<>()).add(feature.getId().getClassifier().concat("(").concat(a.getId().getVersion()).concat(")"));
+ bundleMap
+ .computeIfAbsent(key, k -> new HashSet<>())
+ .add(feature.getId()
+ .getClassifier()
+ .concat("(")
+ .concat(a.getId().getVersion())
+ .concat(")"));
}
- for(final Configuration c : feature.getConfigurations()) {
- configMap.computeIfAbsent(c.getPid(), k -> new HashSet<>()).add(feature.getId().getClassifier());
+ for (final Configuration c : feature.getConfigurations()) {
+ configMap
+ .computeIfAbsent(c.getPid(), k -> new HashSet<>())
+ .add(feature.getId().getClassifier());
}
- for(final String a : feature.getFrameworkProperties().keySet()) {
- propsMap.computeIfAbsent(a, k -> new HashSet<>()).add(feature.getId().getClassifier());
+ for (final String a : feature.getFrameworkProperties().keySet()) {
+ propsMap.computeIfAbsent(a, k -> new HashSet<>())
+ .add(feature.getId().getClassifier());
}
}
final List<String> output = new ArrayList<>();
@@ -72,27 +89,29 @@ public class DuplicatesReporter implements Reporter {
outputDuplicates(output, "bundles", bundleMap);
outputDuplicates(output, "configurations", configMap);
outputDuplicates(output, "artifacts", artifactMap);
- if ( output.isEmpty()) {
+ if (output.isEmpty()) {
output.add("No duplicates found");
}
ctx.addReport(this.getName().concat(".txt"), output);
}
- private void outputDuplicates(final List<String> output, final String key, final Map<String, Set<String>> duplicates) {
+ private void outputDuplicates(
+ final List<String> output, final String key, final Map<String, Set<String>> duplicates) {
boolean writeHeader;
- if ( !duplicates.isEmpty() ) {
+ if (!duplicates.isEmpty()) {
writeHeader = true;
- for(final Map.Entry<String, Set<String>> entry : duplicates.entrySet()) {
- if ( entry.getValue().size() > 1 ) {
- if ( writeHeader ) {
+ for (final Map.Entry<String, Set<String>> entry : duplicates.entrySet()) {
+ if (entry.getValue().size() > 1) {
+ if (writeHeader) {
writeHeader = false;
output.add(key);
output.add("-------------------------------------------");
}
- output.add(entry.getKey().concat(" : ").concat(entry.getValue().toString()));
+ output.add(
+ entry.getKey().concat(" : ").concat(entry.getValue().toString()));
}
}
- if ( !writeHeader ) {
+ if (!writeHeader) {
output.add("");
}
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/reports/ExportPackagesReporter.java b/src/main/java/org/apache/sling/feature/maven/mojos/reports/ExportPackagesReporter.java
index 93a6452..b16abd5 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/reports/ExportPackagesReporter.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/reports/ExportPackagesReporter.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.reports;
@@ -40,7 +42,7 @@ public class ExportPackagesReporter implements Reporter {
@Override
public void generateReport(final ReportContext ctx) throws MojoExecutionException {
- for(final Feature feature : ctx.getFeatures()) {
+ for (final Feature feature : ctx.getFeatures()) {
FeatureDescriptor fd;
try {
fd = ctx.getScanner().scan(feature);
@@ -50,7 +52,7 @@ public class ExportPackagesReporter implements Reporter {
final List<String> exportedPackages = this.getExportedPackages(fd);
- if ( !exportedPackages.isEmpty() ) {
+ if (!exportedPackages.isEmpty()) {
ctx.addReport(fd.getFeature().getId().changeType("packages.txt").toMvnName(), exportedPackages);
}
}
@@ -63,15 +65,15 @@ public class ExportPackagesReporter implements Reporter {
for (final BundleDescriptor bd : fd.getBundleDescriptors()) {
for (PackageInfo p : bd.getExportedPackages()) {
String version = p.getVersion();
- if ( version == null ) {
+ if (version == null) {
version = "----";
}
String region = "----";
String deprecated = "";
if (regions != null) {
boolean found = false;
- for(final ApiRegion r : regions.listRegions()) {
- for(final ApiExport e : r.listExports()) {
+ for (final ApiRegion r : regions.listRegions()) {
+ for (final ApiExport e : r.listExports()) {
if (e.getName().equals(p.getName())) {
found = true;
region = r.getName();
@@ -82,21 +84,23 @@ public class ExportPackagesReporter implements Reporter {
break;
}
}
- if ( found ) {
+ if (found) {
break;
}
}
}
- packages.add(p.getName().concat(" ")
- .concat(version).concat(" ")
- .concat(bd.getArtifact().getId().toMvnId()).concat(" ")
- .concat(region)
- .concat(deprecated));
+ packages.add(p.getName()
+ .concat(" ")
+ .concat(version)
+ .concat(" ")
+ .concat(bd.getArtifact().getId().toMvnId())
+ .concat(" ")
+ .concat(region)
+ .concat(deprecated));
}
}
Collections.sort(packages);
return packages;
}
-
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/reports/ImportPackagesReporter.java b/src/main/java/org/apache/sling/feature/maven/mojos/reports/ImportPackagesReporter.java
index ef4535c..f46abed 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/reports/ImportPackagesReporter.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/reports/ImportPackagesReporter.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.reports;
@@ -36,7 +38,7 @@ public class ImportPackagesReporter implements Reporter {
@Override
public void generateReport(final ReportContext ctx) throws MojoExecutionException {
- for(final Feature feature : ctx.getFeatures()) {
+ for (final Feature feature : ctx.getFeatures()) {
FeatureDescriptor fd;
try {
fd = ctx.getScanner().scan(feature);
@@ -46,7 +48,7 @@ public class ImportPackagesReporter implements Reporter {
final List<String> importedPackages = this.getImportedPackages(fd);
- if ( !importedPackages.isEmpty() ) {
+ if (!importedPackages.isEmpty()) {
ctx.addReport(fd.getFeature().getId().changeType("imports.txt").toMvnName(), importedPackages);
}
}
@@ -58,7 +60,7 @@ public class ImportPackagesReporter implements Reporter {
for (final BundleDescriptor bd : fd.getBundleDescriptors()) {
for (final PackageInfo p : bd.getImportedPackages()) {
String version = p.getVersion();
- if ( version == null ) {
+ if (version == null) {
version = "any";
}
if (p.isOptional()) {
@@ -68,7 +70,12 @@ public class ImportPackagesReporter implements Reporter {
if (isUsedInExportedPackages(bd, p)) {
ext = " used-in-exports";
}
- packages.add(p.getName().concat(" ").concat(version).concat(" ").concat(bd.getArtifact().getId().toMvnId()).concat(ext));
+ packages.add(p.getName()
+ .concat(" ")
+ .concat(version)
+ .concat(" ")
+ .concat(bd.getArtifact().getId().toMvnId())
+ .concat(ext));
}
}
@@ -77,12 +84,11 @@ public class ImportPackagesReporter implements Reporter {
}
private boolean isUsedInExportedPackages(final BundleDescriptor bd, final PackageInfo p) {
- for(final PackageInfo exportedPackage : bd.getExportedPackages()) {
- if ( exportedPackage.getUses().contains(p.getName()) ) {
+ for (final PackageInfo exportedPackage : bd.getExportedPackages()) {
+ if (exportedPackage.getUses().contains(p.getName())) {
return true;
}
}
return false;
}
-
}
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/reports/ReportContext.java b/src/main/java/org/apache/sling/feature/maven/mojos/reports/ReportContext.java
index 5407aab..64b6100 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/reports/ReportContext.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/reports/ReportContext.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.reports;
@@ -20,8 +22,8 @@ import java.util.List;
import org.apache.sling.feature.ArtifactId;
import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.scanner.Scanner;
import org.apache.sling.feature.builder.ArtifactProvider;
+import org.apache.sling.feature.scanner.Scanner;
public interface ReportContext {
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/reports/Reporter.java b/src/main/java/org/apache/sling/feature/maven/mojos/reports/Reporter.java
index 56cca59..dc923d5 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/reports/Reporter.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/reports/Reporter.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.reports;
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/reports/ScriptsImportPackagesReporter.java b/src/main/java/org/apache/sling/feature/maven/mojos/reports/ScriptsImportPackagesReporter.java
index c054c78..bb23e4c 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/reports/ScriptsImportPackagesReporter.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/reports/ScriptsImportPackagesReporter.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.reports;
@@ -53,9 +55,10 @@ public class ScriptsImportPackagesReporter implements Reporter {
for (final Feature feature : ctx.getFeatures()) {
for (final Extension ext : feature.getExtensions()) {
- if (ext.getType() == ExtensionType.ARTIFACTS && Extension.EXTENSION_NAME_CONTENT_PACKAGES.equals(ext.getName())) {
+ if (ext.getType() == ExtensionType.ARTIFACTS
+ && Extension.EXTENSION_NAME_CONTENT_PACKAGES.equals(ext.getName())) {
for (final Artifact artifact : ext.getArtifacts()) {
- if ( ctx.matches(artifact.getId())) {
+ if (ctx.matches(artifact.getId())) {
artifacts.add(artifact.getId());
}
}
@@ -65,23 +68,26 @@ public class ScriptsImportPackagesReporter implements Reporter {
final List<String> report = new ArrayList<>();
- for(final ArtifactId id : artifacts ) {
+ for (final ArtifactId id : artifacts) {
final URL url = ctx.getArtifactProvider().provide(id);
- try ( final ZipInputStream zis = new ZipInputStream(url.openStream())) {
+ try (final ZipInputStream zis = new ZipInputStream(url.openStream())) {
ZipEntry entry = null;
while ((entry = zis.getNextEntry()) != null) {
if (entry.getName().startsWith(PREFIX)) {
final String path = entry.getName().substring(PREFIX.length() - 1);
- if (path.endsWith(".jsp") ) {
+ if (path.endsWith(".jsp")) {
final Set<String> imports = getImports(zis);
- for(final String imp : imports) {
- report.add(imp.concat(" ").concat(id.toMvnId()).concat(" ").concat(path));
+ for (final String imp : imports) {
+ report.add(imp.concat(" ")
+ .concat(id.toMvnId())
+ .concat(" ")
+ .concat(path));
}
}
}
}
} catch (final IOException ioe) {
- throw new MojoExecutionException("Unable to read from " + id.toMvnId(), ioe);
+ throw new MojoExecutionException("Unable to read from " + id.toMvnId(), ioe);
}
}
... 2721 lines suppressed ...