Domanda

I'm trying to build a whole bunch of maven projects in a batch script. There are 2 sets that use (require) different versions of maven. Meaning: half of the projects use Maven 3.1.1 and the other uses 2.2.1, but some of those projects that use maven 2 require some of the maven 3 projects. I'm trying to do this all in one script as such:

 setx M2 %APACHE%\apache-maven-3.1.1\bin\
 rebuildCore
 setx M2 %APACHE%\apache-maven-2.2.1\bin\
 rebuildApp
 7z x "%workspace%\win32-app\target\win32-product-0.0-SNAPSHOT.zip" -o%Desktop% *.* -r -y > nul

The %APACHE% variable points to where the two maven installations are, %Desktop% points to my desktop, and %workspace% is my eclipse workspace.

rebuildCore and rebuildApp are 2 other batch scripts that build my projects, and those work fine.

The problem I am facing is that maven won't change what it points to at runtime after the command prompt has been started, and all windows have to be closed for it to refresh.

Is there any way to completely close all command prompt or powershell windows and run this without starting a new script? I know this seems unlikely, which is why I'm having problems with it.

È stato utile?

Soluzione

This works if you use a symlink in your path (e.g. environment variable M2 points to C:\maven\bin; and C:\maven is a symlink pointing to C:\Program Files\Apache\apache-maven-x.x.x), such that you can delete the symlink or NTFS junction in the middle of the script, and recreate it to another version of Maven. Example of how I changed this:

cd C:\
rmdir maven
mklink /j maven "%APACHE%\apache-maven-3.2.1"
start /wait cmd /q /c rebuildCore.bat
cd C:\
rmdir maven
mklink /j maven "%APACHE%\apache-maven-2.2.1"
start /wait cmd /q /c rebuildApp
:: THIS LAST LINE EXTRACTS MY RCP APP FROM THE BUILT ZIP FILE TO A FOLDER ON MY DESKTOP
7z x "C:\Users\USER\workspace\app-win32-std-product\target\app-win32-std-product-2.4-SNAPSHOT.zip" -oC:\Users\USER\Desktop\ *.* -r -y
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top