A library helps you manage jvm runtime dependencies (Such as Kotlin)
- Finished in pure java (no other dependency)
- Download from maven Repository
- Add dependencies into Classpath
- Get a classloader with dependencies you need
MAVEN_REPOSITORY :replace the default repository (default: the first repository added)
import cf.wayzer.libraryManager.*;
class Example{
void load(){
LibraryManager libraryManager=new LibraryManager();
//select 1 from 3 ways
libraryManager.addMavenCentral();
libraryManager.addJCenter();
libraryManager.addRepository("the name you want","the_url");
//select 1 from 3 ways
libraryManager.require(Dependency.KOTLIN_RUNTIME);
libraryManager.require(Dependency("org.jetbrains.kotlin","kotlin-stdlib","1.3.41"));
libraryManager.require(Dependency("org.jetbrains.kotlin:kotlin-stdlib:1.3.41","the name you add before"));
try {
//select 1 from 2 ways
libraryManager.loadToClasspath();
libraryManager.getClassloader(getClass().getClassLoader()).loadClass("kotlin.Lazy");
} catch (LibraryLoadException e) {
e.printStackTrace();
}
}
}
package example
import cf.wayzer.libraryManager.LibraryManager
//You can't use kotlin Function or Type before loadKotlinStd()
//val v = listOf(123)
fun main() {
LibraryManager.loadKotlinStd()
// Now can use kotlin
listOf(123)
}
- Keep the name of package.
- If you think it is good, leave a link to this page.
Issues and Pull requests for better library are always welcome!