/// <summary>
        /// Builds the plugin and returns the name of the jar that was created
        /// </summary>
        private string BuildPlugin(RoslynPluginDefinition definition, string outputDirectory)
        {
            logger.LogInfo(UIResources.APG_GeneratingPlugin);

            // Make the .jar name match the format [artefactid]-[version].jar
            // i.e. the format expected by Maven
            Directory.CreateDirectory(outputDirectory);
            string fullJarPath = Path.Combine(outputDirectory,
                                              definition.Manifest.Key + "-plugin-" + definition.Manifest.Version + ".jar");

            string repositoryId = RepositoryKeyUtilities.GetValidKey(definition.PackageId + "." + definition.Language);

            string repoKey = RepositoryKeyPrefix + repositoryId;

            RoslynPluginJarBuilder builder = new RoslynPluginJarBuilder(logger);

            builder.SetLanguage(definition.Language)
            .SetRepositoryKey(repoKey)
            .SetRepositoryName(definition.Manifest.Name)
            .SetRulesFilePath(definition.RulesFilePath)
            .SetPluginManifestProperties(definition.Manifest)
            .SetJarFilePath(fullJarPath);

            AddRoslynMetadata(builder, definition, repositoryId);

            string relativeStaticFilePath = "static/" + Path.GetFileName(definition.StaticResourceName);

            builder.AddResourceFile(definition.SourceZipFilePath, relativeStaticFilePath);

            builder.Build();
            return(fullJarPath);
        }
Beispiel #2
0
        private static void CheckGetValidKeyThrows(string input)
        {
            // Should throw on input that cannot be corrected
            Action action = () => RepositoryKeyUtilities.GetValidKey(input);

            action.Should().Throw <ArgumentException>();
        }
Beispiel #3
0
        private static void TestGetValidKey(string input, string expected)
        {
            string actual = RepositoryKeyUtilities.GetValidKey(input);

            actual.Should().Be(expected, "Unexpected key returned");

            RepositoryKeyUtilities.ThrowIfInvalid(expected); // should not throw on values returned by GetValidKey
        }
Beispiel #4
0
        private static void CheckThrowIfInvalidThrows(string input)
        {
            Action action = () => RepositoryKeyUtilities.ThrowIfInvalid(input);

            action.Should().ThrowExactly <ArgumentException>();
        }
Beispiel #5
0
 public RoslynPluginJarBuilder SetRepositoryKey(string key)
 {
     RepositoryKeyUtilities.ThrowIfInvalid(key);
     this.repositoryKey = key;
     return(this);
 }
Beispiel #6
0
 private static void CheckGetValidKeyThrows(string input)
 {
     // Should throw on input that cannot be corrected
     AssertException.Expect <ArgumentException>(() => RepositoryKeyUtilities.GetValidKey(input));
 }
Beispiel #7
0
 private static void CheckThrowIfInvalidThrows(string input)
 {
     AssertException.Expect <ArgumentException>(() => RepositoryKeyUtilities.ThrowIfInvalid(input));
 }