Capturing standards out of a class run by mvn exec:java - java

I would like to run a main method using Maven's exec command. I can set it up to run just fine, but the output of my class is surrounded by Maven's text.
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING]
...
(actual program output)
...
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.351s
[INFO] Finished at: Fri Apr 01 11:38:15 PDT 2011
[INFO] Final Memory: 50M/452M
[INFO] ------------------------------------------------------------------------
Is there a way to just capture just the program output and not the Maven output? Or do I need to rewrite my software to write to a file (not ideal)?

Execute mvn with the -q flag to silence Maven's output.

There's no good solution to this. It's just how the exec plugin works. You could use the exec goal and run a shell script that redirected the output.

Related

Maven fails to compile QuestDB from source with 'ambiguous reference to Record'

I've been running QuestDB from docker, but to try latest version from master, I followed documentation on GitHub but cannot build from source. The output from the console when I try run any maven commands (mvn clean test or build) looks like:
[INFO] QuestDB core 5.0.6-SNAPSHOT ........................ FAILURE [ 7.103 s]
[INFO] JMH benchmarks for QuestDB 1.0 ..................... SKIPPED
[INFO] QuestDB 5.0.6-SNAPSHOT ............................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.192 s
[INFO] Finished at: 2021-01-13T15:14:10+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project questdb: Compilation failure: Compilation failure:
[ERROR] /Users/fmay/proj/qdb/questdb/core/src/main/java/io/questdb/griffin/engine/functions/SymbolFunction.java:[50,39] error: reference to Record is ambiguous
...
I'm trying to build using latest Mac os 11.1.
QuestDB needs to be built with Java 11, check which version is running with
java -version
If you have something different and you use homebrew, you can use brew to install openJDK 11 with
brew install openjdk#11

Why my maven package triggered by Jenkins failed but can be success if I manually execute it?

