Maven build failing due to unrecognized `--settings` option - java

In my Java projects building with maven, I have a a .mvn directory that contains a maven.config file. Content of that file is as follows:
--settings ./.mvn/local-settings.xml
The local-settings.xml holds authentication credentials for pulling from a private registry.
This setup worked fine up until yesterday. Now, the CI build (using maven:3-amazoncorretto-17) is failing with the following error message:
Unable to parse maven.config file options: Unrecognized option: --settings ./.mvn/local-settings.xml
Has there been a breaking change in the maven image I am using for building?

With the introduction of maven 3.9, there was a BREAKING CHANGE that affects the parsing of the maven.config file:
https://maven.apache.org/docs/3.9.0/release-notes.html#potentially-breaking-core-changes
Each line in .mvn/maven.config is now interpreted as a single argument. That is, if the file contains multiple arguments, these must now be placed on separate lines, see MNG-7684.
As pointed out by #khmarbaise in the comments, adding a newline in the maven.config works just fine and is even downwards compatible.
--settings
./.mvn/local-settings.xml

Related

Unable to find out where reflections-maven plugin comes from

There executes a particular Maven plugin and I struggle to find out where it comes from to either remove or replace it as its compile dependency link is broken. I am talking about org.reflections:reflections-maven:0.9.8 that depends on org.jfrog.jade.plugins.common:jade-plugin-common:1.3.8 which Maven is not able to download from the central repository as the link redirects to OpenMind location and results in 404 (link).
Instead of including such JAR in the project structure, I would rather figure out where is reflections-maven plugin defined as this plugin is discontinued (GitHub) but somehow is executed during the build (mvn clean install).
[INFO] --- reflections-maven:0.9.5:reflections (default) # my-module ---
[INFO] Reflections took 240 ms to scan 1 urls, producing 35 keys and 128 values
[INFO] Reflections successfully saved in C:\Dev\my-project\my-parent\my-module\target\classes\META-INF\reflections\my-module-reflections.xml using XmlSerializer
I haven't found where is reflections-maven defined in any of the multi-module project structure or used. Note I use Maven 3.3.9. My attempts:
Skimming through all plugins and dependencies pom.xml of the failing module and all its parents (the module depends on other modules, however, they were all built successfully before the failing one).
mvn dependency:tree -Dverbose doesn't mention any of reflections-maven or jade-plugin-common at all. The command generates over 136k lines, so it was required to save the output into a file and perform the full-text-search. I am afras Maven 3 is the limit here as far as I understand from this comment.
Using depgraph-maven-plugin gave me the very same negative result.
mvn dependency:analyze -DignoreNonCompile gives only an information that the artifacts were resolved and that where it ends. it doesn't really show anything useful.
[INFO] --- reflections-maven:0.9.5:reflections (default) # my-module ---
[IJ]-1-ARTIFACT_RESOLVING-[IJ]-path=-[IJ]-artifactCoord=org.reflections:reflections-maven:pom:0.9.5-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVED-[IJ]-path=C:\Users\user\.m2\repository\org\reflections\reflections-maven\0.9.5\reflections-maven-0.9.5.pom-[IJ]-artifactCoord=org.reflections:reflections-maven:pom:0.9.5-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVING-[IJ]-path=-[IJ]-artifactCoord=org.reflections:reflections-maven:jar:0.9.5-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVED-[IJ]-path=C:\Users\user\.m2\repository\org\reflections\reflections-maven\0.9.5\reflections-maven-0.9.5.jar-[IJ]-artifactCoord=org.reflections:reflections-maven:jar:0.9.5-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVING-[IJ]-path=-[IJ]-artifactCoord=org.reflections:reflections:jar:0.9.5-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVED-[IJ]-path=C:\Users\user\.m2\repository\org\reflections\reflections\0.9.5\reflections-0.9.5.jar-[IJ]-artifactCoord=org.reflections:reflections:jar:0.9.5-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVING-[IJ]-path=-[IJ]-artifactCoord=com.google.guava:guava:jar:r08-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVED-[IJ]-path=C:\Users\user\.m2\repository\com\google\guava\guava\r08\guava-r08.jar-[IJ]-artifactCoord=com.google.guava:guava:jar:r08-[IJ]-error=
...
[IJ]-1-ARTIFACT_RESOLVING-[IJ]-path=-[IJ]-artifactCoord=org.jfrog.maven.annomojo:maven-plugin-anno:jar:1.4.0-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVED-[IJ]-path=C:\Users\user\.m2\repository\org\jfrog\maven\annomojo\maven-plugin-anno\1.4.0\maven-plugin-anno-1.4.0.jar-[IJ]-artifactCoord=org.jfrog.maven.annomojo:maven-plugin-anno:jar:1.4.0-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVING-[IJ]-path=-[IJ]-artifactCoord=org.jfrog.jade.plugins.common:jade-plugin-common:jar:1.3.8-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVED-[IJ]-path=C:\Users\user\.m2\repository\org\jfrog\jade\plugins\common\jade-plugin-common\1.3.8\jade-plugin-common-1.3.8.jar-[IJ]-artifactCoord=org.jfrog.jade.plugins.common:jade-plugin-common:jar:1.3.8-[IJ]-error=
...
Checking the artifacts using the reflections-maven from here, however, none of the artifacts mentioned appear in my project as well.
Question: If I don't have such JAR in the local repository, the build fails as the plugin is executed. In that case, how can I find a way any plugin (particularly reflections-maven in my case) is truly imported and executed in the project?
Feel free to ask for more info in the commens. I use IntelliJ Idea, Maven 3.3.9 and Java 7 if it matters.
Solution 1 (didn't work for me): I have tried to run mvn -Dverbose=true -Doutput=./effective-pom.xml help:effective-pom and both the normal and the verbose form of effective-pom displays the same output of reflections-maven plugin with no additional information about its origin. Since the file is rather big, I include a screenshot:
This might be an issue with my Maven 3.3.9 with a custom settings.xml and a specific IntelliJ Idea. I assume the verbose output would lead to the true origin.
Solution 2:
Upon installing Netbeans (I use IntelliJ Idea by default), the Effective tab of the POM editor finally led me to the true origin where the plugin is defined.
Sadly, IntelliJ Idea doesn't provide such navigation through its effective POM and navigating to the origin is virtually impossible without manual clicking through parent POMs.
With
Help:Effective-Pom:
mvn -Dverbose=true -Doutput=./effective-pom.xml help:effective-pom
We can analyze our "effective pom" (Pom#inheritance, Pom#super-Pom).
The verbose flag will also add the source pom (artifact) as a comment to each output line.
output sets an output file. (default: prints to console)
"inter alia" it allows us to locate/override any inherited plugin/dependency/"pom element".
Unfortunately the output generates:
for "trivial" projects "hundreds" lines of pom.
for "non-trivial" (spring-boot-starter), it gets easily into "ten-thousands" (lines of pom).
In intellij we have a "Show effective Pom" command, which basically invokes the mentioned goal and shows the output (in community edition unfortunately!?) without "verbose".
netbeans has a "Effective" tab in its "Pom Editor":
scrolling/cursoring is here also "cumbersome", but we have "full":
"Navigation" (window) support
Text search
Code hints, etc...
(, "Graph" view also very nice...(and unique feature among "maven IDES (that i know)", and it can be installed un-rooted;)!
Update:
So the mojo seems to work as documented:
<verbose> boolean (since:)3.2.0 Output POM input location as comments.
Default value is: false.
User property is: verbose.
For verbose to have an effect, we need to:
<project ...>
...
<build>
<plugins>
<artifactId>maven-help-plugin</artifactId>
<version>3.2.0</version> <!-- or higher! -->
</plugins>
</build>
...
</project>
... respectively can (without pom modification):
mvn -Dverbose=true -Doutput=./eff.pom.xml \
org.apache.maven.plugins:maven-help-plugin:3.2.0:effective-pom

Changelog path resolving in Liquibase maven plugin

I've got one problem with liquibase-maven-plugin 4.2.2. If I specify the path to logs like it was before
changeLogFile= classpath:db/changelog/db.changelog-master.xml
I'm getting an error
Error Reading Changelog File: Found 2 files that match classpath:db/changelog/db.changelog-master.xml: jar:file:/Users/macbook/IdeaProjects/geek-study-eshop/shop-database/target/shop-database-1.0-SNAPSHOT.jar!/db/changelog/db.changelog-master.xml, file:/Users/macbook/IdeaProjects/geek-study-eshop/shop-database/target/classes/db/changelog/db.changelog-master.xml
I understand the reason for this error and it possible to resolve it by changing changeLogFile to target/db/changelog/db.changelog-master.xml. But in this case, I will have target\ prefix in filenames stored in DATABASECHANGELOG table. But I don't want that for some reasons. I want all file names there to be with prefix db/changelog/... or classpath:db/changelog/.... Is that possible to do that somehow without using logicFilePath attribute?
I found the solution! There is no way to change liquibase-maven-plugin behavior but it's possible to change maven phase on which we run liquibase:diff command. Simply use mvn clean compile liquibase:diff! We are doing diff after compilation and resource movement but before the jar packaging.

Serenity Bdd Report not getting generated after testcase is success- (In Eclipse and Jenkins both)

I have created a BDD test case in Eclipse and the maven build for the test case is a success. I have also created this same project as a maven job in Jenkins and the build is success for it as well.
Generally from what I have studied, the report should be located in Target>Site>Serenity but for me the report is not getting generated in that location.
In Eclipse, there is no error in console log and it shows the following:
Generating reports view to 'C:\Dev..\target\jbehave' using formats '[stats,console,html,xml,serenityreporter,junitscenarioreporter]' and view properties'{decorateNonHtml=true}'
(I checked and saw that a file named index.html is getting formed in target>jbehave>view folder but that file doesn't have any report contents.)
In Jenkins the console log shows the following:
Error: Specified HTML directory 'C:/Jenkins/workspace/Devops/.../target/site/serenity does not exit.
Build step'Publish HTML reports' changed build result to FAILURE.
Finished:FAILURE
I had given the report path in Jenkins in -Post Build Actions- as target>site>serenity initially but seeing that the report instead might be in jbehave folder I changed the path ,but still got the following error:
Error: Specified HTML directory 'C:/Jenkins/workspace/Devops/.../target/jbehave/view does not exit.
Build step'Publish HTML reports' changed build result to FAILURE.
Finished:FAILURE
Things checked:
1)Checked Jenkins- "the HTML Publisher Plugin" version 1.23 is present. So report should be generated.
For Eclipse:
Following properties used in pom.xml:
serenity.version-1.8.21, serenity.maven.version-1.8.21, serenity.jbehave.version-1.35, a-maven-plugin.version=4.1.1
Giving both maven-surefire-plugin and maven-failsafe-plugin(version2.18) in pom.xml
Giving "clean verify serenity:aggregate" in goals in run configuration.
In serenity.properties file added the following 2 lines in an attempt to generate report in an alternate location but still no reports or new folder with report generated.
`serenity.test.root = "net.bdd project"
serenity.outputDirectory = target/site/reports`
What could be the reason for report not getting generating in proper location?
Is it the properties versions in pom.xml? or something else to be added in serenity.properties?
My understanding is that the default location for test report is to be in target>site>serenity. Is there a way we can manually configure this?
If the report is generated in eclipse, will it get generated in jenkins too? (using the same project through git in jenkins)
Please provide some inputs as this is my 1st test case and 1st time working on bdd! Really appreciate it. Thanks!
I resolved the above issue and I managed to generate the report in Jenkins.
I did the following:
1)Changed the versions in properties in pom.xml file to the following:
serenity.version-1.2.4, serenity.maven.version-1.2.4, serenity.jbehave.version-1.1.0, a-maven-plugin.version=4.3.1
2)In Jenkins post build config, I changed the following:
<alwayslinktolastbuild> true </alwayslinktolastbuild> <keepAll>true</KeepAll> <reportDir>${WORKSPACE}/target/site/serenity</reportDir>
Hope this helps! Thanks! :)

