I am trying to generate aggregate javadoc for multiple projects with Maven Javadoc plugin. If I run javadoc:javadoc goal the build finishes with SUCCESS. Anyhow I would like to combine all javadocs with javadoc:aggregate goal and it fails when trying to find org.jboss.msc.service package:
org.apache.maven.reporting.MavenReportException:
Exit code: 1 - /home/me/proj/proj/subproject1/src/main/java/com/test/hasingleton/HATimerServiceActivator.java:6: error: package org.jboss.msc.service does not exist
import org.jboss.msc.service.DelegatingServiceContainer;
How can I configure the maven javadoc plugin to exclude this import? I have tried with following settings:
<excludePackageNames>org.jboss.msc.service.*</excludePackageNames>
<dependencySourceExcludes>
<dependencySourceExclude>org.jboss.msc.service:*</dependencySourceExclude>
</dependencySourceExcludes>
But no luck. All help is appreciated!
You could try this way (include instead of exclude)
<configuration>
<!-- switch on dependency-driven aggregation -->
<includeDependencySources>true</includeDependencySources>
<dependencySourceIncludes>
<!-- include ONLY dependencies I control -->
<dependencySourceInclude>org.test.dep:*</dependencySourceInclude>
</dependencySourceIncludes>
</configuration>
Other way is to use artifact id (rather than package name)
<configuration>
<!-- switch on dependency-driven aggregation -->
<includeDependencySources>true</includeDependencySources>
<dependencySourceExcludes>
<!-- exclude ONLY commons-cli artifacts -->
<dependencySourceExclude>commons-cli:*</dependencySourceExclude>
</dependencySourceExcludes>
</configuration>
Related
I am trying to build my code and I am getting this error:
[WARNING] Unused declared dependencies found:
[WARNING] com:test-client:jar:v1.0-SNAPSHOT:compile
This is the configuration of the dependency plugin in my pom:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>analyze</id>
<goals>
<goal>analyze-only</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- <usedDependencies>-->
<!-- <usedDependency>com:test-client</usedDependency>-->
<!-- </usedDependencies>-->
<failOnWarning>true</failOnWarning>
<ignoreNonCompile>true</ignoreNonCompile>
<ignoredUnusedDeclaredDependencies>
<!-- <ignoredUnusedDeclaredDependency>*:test-client:*</ignoredUnusedDeclaredDependency>-->
</ignoredUnusedDeclaredDependencies>
</configuration>
</plugin>
I tried to add the test-client to the flag ignoredUnsedDeclaredDependecy (see the commented part) but still getting error.
I tried to set the failOnWarning flag to false but also I get same warning.
When I added this section it works.
<usedDependencies>
<usedDependency>com:test-client</usedDependency>
</usedDependencies>
But why the 2 other flags are not being taken?
Note that I am working in a multi module project and this is a child pom of a parent pom.
failOnWarning makes the maven build fail if a warning was generated, it doesn't remove or prevent the warnings. See https://maven.apache.org/plugins/maven-dependency-plugin/examples/failing-the-build-on-dependency-analysis-warnings.html
Regarding the configuration of exlusions, see https://maven.apache.org/plugins/maven-dependency-plugin/examples/exclude-dependencies-from-dependency-analysis.html
That gives an example like so;
<configuration>
<failOnWarning>true</failOnWarning>
<!-- ignore jsr305 for "used but undeclared", "declared but unused", and "non-test scoped" -->
<ignoredDependencies>
<ignoredDependency>com.google.code.findbugs:jsr305</ignoredDependency>
</ignoredDependencies>
<!-- ignore annotations for "used but undeclared" warnings -->
<ignoredUsedUndeclaredDependencies>
<ignoredUsedUndeclaredDependency>com.google.code.findbugs:annotations</ignoredUsedUndeclaredDependency>
</ignoredUsedUndeclaredDependencies>
<!-- ignore annotations for "unused but declared" warnings -->
<ignoredUnusedDeclaredDependencies>
<ignoredUnusedDeclaredDependency>com.google.code.findbugs:annotations</ignoredUnusedDeclaredDependency>
</ignoredUnusedDeclaredDependencies>
<!-- ignore annotations for "non-test scoped" warnings -->
<ignoredNonTestScopedDependencies>
<ignoredNonTestScopedDependency>com.google.code.findbugs:annotations</ignoredNonTestScopedDependency>
</ignoredNonTestScopedDependencies>
</configuration>
So your syntax should be correct.
Do you depend on the latest version of the plugin? If not, try to update the version number to the most recent one you have access to: https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-dependency-plugin
ignoredUnusedDeclaredDependencies was added in the plugin version 2.10 and ignoredNonTestScopedDependencies since 3.3.0.
Also check if your wildcard filter syntax is correct according to https://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html
I figured out what was the issue! my settings were override by the parent pom, why so? because in the parent pom the configuration is written under execution, however in my pom the configuration is outside execution (directly under plugin) when I moved the configuration in my plugin under the execution, my settings were taken into consideration
I'm trying to create a custom maven artefact that creates a basic Java Handler for AWS Lambda. One of the files in my archetype-resources is a serverless.yml file as we are looking to deploy this handler using the ServerLess Framework. I want this file to be part of a filtered=true fileSet as I want to pre-populate certain fields based on the project groupId, projectId etc. Here's a sample:
service: cmpy-prefix-${groupId}-${artifactId}-service
# exclude the code coverage files and circle ci files
package:
exclude:
- coverage/**
- .circleci/**
...
profider:
...
environment:
S3_BUCKET_NAME: ${self:provider.stage}-cmpy-bkt
And I add this file to src/main/resources/META-INF/maven/archetype-metadata.xml as follows:
<fileSet encoding="UTF-8" filtered="true" packaged="false">
<directory></directory>
<includes>
<include>serverless.yml</include>
</includes>
</fileSet>
Now my problem is that serverless.yml file contains ${self:provider.stage} which interfere's when I run maven:generate for this archetype and the error I get is:
org.apache.velocity.exception.ParseErrorException: Encountered ":provider.stage}-cmpy-bkt\...
I tried to set the <delimiter> for the maven-resource-plugin in the pom.xml for my main archetype to no avail. Essentially, I added the following to the pom of the archetype project:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${org.apache.maven.plugins.maven-resources-plugin.version}</version>
<configuration>
<addDefaultExcludes>false</addDefaultExcludes>
<delimiters>$[*]</delimiters>
</configuration>
</plugin>
</plugins>
</build>
But I still face the same problem when I try to generate a new project using this archetype. The maven archetype plugin seems to be ignoring the delimiter.
Any advice/help on how I can fix this will be immensely appreciated.
Found the solution. I had not realised I could add Velocity directives in my archetype files.
See this other Stackoverflow post for hints Maven archetype strips comments
After adding module-info.java files to my project my checkstyle plugin start failing with:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check
(default-cli) on project email: Failed during checkstyle
configuration: NoViableAltException occurred during the analysis of
file
/home/xxx/IdeaProjects/blynk-server/server/notifications/email/src/main/java/module-info.java.
unexpected token: module -> [Help 1]
I tried
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>
However, it failed with:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check
(default-cli) on project blynk: Failed during checkstyle
configuration: cannot initialize module
BeforeExecutionExclusionFileFilter - Unable to instantiate
'BeforeExecutionExclusionFileFilter' class, it is also not possible to
instantiate it as
com.puppycrawl.tools.checkstyle.checks.annotation.BeforeExecutionExclusionFileFilter
What is the correct way for skipping module-info.java files during checkstyle for maven-checkstyle-plugin?
Not sure why the Checkstyle filter is not working (this reported bug seems very similar to yours and it was fixed in version 7.3.0, so maybe you need to update Checkstyle).
Anyway the Maven excludes element is also supposed to do this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<excludes>**/module-info.java</excludes>
</configuration>
</plugin>
More in the plugin goal documentation.
BeforeExecutionExclusionFileFilter was added in Checkstyle 7.2.
But the maven-checkstyle-plugin version 3.0.0 (which is the latest version as of 2018-04-01) uses Checkstyle 6.18 by default.
"Checkstyle" and "Checkstyle Maven Plugin" are different things and have different release cycles.
You may want to upgrade the Checkstyle version as follows:
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version> <!-- Checkstyle Plugin version -->
<!-- ... Configuration, Executions ... -->
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.8</version> <!-- Checkstyle version -->
</dependency>
</dependencies>
</plugin>
After that, BeforeExecutionExclusionFileFilter as well as other newer Checkstyle features (e.g. new checks) will be recognized.
Though this doesn't possibly qualify as an answer. Yet being too long to fit in comment, just to keep a note of the track that the maven-checkstyle-plugin is in:-
The last release of the was version 2.17 on 15-Oct-2015 which was almost 2 years back.
The current trunk of maven-plugins points to an ongoing work within the plugin in its 3.0.0-SNAPSHOT version which might mean we can soon expect a org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0 sometime in near future and which would understand the module-info.java as a class.
This doesn't align with the Java+9+-+Jigsaw doc that specifies the list of modules and plugins that are being upgraded to support JDK-9.
I am using Tycho and Maven to build an eclipse update site containing several plugins. Everything worked happily when I packaged it as an eclipse-update-site, but I'm getting errors now that I've switched to eclipse-repository.
My projects looks like
com.mycompany.plugin/
src/things.java
pom.xml
com.mycompany.plugin.feature/
feature.xml
pom.xml
com.mycompany.updatesite/
category.xml (formerly site.xml)
pom.xml
This page indicates that the maven packaging "eclipse-update-site" is deprecated in favor of "eclipse-repository". Accordingly, I updated my update site's pom.xml to look like (approximately):
<project>
<tycho.version>0.26.0</tycho.version>
<groupId>mygroup</groupId>
<artifactId>artifactId</artifactId>
<version>1.0.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-repository-plugin</artifactId>
<version>${tycho.version}</version>
</plugin>
</plugins>
</build>
<packaging>eclipse-repository</packaging>
</project>
I also renamed my site.xml file to category.xml as suggested by this post and this post. I did not make any other changes to category.xml (formerly site.xml), so it looks like:
<?xml version="1.0" encoding="UTF-8"?>
<site>
<feature url="features/com.mycompany.plugin.feature_0.1.0.qualifier.jar" id="com.mycompany.plugin.feature" version="0.1.0.qualifier">
<category name="com.mycompany"/>
</feature>
<category-def name="com.mycompany" label="MyPlugin"/>
</site>
The maven build marches along happily, building all of my plugins and features. When it tries to build the repository, it fails, saying:
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-p2-repository-plugin:0.26.0:assemble-repository
(default-assemble-repository) on project com.mycompany.updatesite: Could not assemble p2 repository:
Mirroring failed: No repository found at file:/mypath/com.mycompany.updatesite/target/. -> [Help 1]
Clearly I'm missing something, but I can't figure out what.
Which phases of maven are you running?
I encountered the same problem when switching from eclipse-update-site to eclipse-repository and using just the package phase. However, it worked with install.
Or more specifically instead of
mvn clean package
I used
mvn clean install
I hope this helps you too.
I am using the maven-jspc-plugin in my pom.xml.
When i try to execute the jsp-compile goal (which executes the plugin) I get:
Caused by: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.apache.juli.logging.Slf4jLog.<init>(Slf4jLog.java:29)
at org.apache.juli.logging.LogFactory.getLog(LogFactory.java:54)
at org.apache.juli.logging.LogFactory.getLog(LogFactory.java:35)
at org.apache.sling.scripting.jsp.jasper.compiler.OriginalTldLocationsCache.<init>(OriginalTldLocationsCache.java:81)
at org.apache.sling.maven.jspc.JspcMojo.initServletContext(JspcMojo.java:426)
I've tried downloading the (open) source for the maven-jspc-plugin and i am able to easily "mvn install" -- I don't get any build issues, however when i use that build in my project pom it still crashes and tells me it can't find LoggerFactory.
I've logged an issue with the Apache Sling project but am not making much headway.
https://issues.apache.org/jira/browse/SLING-2350
This link includes some more troubleshooting info as well as a simple maven project that uses the maven plugin. downloading the jspc-test.zip and "mvn install"ing will result in the error I've mentioned.
Also, i took a peak at the org.apache.juli pom.xml and it doesnt appear to list any dependencies at all.
Any thoughts on how to resolve would be appreciated.
Thanks!
Plugin dependencies are supplied in a different part of the POM:
<project>
<dependencies>
<!-- dependencies defined here don't get included for plugins -->
...
</dependencies>
<build>
<plugins>
<plugin>
.... jspc plugin section ....
<dependencies>
<dependency>
<!-- Try adding slf4j here --->
Though it does sounds like their POM is invalid if it doesn't already specify slf4j.