I have a jenkins job which tend to build my java application using maven, but it always gets failure during the compile phase.
[[1;34mINFO[m] Changes detected - recompiling the module!
[[1;34mINFO[m] Compiling 550 source files to /var/lib/jenkins/workspace/test/target/classes
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;34mINFO[m] [1;31mBUILD FAILURE[m
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;34mINFO[m] Total time: 9.575 s
[[1;34mINFO[m] Finished at: 2017-12-02T07:47:47+08:00
[[1;34mINFO[m] Final Memory: 24M/346M
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;33mWARNING[m] The requested profile "nexus" could not be activated because it does not exist.
[[1;31mERROR[m] Failed to execute goal [32morg.apache.maven.plugins:maven-compiler-plugin:3.1:compile[m [1m(default-compile)[m on project [36mtest[m: [1;31mCompilation failure[m -> [1m[Help 1][m
[[1;31mERROR[m]
I find and copied the below command in the Jenkins job's console output(on the webpage).
/opt/apache-maven-3.5.0/bin/mvn -f pom.xml -s /var/lib/jenkins/test-maven-setting/setting.xml -gs /var/lib/jenkins/test-maven-setting/setting.xml -Dmaven.repo.local=/var/lib/jenkins/workspace/test/.repository clean package
Then I switched to the jenkins user in the Linux console and go to the job's workspace directory and tried to manually execute the above commands I copied.
but it success!
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.994 s
[INFO] Finished at: 2017-12-02T07:50:17+08:00
[INFO] Final Memory: 35M/298M
so it's very strange, same commands, same user, same directory, but it can success when I execute it manually while fail when Jenkins build the job. Does anyone know what's the problem that Jenkins job failed?
here I retested the maven plugin and pasted some screenshots.
You as using "use default maven settings" option in invoke-maven-targets.
select option for "settings file in filesystem" for both default and global

Maven release plugin. branch release fails (+ missing first letter of branch name)

Added
If my branch is default, maven:prepare completed successfully.
/Added
I have maven project in Idea. Using mercurial.
I have created branch "MAVEN_RELEASE" to try to release it with maven-release-plugin. And got the following error. Please follow the hg push line. Is cause of the problem is AVEN_RELEASE (no first letter)?
[INFO] [INFO] BUILD SUCCESS
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 02:16 min
[INFO] [INFO] Finished at: 2016-05-12T17:53:53+06:00
[INFO] [INFO] Final Memory: 63M/216M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] Checking in modified POMs...
[INFO] EXECUTING: cmd.exe /X /C "hg branch"
[INFO] EXECUTING: cmd.exe /X /C "hg outgoing"
[WARNING] A different branch than AVEN_RELEASE was found in outgoing changes, branch name was MAVEN_RELEASE. Only local branch named AVEN_RELEASE will be pushed.
[INFO] EXECUTING: cmd.exe /X /C "hg commit --message "[maven-release-plugin] prepare release sea-bni-1.0.5" C:\EA\IdeaProjects\sea-eclipse\pom.xml C:\EA\IdeaProjects\sea-eclipse\jnlp-apps\pom.xml C:\EA\IdeaProjects\sea-eclipse\jnlp-apps\arm-data-entry\pom.xml C:\EA\IdeaProjects\sea-eclipse\jnlp-apps\sea-print\pom.xml C:\EA\IdeaProjects\sea-eclipse\sea-web\pom.xml C:\EA\IdeaProjects\sea-eclipse\the-ear\pom.xml"
[INFO] EXECUTING: cmd.exe /X /C "hg push -rAVEN_RELEASE http://oksapp.bingo.ru/hg/sea-eclipse"
[ERROR]
EXECUTION FAILED
Execution of cmd : push failed with exit code: 255.
Working directory was:
C:\EA\IdeaProjects\sea-eclipse
Your Hg installation seems to be valid and complete.
Hg version: 3.5.2 (OK)
Second question, please:
2) Should I do deploy action before doing maven release prepeare, perform?
Should be resolved in maven-scm-plugin version 1.9.5, but I have no luck using it... https://issues.apache.org/jira/browse/SCM-682

Error while building Hadoop src using maven

I want to install hadoop single node setup on windows7 64 bit. I have installed cygwin, windows SDK 7.1, maven 3.1.1 and jdk 1.6.33.
Running Hadoop single node setup on windows 7 is very trooublesome.
While buiding the "mvn package -Pdist,native-win -DskipTests -Dtar" i am getting below error.
Can someone help how to fix this error or any other way to build hadoop on windows 7 64 bit?
portion of the Error log is as follows:
[INFO] Apache Hadoop Main ................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 41.461s
[INFO] Finished at: Wed Jun 11 19:42:25 IST 2014
[INFO] Final Memory: 53M/339M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.
5.1:compile (default-compile) on project hadoop-common: Compilation failure: Com
pilation failure:
[ERROR] D:\hdfs\hadoop-common-project\hadoop-common\src\main\java\org\apache\had
oop\ipc\protocolPB\RefreshCallQueueProtocolPB.java:[26,65] package org.apache.ha
doop.ipc.proto.RefreshCallQueueProtocolProtos does not exist
[ERROR] D:\hdfs\hadoop-common-project\hadoop-common\src\main\java\org\apache\had
oop\ipc\protocolPB\RefreshCallQueueProtocolPB.java:[36,33] package RefreshCallQu
eueProtocolService does not exist
[ERROR] D:\hdfs\hadoop-common-project\hadoop-common\src\main\java\org\apache\had
oop\ipc\protocolPB\RefreshCallQueueProtocolServerSideTranslatorPB.java:[24,65] p
ackage org.apache.hadoop.ipc.proto.RefreshCallQueueProtocolProtos does not exist
You can download the latest hadoop release from this url:
http://apache.mirrors.tds.net/hadoop/common/stable/hadoop-2.2.0.tar.gz
You are complicating yourself for no reason: you only need to build hadoop in windows if your system is 32 bits (and good luck on that: I've been trying it for 3 weeks!). Since your system is 64 all you need to do is download a precompiled package

Build Issues in Jenkins

The following errors occurs in Jenkins on running a job.
[INFO] ------------------------------------------------------------------------<br>
[INFO] BUILD SUCCESS<br>
[INFO] ------------------------------------------------------------------------<br>
[INFO] Total time: 5.785s<br>
[INFO] Finished at: Tue Dec 24 16:40:15 IST 2013<br>
[INFO] Final Memory: 17M/42M<br>
[INFO] ------------------------------------------------------------------------<br>
Waiting for Jenkins to finish collecting data<br>
[JENKINS] Archiving C:\Program Files\Jenkins\jobs\Selenium Code\workspace\pom.xml to org.corp.selenium.framework/Selenium_Code/0.0.1-SNAPSHOT/Selenium_Code-0.0.1-SNAPSHOT.pom<br>
[JENKINS] Archiving C:\Program Files\Jenkins\jobs\Selenium Code\workspace\target\Selenium_Code-0.0.1-SNAPSHOT.jar to org.corp.selenium.framework/Selenium_Code/0.0.1-SNAPSHOT/Selenium_Code-0.0.1-SNAPSHOT.jar<br>
FATAL: hudson.maven.MavenBuild.isInProgress()Z<br>
java.lang.NoSuchMethodError: hudson.maven.MavenBuild.isInProgress()Z<br>
at hudson.maven.MavenBuild.access$700(MavenBuild.java:94)<br>
at hudson.maven.MavenBuild$ProxyImpl2.close(MavenBuild.java:621)<br>
at hudson.maven.AbstractMavenBuilder.end(AbstractMavenBuilder.java:106)<br>
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun<br>(MavenModuleSetBuild.java:839)<br>
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:562)<br>
at hudson.model.Run.execute(Run.java:1665)<br>
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:519)<br>
at hudson.model.ResourceController.execute(ResourceController.java:88)<br>
at hudson.model.Executor.run(Executor.java:230)<br>
As you can see from the above console output from jenkins, the below listed changes happen:
Build is successful
The Jar files gets created and succesfully installed into maven repository
Still the job fails with the java.lang.NoSuchMethodError
exception.
Please let me know, how to fix this exception?
I had the same issue here and downgrade of Maven Project Plugin to version 2.0-beta-1 solved it.
I hope it helps
Best Regards

Categories