Edit July 19 Part 2
I'll be damned. The error wasn't with Bash all along -- it was with sudo. When I run any of the working files below with sudo, even the python ones (sudo ./python1.py), I get the POM errors.
But when I run any of the files, including the bash files, without sudo (bash test.sh), the JAR files are created.
How can sudo being screwing this much up?
OP
I am trying to run the command 'mvn clean install' to make a .jar of the application I am using. Typing out this command manually in a terminal works perfectly. But this is part of a larger script suite, so it needs to be in a bash script (or .py or whatever language). When I run this from a simple test.sh file, and even in the exact same repo folder, I get the following error:
[ERROR] Some projects were encountered while processing the POMS: [FATAL] Non-resolvable parent POM for </path/application-SNAPSHOT>: Could not find artifact microservice-spring-boot-starter:pom:0.1.2-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 5, column 13
I go to this line 5, column 13 location in my POM file, and I see the same microservice-spring-boot-starter mentioned above. It is grey, not red, meaning it has the references loaded. And again, I can run the 'mvn clean install' command just fine from terminal.
Does anyone know how I can fix this? Alternatively, is there another way that making a .jar can be done by scripting? I know I can make one via Intellij (the IDE I am using), but I don't want to use an application as part of this script suite.
thanks peeps!
Per @khmarbaise I can't post the full POM file because this is all for an offline system.
When I do mvn -version I get:
- Apache Maven 3.6.3 (Red Hat 3.6.3-4)
- Maven home: /usr/share/maven
- Java version: 15, vendor: Red Hat, Inc., runtime: /<Java 15 path>
Test.sh script:
#!/bin/bash
mvn clean install
Ran from the same project repo folder of when I do 'mvn clean install' via terminal. Manually the .jar is created, via the script I get an error. So clearly all artifacts are there in the project folder, the issue is where is Fedora looking when things are in a bash script.
Edit July 19: Part 1 Now I am convinced this is an error with bash. I just created not 1 but 2 different python scripts, and the jar was created perfectly. Yet as soon as I reference these python scripts from a bash file, boom, I get the POM error. Wtf is up with Bash?
Python Script 1: CWD not specified -This script is ran in the same folder as the Repo and getcwd is there to prove it. Creats jar just fine
#!/usr/bin/env python3
import os
import subprocess
print(os.getcwd())
subprocess.call([“mvn clean install”], shell=True)
Python Script 2: CWD specified -This script is ran in the same folder as the Repo and cwd is directly specified in the command
#!/usr/bin/env python3
import os
import subprocess
from subprocess import call
print(os.getcwd())
status = call(“mvn clean && mvn install”,cwd=os.getcwd(), shell=True)
Again, both of these scripts create the jar just fine. But bash continues to rear its ugly head. The whole purpose of all of this is to invoke this python script in the suite of bash scripts I have. Since they are getting a bit unwieldly, I created a simple test.sh just to see if bash would play nicely.
Test.sh: I exist solely to invoke the python script and am in same folder as Repo
#!/bin/bash
./python1
I run the above Test.sh, and I get the exact same POM errors. I don’t get the errors running Python scripts. I don’t get these errors in Terminal. I only get it when Bash is involved.
Please explain to me how Bash is not the problem here.
CodePudding user response:
This is not a bash problem but your project is broken.
The error message tells you exactly what is wrong. You need to correct the parent Pom for this to work.
CodePudding user response:
Edit July 19 Part 2
I'll be damned. The error wasn't with Bash all along -- it was with sudo. When I run any of the working files below with sudo, even the python ones (sudo ./python1.py), I get the POM errors.
But when I run any of the files, including the bash files, without sudo (bash test.sh), the JAR files are created.
How can sudo being screwing this much up? Thats a question for another time, thankful I get what I wanted now.