如何在Maven 2 exec插件的参数中使用空格

时间:2011-01-17 18:44:45

标签: java maven-2 maven maven-plugin

相关问题:Maven Exec Plugin not reading configuration

在我的配置中,我需要一个参数,它是一个文件路径。我发现了一个相当“脏”的解决方法,用POM中的引号包围参数(“脏”,因为参数将使用这些引号传递给main方法,它们必须在代码中再次删除。)

<configuration>
    <executable>java</executable>
    <arguments>
        <argument>"path to file"</argument>
    </arguments>
</configuration>

但是我找不到将路径作为命令行参数传递的解决方案:

>mvn exec:java -Dexec.args="path to file"

5 个答案:

答案 0 :(得分:8)

通常,如果参数值中有空格,maven需要引用整个参数。

mvn exec:java "-Dexec.args=path to file"

答案 1 :(得分:3)

在命令行中,您可以尝试使用单引号(但我不确定它是否有效),例如:

>mvn exec:java -Dexec.args="'path to file' arg2 arg3"

答案 2 :(得分:2)

使用-Dexec.args="'space parameter' normalparameter 'one more space parameter'"

我在Windows上尝试过它并且有效。

答案 3 :(得分:1)

如果您希望在命令行中尝试:$ mvn exec:java -Dexec.args="path\ to\ file arg2 arg3"

答案 4 :(得分:0)

尝试static Stream<List<User>> getSpecifiedUsersStreamWithDistance( {@required User loggedInUser, @required List<String> uids}) { try { List<Stream<User>> listOfStreams = []; for (var uid in uids) { Stream<User> streamToAdd = _fireStore .collection('users') .where('email', isEqualTo: uid) .snapshots() .map((snap) => snap.documents .map((doc) => User.fromMap(map: doc.data)) .map((user) { user.updateDistanceToOtherUser(otherUser: loggedInUser); return user; }).toList()[0]); listOfStreams.add(streamToAdd); } Stream<List<User>> usersStream = ZipStream.list(listOfStreams); return usersStream; } catch (e) { print(e); return null; } } (而不是import UIKit class ViewController: UIViewController, LogInViewDelegate, SignUpViewDelegate { @IBOutlet weak var logInSignUpControl: UISegmentedControl! @IBOutlet weak var containerView: UIView! var logInVC: LogInViewController? var signUpVC: SignUpViewController? var activeVC = 0 override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. initializeCustomControllers() } func initializeCustomControllers() { let storyboard = UIStoryboard(name: "Main", bundle: nil) logInVC = storyboard.instantiateViewController(withIdentifier: "LogInViewController") as? LogInViewController signUpVC = storyboard.instantiateViewController(withIdentifier: "SignUpViewController") as? SignUpViewController logInVC?.delegate = self signUpVC?.delegate = self logInVC?.willMove(toParent: self) logInVC?.view.frame = containerView.bounds containerView.addSubview(logInVC!.view) addChild(logInVC!) logInVC?.didMove(toParent: self) } func swapCustomController(from: UIViewController,to: UIViewController) { from.view.removeFromSuperview() from.removeFromParent() to.willMove(toParent: self) to.view.frame = containerView.bounds containerView.addSubview(to.view) addChild(to) to.didMove(toParent: self) } @IBAction func logInSignUpControlTapped(_ sender: Any) { switch logInSignUpControl.selectedSegmentIndex { case 0: if activeVC == 1 { swapCustomController(from: signUpVC!, to: logInVC!) activeVC = 0 } case 1: if activeVC == 0 { swapCustomController(from: logInVC!, to: signUpVC!) activeVC = 1 } default: break } } func logInAttempted(error: Error?) { if error == nil { // segue print("log in successful") } else { showAlert(title: "Log In error", message: error?.localizedDescription ?? "Unknown Error") } } func signUpAttempted(error: Error?) { showAlert(title: "Sign Up Error", message: error?.localizedDescription ?? "Unknown Error") } }

Check here for details.