Sergey
Sergey

Reputation: 1089

Flyway 'migrate' ant task error: "Unable to find path for sql migrations [...]"

I can not specify the correct path to the directory with .sql files. I tried to set the "baseDir" attribute to different directories in different places (in classpath, of course) and set different classpath. Build scripts always falls with message “Unable to find path for sql migrations: [uri to directory with . sql files]”.

It's not looking like issue 156 as was said in similar question, becourse if I delete the code in SqlMigrationResolver.java

if (StringUtils.hasText(baseDir) && !new ClassPathResource(baseDir + "/",
    classLoader).exists()) {
  LOG.warn("Unable to find path for sql migrations: " + baseDir);
  return migrations;
}

as was said in Comment #9 I still catch

deployDB:
[flyway:migrate] com.googlecode.flyway.core.exception.FlywayException: Error loading sql migration files
[flyway:migrate] Caused by java.io.FileNotFoundException: class path resource [db/migration/] cannot be resolved to URL because it does not exist

BUILD FAILED
c:\DeployTest\build.xml:208: Flyway Error: com.googlecode.flyway.core.exception.FlywayException: Error loading sql migration files

Flyway falls at

resources = new PathMatchingResourcePatternResolver(classLoader)
        .getResources("classpath:" + searchRoot + searchPattern);

It can not execute getResources method.

It's not looking like bug, it's looking like I can not set right uri to directory with my SQL scripts =(

Please, help me to set this damn uri!

My build.xml:

<target name="init-flyway">
  <taskdef uri="antlib:com.googlecode.flyway.ant"
           resource="com/googlecode/flyway/ant/antlib.xml"
  />
  <property name="flyway.driver" value="${dbDriver}"/>
  <property name="flyway.url" value="${dbUrl}"/>
  <property name="flyway.user" value="${dbScheme}"/>
  <property name="flyway.password" value="${dbPass}"/>
  <property name="flyway.baseDir" value="\db\migration"/>
  <property name="flyway.classpath" value="c:\DeployTest"/>
</target>

<target name="deployDB" depends="init-flyway">
  <flyway:migrate/>
</target>

Upvotes: 0

Views: 3298

Answers (2)

Ram
Ram

Reputation: 21

Instead of this:

<path id="flyway.classpath"> 
    <fileset dir="c:\DeployTest"/> 
</path>

Use:

<path id="flyway.classpath">  
      <pathelement location="c:\DeployTest"/>
</path>  

Upvotes: 2

Axel Fontaine
Axel Fontaine

Reputation: 35189

Try changing flyway.classpath from a property to a path.

For your case this means changing this:

<property name="flyway.classpath" value="c:\DeployTest"/>

to this:

<path id="flyway.classpath">
    <fileset dir="c:\DeployTest"/>
</path>

Upvotes: 2

Related Questions