Permalink
Browse files

Ivy dependency manager

  • Loading branch information...
cheptsov committed Jan 25, 2013
1 parent 640b75c commit 4049d482501db89992edc265657b1ae62dae2d28
@@ -0,0 +1,28 @@
+<component name="libraryTable">
+ <library name="ivy-2.2.0">
+ <CLASSES>
+ <root url="jar://$PROJECT_DIR$/lib/ivy-2.2.0.jar!/" />
+ <root url="jar://$PROJECT_DIR$/lib/xml-apis-1.0.b2.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$PROJECT_DIR$/lib/ivy-2.2.0-src.zip!/apache-ivy-2.2.0/test/java" />
+ <root url="jar://$PROJECT_DIR$/lib/ivy-2.2.0-src.zip!/apache-ivy-2.2.0/src/java" />
+ <root url="jar://$PROJECT_DIR$/lib/ivy-2.2.0-src.zip!/apache-ivy-2.2.0/src/example/dual/project/src" />
+ <root url="jar://$PROJECT_DIR$/lib/ivy-2.2.0-src.zip!/apache-ivy-2.2.0/src/example/multi-project/projects/console/src" />
+ <root url="jar://$PROJECT_DIR$/lib/ivy-2.2.0-src.zip!/apache-ivy-2.2.0/src/example/multi-project/projects/sizewhere/src" />
+ <root url="jar://$PROJECT_DIR$/lib/ivy-2.2.0-src.zip!/apache-ivy-2.2.0/src/example/multi-project/projects/list/src" />
+ <root url="jar://$PROJECT_DIR$/lib/ivy-2.2.0-src.zip!/apache-ivy-2.2.0/src/example/multi-project/projects/find/src" />
+ <root url="jar://$PROJECT_DIR$/lib/ivy-2.2.0-src.zip!/apache-ivy-2.2.0/src/example/multi-project/projects/size/src" />
+ <root url="jar://$PROJECT_DIR$/lib/ivy-2.2.0-src.zip!/apache-ivy-2.2.0/src/example/multi-project/projects/version/src" />
+ <root url="jar://$PROJECT_DIR$/lib/ivy-2.2.0-src.zip!/apache-ivy-2.2.0/src/example/chained-resolvers/chainedresolvers-project/src" />
+ <root url="jar://$PROJECT_DIR$/lib/ivy-2.2.0-src.zip!/apache-ivy-2.2.0/src/example/configurations/jdbc-example/src" />
+ <root url="jar://$PROJECT_DIR$/lib/ivy-2.2.0-src.zip!/apache-ivy-2.2.0/src/example/configurations/multi-projects/filter-framework/test" />
+ <root url="jar://$PROJECT_DIR$/lib/ivy-2.2.0-src.zip!/apache-ivy-2.2.0/src/example/configurations/multi-projects/filter-framework/src" />
+ <root url="jar://$PROJECT_DIR$/lib/ivy-2.2.0-src.zip!/apache-ivy-2.2.0/src/example/configurations/multi-projects/myapp/src" />
+ <root url="jar://$PROJECT_DIR$/lib/ivy-2.2.0-src.zip!/apache-ivy-2.2.0/src/example/dependence/dependee/src" />
+ <root url="jar://$PROJECT_DIR$/lib/ivy-2.2.0-src.zip!/apache-ivy-2.2.0/src/example/dependence/depender/src" />
+ <root url="jar://$PROJECT_DIR$/lib/ivy-2.2.0-src.zip!/apache-ivy-2.2.0/src/example/hello-ivy/src" />
+ </SOURCES>
+ </library>
+</component>
View
@@ -9,5 +9,6 @@
<dependency org="org.slf4j" name="slf4j-log4j12" rev="1.6.6" conf="compile->default"/>
<dependency org="org.eclipse.jetty.aggregate" name="jetty-all-server" rev="8.1.5.v20120716" conf="compile->default"/>
<dependency org="org.codehaus.jackson" name="jackson-mapper-asl" rev="1.9.9" conf="compile->default"/>
+ <dependency org="org.apache.ivy" name="ivy" rev="2.2.0" conf="compile->default"/>
</dependencies>
</ivy-module>
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
@@ -15,6 +15,7 @@
<orderEntry type="library" name="log4j-1.2.17" level="project" />
<orderEntry type="library" name="slf4j-api-1.6.6" level="project" />
<orderEntry type="library" name="guava-11.0.2" level="project" />
+ <orderEntry type="library" name="ivy-2.2.0" level="project" />
</component>
</module>
View
@@ -9,6 +9,7 @@ import org.apache.log4j.Level
import org.apache.log4j.LogManager
import kara.generators.*
import java.util.ArrayList
+import dependencies.DependenciesResolver
fun server(appConfig : AppConfig) {
val jettyRunner = JettyRunner(appConfig)
@@ -21,6 +22,11 @@ fun generator(appConfig : AppConfig, task : GeneratorTask, args : List<String>)
generator.exec()
}
+fun resolverDependencies(appConfig : AppConfig) {
+ var dependencyResolver = DependenciesResolver(appConfig)
+ dependencyResolver.exec()
+}
+
fun config(appCongig : AppConfig) {
println(appCongig.toString())
}
@@ -32,16 +38,17 @@ Usage:
kara [-options] command args
Commands:
- c, config Show the application's configuration for the current environment
- g, generate Generates a new project or file (see below)
- h, help Show this help message
- s, server Run the Kara server on the current directory
+ c, config Show the application's configuration for the current environment
+ g, generate Generates a new project or file (see below)
+ d, dependencies Generates dependencies for application's ivy.xml file to application's lib folder.
+ h, help Show this help message
+ s, server Run the Kara server on the current directory
Options:
- -d, --debug Show debug log messages
- -e, --env Specify the environment (default is --env=development)
- -i, --info Show info log messages (default)
- -w, --warn Show only warning log messages
+ -d, --debug Show debug log messages
+ -e, --env Specify the environment (default is --env=development)
+ -i, --info Show info log messages (default)
+ -w, --warn Show only warning log messages
Generators:
project <name> Generates a new Kara project with the given name.
@@ -77,6 +84,7 @@ fun main(args: Array<String>) {
var startServer = false
var runGenerator = false
+ var resolveDependencies = false
var showHelp = false
var showConfig = false
var generatorTask : GeneratorTask? = null
@@ -99,6 +107,7 @@ fun main(args: Array<String>) {
"c", "config" -> showConfig = true
"s", "server" -> startServer = true
"g", "generate" -> runGenerator = true
+ "d", "dependencies" -> resolveDependencies = true
"h", "help" -> showHelp = true
"update" -> generatorTask = GeneratorTask.update
"project" -> generatorTask = GeneratorTask.project
@@ -145,6 +154,9 @@ fun main(args: Array<String>) {
throw RuntimeException("Need to specify a generator task to run. Run 'kara help' for usage.")
generator(appConfig, generatorTask!!, generatorArgs)
}
+ else if (resolveDependencies) {
+ resolverDependencies(appConfig)
+ }
else {
println("No valid command specified! Run 'kara help' for usage.")
}
@@ -0,0 +1,21 @@
+package dependencies
+
+import kara.config.AppConfig
+import org.apache.ivy.core.settings.IvySettings
+import org.apache.ivy.Ivy
+import org.apache.ivy.core.event.EventManager
+import org.apache.ivy.core.event.IvyListener
+import org.apache.ivy.core.event.IvyEvent
+import java.io.File
+import org.apache.ivy.plugins.resolver.URLResolver
+import org.apache.ivy.core.retrieve.RetrieveOptions
+import org.apache.ivy.util.filter.Filter
+import org.apache.ivy.util.filter.FilterHelper
+import org.apache.ivy.Main
+
+public class DependenciesResolver(val appConfig : AppConfig) {
+ public fun exec() {
+ val pattern = "${appConfig.appRoot}/lib/[artifact]-[revision].[ext]"
+ Main.main(array("-retrieve", pattern, "-types", "jar"))
+ }
+}
@@ -153,11 +153,12 @@ class Generator(val appConfig : AppConfig, val task : GeneratorTask, val args :
createIDEFiles(ide)
// copy the necessary libraries
copyFile("lib/kotlin-runtime.jar", "lib/kotlin-runtime.jar")
- copyFile("out/jars/KaraLib.jar", "lib/KaraLib.jar")
+ copyFile("modules/core/KaraLib.jar", "lib/KaraLib.jar")
// render the templates
renderTemplate(moduleImlTemplate(this), "${appConfig.appPackage}.iml")
renderTemplate(buildxmlTemplate(this), "build.xml")
+ renderTemplate(ivyTemplate(this, projectName), "ivy.xml")
renderTemplate(appconfigTemplate(this), "config/appconfig.json")
renderTemplate(appconfigDevelopmentTemplate(this), "config/appconfig.development.json")
renderTemplate(applicationTemplate(this), "src/$appPackagePath/Application.kt")
@@ -0,0 +1,17 @@
+package generators.templates
+
+import kara.generators.Generator
+
+/**
+ * Templates for ivy.xml.
+ */
+
+fun ivyTemplate(gen : Generator, projectName : String) : String {
+ return """<?xml version="1.0" encoding="UTF-8"?>
+<ivy-module version="2.0">
+ <info organisation="${gen.appPackage}" module="$projectName"/>
+ <dependencies>
+ </dependencies>
+</ivy-module>
+"""
+}

0 comments on commit 4049d48

Please sign in to comment.