public Artifact GetArtifactFor(NPanday.Model.Pom.Model model) { Artifact artifact = new Artifact(); artifact.ArtifactId = model.artifactId; artifact.GroupId = model.groupId; artifact.Version = model.version; artifact.Extension = GetExtensionFor(model.packaging); return(artifact); }
/// <summary> /// Creates an instance of the specified mojo name within the specified application domain. /// </summary> /// <param name="mojoName">the name of the mojo to create</param> /// <param name="pluginAssemblyFile">the.NET maven plugin</param> /// <param name="paramFile">the file containing the parameters to inject into an instance /// of the specified mojo</param> /// <param name="applicationDomain"> /// the application domain used to create the specified mojo name instance</param> /// <returns>an instance of the specified mojo name within the specified application domain</returns> internal int BuildPluginProject(AppDomain applicationDomain, FileInfo pluginArtifact, FileInfo outputDirectory, string groupId, string artifactId, string version) { ObjectHandle objectHandle = applicationDomain.CreateInstanceFrom(@pluginArtifact.FullName, "NPanday.Plugin.Generator.JavaClassUnmarshaller"); JavaClassUnmarshaller jcuRemote = (JavaClassUnmarshaller)objectHandle.Unwrap(); List <JavaClass> javaClasses = jcuRemote.GetMojosFor(artifactId, groupId); JavaClassUnmarshaller jcuLocal = new JavaClassUnmarshaller(); char[] delim = { '.' }; DirectoryInfo sourceDirectory = new DirectoryInfo(@outputDirectory.FullName + "/src/main/java/" + artifactId.Replace('.', '/')); sourceDirectory.Create(); if (javaClasses.Count == 0) { Console.WriteLine("NPanday-000-000: There are no Mojos within the assembly: Artifact Id = " + artifactId); return(1); } foreach (JavaClass javaClass in javaClasses) { string[] tokens = javaClass.ClassName.Split(delim); string classFileName = tokens[tokens.Length - 1]; FileInfo fileInfo = new FileInfo(sourceDirectory.FullName + "/" + classFileName + ".java"); jcuLocal.unmarshall(javaClass, fileInfo); } TextReader reader = new StreamReader(typeof(Generator).Assembly .GetManifestResourceStream("NPanday.Plugin.MojoGenerator.pom-java.xml")); XmlSerializer serializer = new XmlSerializer(typeof(NPanday.Model.Pom.Model)); NPanday.Model.Pom.Model model = (NPanday.Model.Pom.Model)serializer.Deserialize(reader); model.artifactId = artifactId + ".JavaBinding"; model.groupId = groupId; model.version = version; model.name = artifactId + ".JavaBinding"; FileInfo outputPomXml = new FileInfo(@outputDirectory.FullName + "/pom-java.xml"); TextWriter textWriter = new StreamWriter(@outputPomXml.FullName); serializer.Serialize(textWriter, model); return(0); }
public override string[] ImportProjectType(ProjectDigest[] prjDigests, string solutionFile, string groupId, string artifactId, string version, string scmTag, bool writePom, List <Reference> missingReferences, List <string> nonPortableReferences) { List <string> generatedPoms = new List <string>(); string pomFileName = Path.GetFullPath(Path.GetDirectoryName(solutionFile) + @"\pom.xml"); // write the parent pom NPanday.Model.Pom.Model mainModel = PomConverter.MakeProjectsParentPomModel(prjDigests, pomFileName, groupId, artifactId, version, scmTag, true); generatedPoms.Add(pomFileName); generatedPoms.AddRange( GenerateChildPoms(prjDigests, groupId, pomFileName, mainModel, writePom, scmTag, missingReferences, nonPortableReferences) ); return(generatedPoms.ToArray()); }
public string[] GenerateChildPoms(ProjectDigest[] prjDigests, string groupId, string parentPomFilename, NPanday.Model.Pom.Model parentPomModel, bool writePom, string scmTag, List <Reference> missingReferences, List <string> nonPortableReferences) { List <string> generatedPoms = new List <string>(); // make the child pom NPanday.Model.Pom.Model[] models = PomConverter.ConvertProjectsToPomModels(prjDigests, parentPomFilename, parentPomModel, groupId, writePom, scmTag, missingReferences, nonPortableReferences); if (models != null && models.Length > 0) { foreach (ProjectDigest prj in prjDigests) { string fileDir = Path.GetDirectoryName(prj.FullFileName); string pomFile = Path.GetFullPath(fileDir + @"\pom.xml"); generatedPoms.Add(pomFile); } } return(generatedPoms.ToArray()); }