Exemplo n.º 1
0
 public bool Matches(MavenCoordinate other)
 {
     return(string.Equals(GroupId, other.GroupId) &&
            string.Equals(ArtefactId, other.ArtefactId) &&
            (string.Equals(Version, other.Version) ||
             string.IsNullOrEmpty(Version) ||
             string.IsNullOrEmpty(other.Version)));
 }
Exemplo n.º 2
0
        public static CompiledAssembly[] CompileMaven(MavenCoordinate cord)
        {
            System.Console.WriteLine("Starting {0}", cord);

            if (cord.Version == null)
            {
                var metadata = XmlDeserialize <Metadata>(HttpGet(
                                                             $"http://central.maven.org/maven2/{cord.GroupId.Replace('.', '/')}/{cord.ArtefactId}/maven-metadata.xml"));

                cord = new MavenCoordinate(cord.GroupId, cord.ArtefactId, metadata.Versioning.Release);
            }

            if (Cache.TryGetValue(cord, out var cached))
            {
                if (cached == null)
                {
                    throw new NotImplementedException("Don't know what to do with cyclic dependencies");
                }
                return(cached);
            }

            Cache[cord] = null;

            var pom = XmlDeserialize <Project>(HttpGet(
                                                   $"http://central.maven.org/maven2/{cord.GroupId.Replace('.', '/')}/{cord.ArtefactId}/{cord.Version}/{cord.ArtefactId}-{cord.Version}.pom"));

            var compiledDeps = new List <CompiledAssembly>();

            foreach (var dependency in pom.Dependencies?.Dependency ?? Enumerable.Empty <Dependency>())
            {
                var depCord = new MavenCoordinate(dependency.GroupId, dependency.ArtifactId, dependency.Version);
                compiledDeps.AddRange(CompileMaven(depCord));
            }

            var jar = JarReader.BuildJarFile(WebRequest
                                             .CreateHttp(
                                                 $"http://central.maven.org/maven2/{cord.GroupId.Replace('.', '/')}/{cord.ArtefactId}/{cord.Version}/{cord.ArtefactId}-{cord.Version}.jar")
                                             .GetResponse().GetResponseStream());

            var jab = new JavaAssemblyBuilder();

            foreach (var dep in compiledDeps)
            {
                jab.RegisterReferenceAssembly(dep.Loaded);
            }

            var built = jab.BuildAssembly(cord.ArtefactId, SanitizeVersion(cord.Version), jar);

            compiledDeps.Add(new CompiledAssembly(built));

            System.Console.WriteLine("Finished {0}:{1}:{2}", cord.GroupId, cord.ArtefactId, cord.Version);

            return(Cache[cord] = compiledDeps.ToArray());
        }
Exemplo n.º 3
0
 protected bool Equals(MavenCoordinate other)
 {
     return(string.Equals(GroupId, other.GroupId) && string.Equals(ArtefactId, other.ArtefactId) && string.Equals(Version, other.Version));
 }