Cannot run Flume because of JAR conflict

I've installed Flume and Hadoop manually (I mean, not CDH) and I'm trying to run the twitter example from Cloudera.
In the apache-flume-1.5.0-SNAPSHOT-bin directory, I start the agent with the following command:
bin/flume-ng agent -c conf -f conf/twitter.conf -Dflume.root.logger=DEBUG,console -n TwitterAgent
My conf/twitter.conf file uses the logger as the sink. The conf/flume-env.sh assigns to CLASSPATH the flume-sources-1.0-SNAPSHOT.jar that contains the definition of the twitter source. The resulting output is:
(...) [ERROR org.apache.flume.lifecycle.LifecycleSupervisor$MonitorRunnable.run(LifecycleSupervisor.java:253)] Unable to start EventDrivenSourceRunner: { source:com.cloudera.flume.source.TwitterSource{name:Twitter,state:IDLE} } - Exception follows. java.lang.NoSuchMethodError:
twitter4j.FilterQuery.setIncludeEntities(Z)Ltwitter4j/FilterQuery;
at com.cloudera.flume.source.TwitterSource.start(TwitterSource.java:139)
The conflict results from a FilterQuery class that is defined elsewhere in the flume lib and that does not contain the setIncludeEntities method. For me, the file that contains this class is the twitter4j-stream-3.0.3.jar and I cannot exclude the file from the classpath as suggested here.
I believe this experience was quite frustrating for you, for me it was for sure. The main problem is, both the files, flume-sources-1.0-SNAPSHOT.jar and twitter4j-stream-3.0.3.jar contains the same FilterQuery.class. That is why the conflict message is generated in the log file.
I am not a Java or Big Data expert, but I can give you an alternate to this problem. Download the Twitter4j-stream-2.6.6.jar or lower version from here and replacethe twitter4j-stream-3.0.3.jar. All the 3.X.X uses this class. After replacing, everything should work fine. But you may get some heap error after downloading huge amount of tweets. Please google the solution as it was resolved in 3.X.X files.
-Edit
Also, please don't forget to download and replace all the twitter4j files in /usr/lib/flume-ng folder. Namely, twitter4j-media-support-2.2.6.jar, twitter4j-stream-2.2.6.jar and twitter4j-core-2.2.6.jar. Any mismatch related to version among these files will also create problem.
As suggested in the post a problematic file can be search-contrib-1.0.0-jar-with-dependencies.jar too.
You need to recompile flume-sources-1.0-SNAPSHOT.jar from the git:https://github.com/cloudera/cdh-twitter-example
Install Maven, then download the repository of cdh-twitter-example.
Unzip, then execute inside (as mentionned) :
$ cd flume-sources
$ mvn package
$ cd ..
This problem happened when the twitter4j version updated from 2.2.6 to 3.X, they removed the method setIncludeEntities, and the JAR is not up to date.
PS: Do not download the prebuilt version, it is still the old.
Simply rename all twitter4j-stream* jar files and rerun your flume. It will work with charm. :)
I had the same problem and at last I solved following these steps:
First I renamed all jar files in jarx: from twitter4j-stream-3.0.3.jar -> twitter4j-stream-3.0.3.jarx, ...
This solved the error, but when it tried to estabilish connection, I got error 404:
(Twitter Stream consumer-1[Establishing connection])
[INFO - Twitter4j.internal.logging.SLF4JLogger.info(SLF4JLogger.java:83)] 404:
The URI requested is invalid or the resource requested, such as a user, does not exist.)
After reading this page (https://twittercommunity.com/t/twitter-streaming-api-not-working-with-twitter4j-and-apache-flume/66612/11) finally I solved downloading a new version of twitter4j (in the page there's a link).
Probably not the best solution, but worked for me.

The command line is too long. in java project with maven

I have maven-gwt project. It has lots of dependencies which is usual by a large project. I think it is at the limit with creation of classpath. I found some information about the limitation. Allowed is 1023 Character. But I need the libraries.
I receive the following error when i want to package my project mit Maven.
The command line is too long.
How can I get around the problem.?
Here is the expanded error in Jenkins:
[INFO] --- maven-surefire-plugin:2.5:test (default-test) # MyProject ---
[INFO] Surefire report directory: C:\Documents and Settings\User\.jenkins\workspace\Myproject\target\surefire-reports
The command line is too long.
The command line is too long.
[ERROR] There are test failures.
I found another workaround here http://code.google.com/p/gwt-maven/issues/detail?id=88
(I have problem with changing pom to fit a specific OS)
In short: make path to local repository as short as possible.
"
Comment 40 by gaurav.a...#gmail.com, Mar 23, 2009
One of the fix to the problem of "GWT compilation fails due to- The input line is
too long." is as follows:
Change m2(maven) repository. You might have your maven
repository at:
C:\Documents and Settings\MahcineNameABC\.m2
Copy settings.xml file from folder
apache-maven-2.0.8\apache-maven-2.0.8\conf into C:\Documents and Settings\MahcineNameABC\.m2
In settings.xml:
change the tag as
<localRepository>M:</localRepository>. Now your m2 home is a virtual M drive.
Create a repository folder as D:\maven-2.0.8\repository
Cut/Copy all the files/folders from C:\Documents and Settings\MahcineNameABC\.m2\repository to D:\maven-2.0.8\repository
Map local drive: open command prompt and execute (to create the
virtual drive):
subst M: D:\maven-2.0.8\repository(help)
Now a virtual M drive will point to your repository.
Set environment variable M2_REPO with value M:
To enable long inputs, on command prompt execute:cmd /e:32768
This would fix the problem of long inputs due to very long entries in classpath
variables, at least in Win XP SP2. The inputs are combined and tested from comment#22
and #7.
Hope it helps!
This should help in most cases (and 'til the end of project - at least in my case)
This seems to be a known problem with gwt-maven. There is a discussion on the gwt-maven google groups: Workaround for windows command line length limit
The problem seems to be that the sources are included on the test classpath, hence you're getting problems when you're running surefire:
The workaround is to exclude the sources dependency, make it system scope (from the above thread):
<dependency>
<!-- non existant artifact ID required (-source) maven bug?? -->
<artifactId>myproject-rpc-source</artifactId>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<classifier>sources</classifier>
<!-- hack below as maven only incudes provdied in test scope -->
<scope>system</scope>
<systemPath>${basedir}/../rpc/target/myproject-rpc-${project.version}-sources.jar</systemPath>
</dependency>
but I would fully read and understand the google groups thread before proceeding with this.
If you are using Intellij there is a setting in workspace.xml that takes care of this issue. There is an existing post about this.
From 2.5.0-rc1 the GWT Maven plugin has a new option: "genParam". Set this param to false to aviod this problem.

Categories

Resources