Пример #1
0
        private void btnGeneratePOM_Click(object sender, RoutedEventArgs e)
        {
            JARBuilderEventArgs args = new JARBuilderEventArgs(RepositoryRoot, (LogLevel)cbLogLevel.SelectedValue);

            cts = new CancellationTokenSource();
            args.CancellationToken     = cts.Token;
            args.JDKFolder             = tbJDKFolder.Text;
            args.SourceFolder          = tbDestinationFolder.Text;
            args.JarDestinationFolder  = tbJarDestinationFolder.Text;
            args.SplitFolderByAssembly = cbEnableSplitFolder.IsChecked.Value;
            args.WithJARSource         = cbWithSource.IsChecked.Value;
            args.EmbeddingJCOBridge    = cbWithEmbedding.IsChecked.Value;
            args.GeneratePOM           = JARBuilderEventArgs.POMType.Release;
            args.AssembliesToUse       = AssemblyDataCollection.CreateList(AssemblyDataCollection);

            if (cbExportToFile.IsChecked.Value)
            {
                export(args);
                if (MessageBox.Show("Continue operation?", string.Empty, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) == MessageBoxResult.No)
                {
                    return;
                }
            }

            commandPanel.IsEnabled = false;
            btnStop.Visibility     = Visibility.Visible;
            Task.Factory.StartNew(JavaBuilder.CreatePOM, args);
        }
Пример #2
0
        public static void CreateJars(object o)
        {
            bool     failed    = false;
            DateTime dtStart   = DateTime.Now;
            string   reportStr = string.Empty;

            try
            {
                JARBuilderEventArgs args = o as JARBuilderEventArgs;
                logLevel = args.LogLevel;

                if (!Path.IsPathRooted(args.SourceFolder))
                {
                    args.SourceFolder = Path.Combine(args.RootFolder, args.SourceFolder);
                }

                if (!Path.IsPathRooted(args.JDKFolder))
                {
                    args.JDKFolder = Path.Combine(args.RootFolder, args.JDKFolder);
                }

                if (!Path.IsPathRooted(args.JarDestinationFolder))
                {
                    args.JarDestinationFolder = Path.Combine(args.RootFolder, args.JarDestinationFolder);
                }

                var srcRootFolder = Path.Combine(args.SourceFolder, Const.FileNameAndDirectory.SourceDirectory);
                var jars          = CreateJars(args.JDKFolder, args.RootFolder, srcRootFolder, args.JarDestinationFolder, (args.AssembliesToUse == null) ? CreateFolderList(srcRootFolder) : args.AssembliesToUse, args.WithJARSource, args.EmbeddingJCOBridge);
                reportStr = string.Format("{0} Jars created in {1}.", jars, DateTime.Now - dtStart);
            }
            catch (OperationCanceledException ex)
            {
                reportStr = string.Format("Error {0}", ex.Message);
                AppendToConsole(LogLevel.Error, reportStr);
            }
            catch (Exception ex)
            {
                reportStr = string.Format("Error {0}", ex.Message);
                AppendToConsole(LogLevel.Error, reportStr);
                failed = true;
            }
            finally
            {
                EndOperationHandler?.Invoke(null, new EndOperationEventArgs(reportStr, failed));
            }
        }
Пример #3
0
        public static void CreatePOM(object o)
        {
            bool     failed    = false;
            DateTime dtStart   = DateTime.Now;
            string   reportStr = string.Empty;

            try
            {
                JARBuilderEventArgs args = o as JARBuilderEventArgs;
                logLevel = args.LogLevel;

                if (!Path.IsPathRooted(args.SourceFolder))
                {
                    args.SourceFolder = Path.Combine(args.RootFolder, args.SourceFolder);
                }

                if (!Path.IsPathRooted(args.JDKFolder))
                {
                    args.JDKFolder = Path.Combine(args.RootFolder, args.JDKFolder);
                }

                if (!Path.IsPathRooted(args.JarDestinationFolder))
                {
                    args.JarDestinationFolder = Path.Combine(args.RootFolder, args.JarDestinationFolder);
                }

                Const.FileNameAndDirectory.CreateJCOBridgeZip(args.RootFolder);

                var           srcRootFolder   = Path.Combine(args.SourceFolder, Const.FileNameAndDirectory.SourceDirectory);
                var           assembliesToUse = (args.AssembliesToUse == null) ? CreateFolderList(srcRootFolder, false) : args.AssembliesToUse;
                StringBuilder sb = new StringBuilder();
                foreach (var item in assembliesToUse)
                {
                    sb.AppendFormat(Const.POM.POM_JCOREFLECTOR_SOURCE_PLACEHOLDER, item);
                    sb.AppendLine();
                }
                var sourceFlders = sb.ToString();
                //sourceFlders = sourceFlders.Remove(sourceFlders.LastIndexOf(','));
                sourceFlders = sourceFlders.Replace('\\', '/');

                var jcoPomTemplate = Const.Templates.GetTemplate(Const.Templates.POMJCOReflector);
                var jcoPom         = jcoPomTemplate.Replace(Const.POM.POM_VERSION_PLACEHOLDER, Const.ReflectorVersion + ((args.GeneratePOM == JARBuilderEventArgs.POMType.Snapshot) ? Const.POM.POM_VERSION_SNAPSHOT : string.Empty))
                                     .Replace(Const.POM.POM_RUNTIME_PLACEHOLDER, Const.Framework.RuntimeFolder)
                                     .Replace(Const.POM.POM_SOURCEDIRECTORIES_PLACEHOLDER, sourceFlders);

                var fileName = Path.Combine(srcRootFolder, string.Format("{0}.xml", Const.Framework.RuntimeFolder));
                File.WriteAllText(fileName, jcoPom);
                reportStr = string.Format("{0} POM created in {1}.", fileName, DateTime.Now - dtStart);
            }
            catch (OperationCanceledException ex)
            {
                reportStr = string.Format("Error {0}", ex.Message);
                AppendToConsole(LogLevel.Error, reportStr);
            }
            catch (Exception ex)
            {
                reportStr = string.Format("Error {0}", ex.Message);
                AppendToConsole(LogLevel.Error, reportStr);
                failed = true;
            }
            finally
            {
                EndOperationHandler?.Invoke(null, new EndOperationEventArgs(reportStr, failed));
            }
        }