I'm trying to build a project with Maven sequentially, with no success.
I tried put the following lines in a script file and called it from bash.
mvn -f ./cmroad-api/pom.xml clean install corona:package -Ddebug=false
mvn -f ./cmroad-impl/pom.xml clean install corona:package -Ddebug=false
The first command runs but the build does not call the second command. I tried putting the ; like:
mvn -f ./cmroad-api/pom.xml clean install corona:package -Ddebug=false; mvn -f ./cmroad-impl/pom.xml clean install corona:package -Ddebug=false.
The output was:
[ERROR] Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>.
I would be most thankful for any help.
[ERROR] Unknown lifecycle phase "mvn".
This is the error you would get on typing mvn mvn; your script has two mvns on the same line, presumably because something is wrong with your line endings.
Start with a simple script:
#!/bin/sh
echo A
echo B
and get that working before moving on to Maven. The commands you specify should work when placed in a correctly prepared script. (Although, as khmarbaise says, your project is wrong if you need to build in this order.)
Related
I'm trying to install Datomic on a Windows 10 computer, following the official instructions.
I downloaded and unzipped the dev tools as instructed.
I cannot, however, run the install script because it is a bash script.
I opened the script and discovered it requires maven, so I installed maven and tried to run the commands manually.
echo 'Installing: com.cognitect/rebl {:mvn/version "0.9.242"}'
mvn -q org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dfile=rebl-0.9.242/rebl-0.9.242.jar
echo 'Installing: com.datomic/dev-local {:mvn/version "0.9.232"}'
mvn -q org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dfile=dev-local-0.9.232/dev-local-0.9.232.jar
At first this errored with
The goal you specified requires a project to execute but there is no POM in this directory
So I figured out how to create a maven pom.xml.
Then it errors
[ERROR] The specified file 'C:\workspaces\clj-recipe\rebl-0' not exists
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file (default-cli) on project clj-recipe: The specified file 'C:\workspaces\clj-recipe\rebl-0' not exists
Is dev-local not intended for windows?
Update
I did get the maven scripts to run. I created my own install.ps1 in the dev tool directory, which kept paths the same, and quoted the file paths.
# expects to be run from the project (pom.xml) directory, but in a script file in the same directory as the original install script
echo 'Installing: com.cognitect/rebl {:mvn/version "0.9.242"}'
mvn -q org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dfile="rebl-0.9.242/rebl-0.9.242.jar"
echo 'Installing: com.datomic/dev-local {:mvn/version "0.9.232"}'
mvn -q org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dfile="dev-local-0.9.232/dev-local-0.9.232.jar"
I still can't get dev-local to run though. There appears to be no changes to the pom.xml.
I start up a repl for the current lein project and run
(require '[datomic.client.api :as d])
(def client (d/client {:server-type :dev-local
:system "dev"}))
Getting the error No such namespace: d.
My guess is that I don't understand how deps.edn works... Right now I have a single deps.edn under C:/Users/[username here]/documents/.clojure/deps.edn
{
:mvn/repos {"cognitect-dev-tools"
{:url "https://dev-tools.cognitect.com/maven/releases/"}}
:deps
{com.datomic/dev-local {:mvn/version "0.9.225"}}
}
There were two key issues here
The install script is not necessary with leiningen (and is not written for windows)
If you want to use a maven-based approach, then use the install script. Be warned that you need maven installed.
The install script can be tweaked for windows by changing as shown above (quote paths, remove the cd, make it a ps1 file)
The deps.edn, maven, and leiningen paths are not compatible. I must configure the dependency using leiningen to use it in my lein-based project
Configuring for lein is fairly simple
add a repositories configuration section
add a package dependency
(defproject ;;...
:dependencies [
;;...
[com.datomic/dev-local "0.9.225"]
]
:repositories [
["cognitect-dev-tools" {:url "https://dev-tools.cognitect.com/maven/releases/"
:username :env/datomic_username
:password :env/datomic_password}]]
;;...
)
Note that the credentials have to be supplied to the lein project. This can be done with
environment variables as shown above (specify the name as :env/var-name-here)
or using an encrypted password field
or use a profile
We have recently migrated our multimodule(each module with a pom.xml) repository from SVN to GIT.SCM connection in all pom.xml files updated from svn to git.
When i am trying to create a branch from git repository using maven release plugin it fails with the below error
"Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5:branch (default-cli) on project intgr: An error is occurred in the checkin process: Exception while executing SCM command. Error while executing command. Error while executing process. Cannot run program "/bin/sh" (in directory "/u01/remote-agent-home/xml-data/build-dir/IN-CDBFG-JOB1/mahirepository"): error=7, Argument list too long -> [Help 1]"
On examining logs i understand below command generated this error.
"[INFO] Checking in modified POMs... [INFO] Executing: /bin/sh -c cd /u01/remote-agent-home/xml-data/build-dir/IN-CDBFG-JOB1/mahirepository && git add -- intgr-parent/pom.xml archetypes/pom.xml and 1000 more pom files "
Is there a way i can workaround or fix this issue?
Maven version : Apache Maven 3.0.4
JDK version : 1.7.0_01
Maven command :
mvn -s ./settingsBamboo.xml --batch-mode release:branch -DbranchName=${bamboo.branchname} -DupdateWorkingCopyVersions=true -DsuppressCommitBeforeBranch=true -DautoVersionSubmodules=true -DremoteTagging=false -DupdateBranchVersions=false -X
I am currently facing this problem as well, but I got a bit further on this.
The issue has nothing to do with Java or Maven, it's a Linux limitation.
using getconfig MAX_ARGS you can find the max amount of bytes you can use as arguments.
Large maven commands can easily go beyond this, and the amount of bytes differs largely per distro.
Check the amount of bytes you can use, and try to get your command below that.
You could for example move into the build dir first, and then run the command relative.
Another solution would be to increase the amount of usable space, but I have so far not gotten that working.
If anyone does or you have fixed this yourself, let me know.
I have a test automation framework and I am able to run my tests from maven command line with the following without any error:
mvn clean test -Pdev -Dserver="remote" -Dbrowser="ie" -Dcucumber.options="--tags #test"
I try to integrate it to teamcity but there are some problem with the arguments.
My config in Build Step:Maven:
Goals: clean test
path to pom file: is correct
Additional maven Command Line Parameters:
-Pdev
-Dserver=remote
-Dbrowser=ie
"-Dcucumber.options=--tags #test"
When I start the job, the test has been started but never ends, just it runs continuously and the job is stucked.
Any idea why? I'm pretty sure, cucumber.options arguments syntax is wrong, but without quotes it doesn't work at all. Please note, locally everything is working fine, there is no any error in arguments/maven profile etc.
Thanks!
If your TeamCity instance is running on Windows, the below syntax for defining Cucumber Options in the Additional Maven Command Line Parameters should work:
"-Dcucumber.options= --tags #test"
Not sure if it matters, but notice I have a space in between the = character and --tags
set homepath=%userprofile%
set a=%1
set b=%2
set c=%3
set uuid=%4
set zipDirectory=%5
set pluginDirectory=%6
cd %homepath%\%a%
mvn archetype:generate -DarchetypeCatalog=file://%homepath%/.m2/repository
Everything works up to here, then the command lines stop executing. It doesn't print the 1, nor subsequent commands.
1
c
b
c
%uuid%
Y
cd %homepath%\%a%\%b%
mvn clean install
cd %homepath%\%a%\%b%\%b%-plugin\target
jar -xvf %zipDirectory%
cd %homepath%\%a%\%b%\%b%-plugin\target\META-INF\maven\%c%\%b%-plugin
copy pom.xml + %pluginDirectory%
cd %pluginDirectory%
rename pom.xml %b%-plugin-1.0.0.pom
Question: Is there anything about maven I don't know about that interrupts a batch process? Does it not understand to execute the command with a lone number 1?
When invoking Maven from a batch file to create a new project via archetype you should be aware of the interactive mode of the execution, that is, Maven will prompt for certain values or ask for confirmation.
It seems in your case this is not the desired behavior. You should hence pass via command line some options of the generate goal and the specific archetype and then run either in batch mode via the -B standard Maven option or via -DinteractiveMode=true.
From official documentation you should pass
The archetypeGroupId, archetypeArtifactId and archetypeVersion defines the archetype to use for project generation.
The groupId, artifactId, version and package are the main properties to be set. Each archetype require these properties. Some archetypes define other properties; refer to the appropriate archetype's documentation if needed
Hence in your case:
call mvn archetype:generate -DarchetypeCatalog=file://%homepath%/.m2/repository -B \
-DarchetypeGroupId=com.sample -DarchetypeArtifactId=artifact -DarchetypeVersion=1.0 \
-DgroupId=your.groupid -DartifactId=your.artifactId -Dversion=0.0.1-SNAPSHOT \
-Dsomething-else=value
Note: \ added for readability, you don't actually need it
try to execute that command like this. Then next command will execute as expected
CALL mvn <command>
I have setup a "Hello World" pipeline with one task mvn clean package in Go CD. I have registered an agent with Java and Maven up and running.
When I trigger the pipeline, the job fails:
12:05:08.655 [go] Start to execute task: <exec command="mvn" > <arg>clean package</arg> </exec>.
12:05:08.660 Error happened while attempting to execute 'mvn clean package'. Please make sure [mvn] can be executed on this agent.
If I execute mvn clean package in my agent, everything works. What is happening? Is there a place where I can see more specific logs?
Instead of running the following:
Command:
mvn clean package
try to use
Command:
/bin/bash
Arguments:
-c
mvn clean package
I struggled with the same issue and figured out a solution which worked for me. Maybe, it will help you.
In the command prompt of your agent enter echo $PATH
This will show all your path variables. Copy all of them.
Now, in the GUI of your server, choose the configuration of your
pipeline and add a PATH variable with the copied variables.
You can use:
Command:
mvn
Arguments:
clean
package