问题
I am building a Java project via Jenkins. The JAR is being created (after I execute maven clean install in Jenkins) in C:\Windows\System32\config\systemprofile.m2\repository\com\other folders.
Is there any way to change this path? I want to sent the JAR to a VM via SSH. However, I am not able to access this folder since this is system directory.
Thank you.
回答1:
For some reason, your Jenkins uses this directory as local Maven repository. I would define a different local repository in Jenkins or in the settings.xml
. It is also important that you make sure that no two running builds use the same local repository at the same time because local repositories cannot be used concurrently.
回答2:
If you are using maven to build, add the below to your pom.xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>your custom location</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
回答3:
By default, maven should create your build artifacts (including the JAR file) in target
directory next to your pom.xml
.
You can change this behavior in pom.xml
by specifying the build directory:
<build>
<directory>/some/other/dir</directory>
</build>
The directory you are referring to is your local maven repository, which contains all JAR files maven is working with. You can read more about local maven repository here.
来源:https://stackoverflow.com/questions/58503940/how-to-change-jar-build-path-in-jenkins