Cause of DOMA 4019 error when compiling with Gradle suffered for 7 days

I was frustrated that I couldn't compile it even though it was a simple source, but it was an error with no result. A memorandum so as not to wake it up again.

If I make it with Eclipse's Doma plugin, I get an error if I don't move the file.

error contents


error: [DOMA4019] The file "META-INF/doma/sample/dao/TestDao/selectAll.sql" is not found in the classpath. The absolute path is "/Users/harutotanabe/Downloads/sample/build/classes/java/main/META-INF/doma/sample/dao/TestDao/selectAll.sql".

▼ Sample code

Main processing


@SpringBootApplication
public class SampleApplication {

	public static void main(String[] args) {
		SpringApplication.run(SampleApplication.class, args);
	}

    @Autowired
    TestDao TestDao;

    @Bean
    CommandLineRunner runner() {
    	TestDao.selectAll();
        return null;
       }
 }

Entity


@Entity
public class Test {
    public Integer id;
    public String test;
}

Dao


@ConfigAutowireable
@Dao
public interface TestDao {

@select 
List<Test> selectAll();
}

gradle


plugins {
	id 'org.springframework.boot' version '2.1.4.RELEASE'
	id 'java'
}

task copyDomaResources(type: Sync)  {
    from sourceSets.main.resources.srcDirs
    println 'SQL file copy source'
    println sourceSets.main.resources.srcDirs
    into compileJava.destinationDir
    println 'SQL file copy destination'
    println compileJava.destinationDir
    include 'doma.compile.config'
    include 'META-INF/**/*.sql'
    include 'META-INF/**/*.script'
}

compileJava {
    dependsOn copyDomaResources
    options.encoding = 'UTF-8'
}


apply plugin: 'io.spring.dependency-management'

group = 'doma'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

configurations {
	compileOnly {
		extendsFrom annotationProcessor
	}
}

repositories {
    mavenCentral()
    mavenLocal()
    maven {url 'https://oss.sonatype.org/content/repositories/snapshots/'}
}

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter'
	compileOnly 'org.projectlombok:lombok'
	compile group: 'org.seasar.doma.boot', name: 'doma-spring-boot-starter', version: '1.1.1'
	runtimeOnly 'org.postgresql:postgresql'
	annotationProcessor 'org.projectlombok:lombok'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	annotationProcessor "org.seasar.doma:doma:2.24.0"
    implementation "org.seasar.doma:doma:2.24.0"
}

-If you create a SQL file by just enter with the Doma plug-in of Eclipse, it will be under Java.

▼ Before correspondence (image) image.png

With this, you cannot copy the SQL file. Because the copy source is resources. .. .. Therefore, it is OK if you move the META-INF folder to resources

▼ After correspondence (image) image.png

Recommended Posts

Cause of DOMA 4019 error when compiling with Gradle suffered for 7 days
Error when starting JUnit with deprecated version of POI
Workaround for Bundler.require error when executing ruby with crontab
Error when playing with java