Created
August 3, 2012 07:49
-
-
Save indare/3245546 to your computer and use it in GitHub Desktop.
ClassNotFountになったぞ・・・('A`)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package info.indare.hogehoge.fuga | |
import info.indare.hogehoge.Pugya | |
class Fuga extends Pugya{ | |
def moto(){ | |
println this.getClass().getName() | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HogeMaster { | |
public static void main(args){ | |
def srcPath = System.getProperty("user.dir") + File.separator + "src" + File.separator | |
def dir = System.getProperty("user.dir") + File.separator + "src" + File.separator | |
List<Class<?>> testClasses = new ArrayList<Class<?>>() | |
def testRootDir = "info.indare.hogehoge".split(/\./).inject(dir) { prev, next -> | |
prev.toString() + File.separator + next | |
} | |
new File(testRootDir.toString()).eachFileRecurse { | |
if (it.isFile()){ | |
println(it) | |
def classfile = it.absolutePath.replace(srcPath,"").replace(File.separator,".").replace(".groovy","") | |
println(classfile) | |
testClasses.push(getClassForName(classfile)) | |
} | |
} | |
testClasses.each{ | |
it.newInstance().moto() | |
} | |
} | |
@SuppressWarnings("unchecked") | |
public static <T> Class<T> getClassForName(String className) { | |
try { | |
return (Class<T>) Class.forName(className); | |
} catch (ClassNotFoundException e) { | |
throw new RuntimeException(e); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package info.indare.hogehoge.piyo | |
import info.indare.hogehoge.Pugya | |
class Piyo extends Pugya{ | |
def moto(){ | |
println this.getClass().getName() | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package info.indare.hogehoge | |
class Pugya { | |
def moto(){ | |
println this.getClass().getName() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment