Example #1
0
/*        public static API_IKVM install_IKVM_Assemblies_on_GAC(this API_IKVM ikvm)
 *      {
 *              "Installing IKVM dlls in local GAC folder".info();
 *              var gacUtil =  new DotNet_SDK_GacUtil();
 *              foreach(var file in ikvm._IKVMRuntimeDir.files("ikvm*.*"))
 *                      if (file.fileName().neq("ikvm-native.dll") && gacUtil.install(file).isFalse())
 *                      {
 *                              "Failed to install into GAC, so stopping installation process".error();
 *                              break;
 *                      }
 *                      return ikvm;
 *      }
 */
        public static bool checkIfJavaPathIsCorrectlySet(this API_IKVM ikvm)
        {
            var javaHome = Environment.GetEnvironmentVariable("Java_Home");

            if (string.IsNullOrEmpty(javaHome))
            {
                "in checkIfJavaPathIsCorrectlySet, could not find Java_Home variable".error();
            }
            else
            {
                var javaCompiler = Path.Combine(javaHome, @"bin\javac.exe");
                if (!File.Exists(javaCompiler))
                {
                    "in checkIfJavaPathIsCorrectlySet, could not find javaCompiler executable: {0}".error(javaCompiler);
                }
                {
                    var javaParser = Path.Combine(javaHome, @"bin\javap.exe");
                    if (!File.Exists(javaParser))
                    {
                        "in checkIfJavaPathIsCorrectlySet, could not find javaParser executable: {0}".error(javaParser);
                    }
                    else
                    {
                        ikvm.javaCompilerExecutable = javaCompiler;
                        ikvm.javaParserExecutable   = javaParser;

                        return(true);
                    }
                }
            }
            return(false);
        }
Example #2
0
 public static void uninstallIKVM(this API_IKVM ikvm)
 {
     if (Directory.Exists(ikvm._IKVMRuntimeDir))
     {
         Files.deleteFolder(ikvm._IKVMRuntimeDir, true);
     }
 }
Example #3
0
        public static string convertJarFileIntoDotNetAssembly(this API_IKVM ikvm, string pathToJarFile, string targetDirectory)
        {
            if (File.Exists(pathToJarFile) && Path.GetExtension(pathToJarFile) == ".jar")
            {
                var destinationFile = Path.Combine(targetDirectory,
                                                   Path.GetFileNameWithoutExtension(pathToJarFile) + ".dll");
                Files.deleteFile(destinationFile);
                var executionParameters = string.Format(ikvm.IKVMCompilerArgumentsFormat, pathToJarFile,
                                                        destinationFile);
                //var executionResult =
                //    Processes.startProcessAsConsoleApplicationAndReturnConsoleOutput(ikvm.IKVMCompilerExecutable,
                //                                                                     executionParameters);
                var process = ikvm.IKVMCompilerExecutable.startProcess(executionParameters, (line) => line.info());
                process.WaitForExit();
                if (File.Exists(destinationFile))
                {
                    return(destinationFile);
                }

                "in IKVMUtils.convertJarToDotNetAssembly, Jar file was not Converted into .Net Dll".error();
            }
            else
            {
                "in IKVMUtils.convertJarToDotNetAssembly, only jar files are supported".error();
            }
            return("");
        }
Example #4
0
 public static bool checkIKVMInstallation(this API_IKVM ikvm)
 {
     Files.checkIfDirectoryExistsAndCreateIfNot(ikvm.jarStubsCacheDir);
     if (ikvm.checkIfJavaPathIsCorrectlySet())
     {
         if (Directory.Exists(ikvm._IKVMRuntimeDir) && File.Exists(ikvm.IKVMCompilerExecutable) && File.Exists(ikvm.IKVMStubExecutable))
         {
             return(true);
         }
     }
     return(false);
 }
		public void Create_DotNetDll_Using_IKVM()
		{
			"Creating Groovy .NET Dll using IKVM: {0}".info();			
			Groovy_DotNet_Folder.createDir();
			var groovyJar = this.Install_Dir.pathCombine(@"groovy-{0}\embeddable\groovy-all-{0}.jar".format(Groovy_Version));
			//"Groovy Jar: {0} {1}".info(groovyJar, groovyJar.fileExists());
			
			var apiIKVM = new API_IKVM(); 

			var result = apiIKVM.convertJarFileIntoDotNetAssembly(groovyJar,Groovy_DotNet_Folder);
			"Result: {0}".info(result);						
		}