Я пытаюсь получить путь к файлу от пользователя с помощью Read-Host и проверить, присутствует ли такой файл в этом месте или нет.
$choice = Read-Host -Prompt 'Do you like to run the flyway command?[yes:no]'
if($choice -eq 'yes'){
[string]$fileToCheck = Read-Host -Prompt 'Enter the path to the flyway configuration file. For example C:\Users\admin\Desktop\flyway.conf'
if(Test-Path $fileToCheck -PathType leaf){
mvn -Dflyway.configFiles=$fileToCheck flyway:info
mvn -Dflyway.configFiles=$fileToCheck flyway:migrate
mvn -Dflyway.configFiles=$fileToCheck flyway:info
}
else{
Write-Host 'Flyway configuration file not present. Enter correct path.'
}
}
Когда команда maven будет выполнена, я получаю следующее ошибка.
Enter the path to the flyway configuration file. For example C:\Users\admin\Desktop\flyway.conf: C:\Users\akshay\Desktop\flyway.conf
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
Progress (1): 2.2/14 kB
Progress (1): 5.0/14 kB
Progress (1): 7.8/14 kB
Progress (1): 11/14 kB
Progress (2): 11/14 kB | 2.3/20 kB
Progress (2): 11/14 kB | 5.0/20 kB
Progress (2): 11/14 kB | 7.8/20 kB
Progress (2): 11/14 kB | 11/20 kB
Progress (2): 13/14 kB | 11/20 kB
Progress (2): 14 kB | 11/20 kB
Progress (2): 14 kB | 13/20 kB
Progress (2): 14 kB | 16/20 kB
Progress (2): 14 kB | 19/20 kB
Progress (2): 14 kB | 20 kB
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml (14 kB at 12 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml (20 kB at 18 kB/s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.037 s
[INFO] Finished at: 2020-03-23T17:08:53+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix '.configFiles=C' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] availa
ble from the repositories [local (C:\Users\akshay\.m2\repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
Я не могу использовать полный путь к файлу для аргумента flyway.configFiles
. Только C
добавляется туда.