我正在嘗試將項目集成到具有兩個組件的客戶端(用silverlight編寫)和服務器(用java編寫)中。服務器端完全兼容maven,但我遇到了使用maven運行msbuild的問題。我收到以下拒絕訪問錯誤從maven調用msbuild時出錯
嵌入式錯誤:無法運行程序「C:\ WINDOWS \ Microsoft.NET \ Framework \ v4.0.3031 9 \ msbuild」(在目錄「C:\ workspace \ something \ client」 ):CreateProcess的錯誤= 5, 訪問被拒絕
機:的Windows XP 殼:git的慶典和CMD
的pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>x</groupId>
<artifactId>client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>client</name>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<executable>${msbuild.path}</executable>
</configuration>
<executions>
<execution>
<id>clean</id>
<phase>clean</phase>
<configuration>
<arguments>
<argument>/t:Clean</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
<execution>
<id>build</id>
<phase>compile</phase>
<configuration>
<arguments>
<argument>/t:some.sln</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
錯誤:
$ mvn compile -Dmsbuild.path=C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/msbu
ild -e
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building client
[INFO] task-segment: [compile]
[INFO] ------------------------------------------------------------------------
[INFO] [exec:exec {execution: build}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Command execution failed.
Embedded error: Cannot run program "C:\WINDOWS\Microsoft.NET\Framework\v4.0.3031
9\msbuild" (in directory "c:\workspace\something\client"): CreateProcess error=5,
Access is denied
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Command execution failed
.
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLi
fecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
ltLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
dleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
ts(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:6
0)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Command execution fai
led.
at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:363)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
nManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:694)
... 17 more
Caused by: java.io.IOException: Cannot run program "C:\WINDOWS\Microsoft.NET\Fra
mework\v4.0.30319\msbuild" (in directory "c:\workspace\something\client"): Create
Process error=5, Access is denied
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at java.lang.Runtime.exec(Runtime.java:593)
at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13Com
mandLauncher.java:58)
at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:2
54)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecut
or.java:319)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:
160)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:602)
at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:348)
... 19 more
Caused by: java.io.IOException: CreateProcess error=5, Access is denied
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
... 26 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Tue Mar 27 10:33:58 CDT 2012
[INFO] Final Memory: 7M/494M
[INFO] ------------------------------------------------------------------------
任何人都有成功使用maven/java或使用maven在運行任何Windows程序/批處理文件運行的MSBuild?
將msbuild放在路徑中並避免長路徑名可能會更好。他們總是似乎造成麻煩.. – 2012-03-27 20:52:14