I have been blocked for at least 3 days because of this error, please help me out for this situation.
src
|
|- main
|
|
|
|--Java
|
|
|
|
|
--myclass.java
|
|
|--my.xslt
|
|
|
|
|
|-resource folder
|
|
|--test
|
|--java
|
|--myclassTest.java
For history reason, this is my project structure. So in settings.gradle file
include 'main', 'test'
in main\myclass.java
public class myclass{
static {
stylesheetStream = myService.class.getResourceAsStream("my.xslt");
}
So myclass will use my.xslt.
In test\myclassTest.java,
import myclass
public class myclassTest{
@Test
public void test111() {
myclass
me = new myclass();
}
}
Obviously, myclassTest reference myclass to test myclass.
under src folder, this is parent build.gradle like
apply plugin: 'base'
subprojects {
apply plugin: 'java'
}
In main folder, build.grale like
sourceSets {
main {
java.srcDir 'java'
resources.srcDir 'resources'
}
}
in test folder, build.gradle like
sourceSets {
test {
java.srcDir 'java'
resources.srcDir 'resources'
}
}
dependencies {
compile project(path: ':main')
}
But when I failed in running test, and got java.lang.NoClassDefFoundError. Obviously, myclasstest failed because it can not get myclass, the reason is myclass can not find correct path for my.xslt.
How to solve this tough problem? Please advice. I appreciate your great help.