gradle install如何生成pom.xml文件

时间:2019-05-27 15:42:55

标签: java maven gradle pom.xml

当我运行Private Sub CreateAISnake() size(0) = Me.Width - 10 size(1) = Me.Height - 10 Randomize() xlocation = Int(Rnd() * size(0) + 1) ylocation = Int(Rnd() * size(1) + 1) AIsnake(0) = New PictureBox With AIsnake(0) .Width = 15 .Height = 15 .BackColor = Color.White .Top = ylocation .Left = xlocation End With Me.Controls.Add(AIsnake(0)) For counter = 1 To 9 AIsnake(counter) = New PictureBox With AIsnake(counter) .Width = 15 .Height = 15 .BackColor = Color.White .Top = AIsnake(counter - 1).Top - 16 .Left = AIsnake(counter - 1).Left End With Me.Controls.Add(AIsnake(counter)) AIsnake(counter).BringToFront() Next End Sub Private Sub FollowSnake(ByRef object1 As Object, ByRef object2 As Object) If object1.left + object1.width > object2.left Then AILR = -5 End If If object1.left + object1.width < object2.left Then AILR = 5 End If If object1.top + object1.height > object2.top Then AIUD = -5 End If If object1.top + object1.height < object2.top Then AIUD = 5 End If End Sub Private Sub AISnakeMover_Tick(sender As Object, e As EventArgs) Handles AISnakeMover.Tick For counter = 9 To 1 Step -1 AIsnake(counter).Top = AIsnake(counter - 1).Top AIsnake(counter).Left = AIsnake(counter - 1).Left Next FollowSnake(AIsnake(0), snake(0)) AIsnake(0).Top += AIUD AIsnake(0).Left += AILR End Sub 时,它将在每个子项目中生成漂亮的 Public Class Form1 Dim g As New Graph Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click g.AddVertex("A") g.AddVertex("B") g.AddVertex("C") g.AddVertex("D") g.AddVertex("E") g.AddEdge(0, 1, 6) g.AddEdge(0, 3, 1) g.AddEdge(1, 0, 6) g.AddEdge(1, 2, 5) g.AddEdge(1, 3, 2) g.AddEdge(1, 4, 2) g.AddEdge(2, 1, 5) g.AddEdge(2, 4, 5) g.AddEdge(3, 0, 1) g.AddEdge(3, 1, 2) g.AddEdge(3, 4, 1) g.AddEdge(4, 1, 2) g.AddEdge(4, 2, 5) g.AddEdge(4, 3, 1) MsgBox("Graph created") End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim pathinfo As New Dijkstra(g.getAdjacencyMatrix, 5) Dim distances = pathinfo.aShortestDistance Dim paths = pathinfo.path For counter = 0 To distances.Length - 1 ListBox1.Items.Add("Vertex" & counter & " Distance" & distances(counter) & " Via Vertex" & paths(counter)) Next End Sub End Class Public Class Vertex Public value As String Public visited As Boolean Public Sub New(ByVal value As String) Me.value = value visited = False End Sub End Class Public Class Graph Const Total_Vertices As Integer = 9 Dim Vertices() As Vertex Dim Adjacency_Matrix(,) As Double Dim iNumberOfVertices As Integer Dim iMaxSize As Integer Public Sub New() ReDim Vertices(Total_Vertices) ReDim Adjacency_Matrix(Total_Vertices, Total_Vertices) For x = 0 To Total_Vertices - 1 For y = 0 To Total_Vertices - 1 Adjacency_Matrix(x, y) = 0 Next Next iNumberOfVertices = 0 End Sub Public Sub AddVertex(ByVal value As String) Vertices(iNumberOfVertices) = New Vertex(value) iNumberOfVertices += 1 End Sub Public Sub AddEdge(ByVal StartVertex As Integer, ByVal EndVertex As Integer, weight As Double) Adjacency_Matrix(StartVertex, EndVertex) = weight ' directed Adjacency_Matrix(EndVertex, StartVertex) = weight ' undirected End Sub Public Sub ShowVertex(ByVal v As Integer) MsgBox(Vertices(v).value) End Sub Public Function getAdjacencyMatrix() Return Adjacency_Matrix End Function End Class Public Class Dijkstra Dim shortestDistance() As Double Dim previousVertices() As Double Dim unvisitedVertices As New List(Of Integer) Public Sub New(adjacencyMatrix As Double(,), totalVertices As Integer) ReDim previousVertices(totalVertices - 1) ReDim shortestDistance(totalVertices - 1) 'setting unvisited vertex to 0 and shortest distance as infinity For counter = 0 To totalVertices - 1 unvisitedVertices.Add(counter) shortestDistance(counter) = Double.PositiveInfinity Next shortestDistance(0) = 0 'Start Vertex 'generate info about shortest distance and paths While unvisitedVertices.Count > 0 Dim currentVertex As Integer = getNextVertex() 'scan the matrix For counter = 0 To totalVertices - 1 If adjacencyMatrix(currentVertex, counter) > 0 Then ' edge check with another vertex If shortestDistance(counter) > shortestDistance(currentVertex) + adjacencyMatrix(currentVertex, counter) Then shortestDistance(counter) = shortestDistance(currentVertex) + adjacencyMatrix(currentVertex, counter) previousVertices(counter) = currentVertex End If End If Next End While End Sub Public Function getNextVertex() 'returns the unvisited vertex with the smallest known distance from the start Dim smallestKnownDistance = Double.PositiveInfinity Dim vertex As Integer = -1 'scan the list of unvisited vertices For Each value As Integer In unvisitedVertices If shortestDistance(value) <= smallestKnownDistance Then smallestKnownDistance = shortestDistance(value) vertex = value End If Next unvisitedVertices.Remove(vertex) Return vertex End Function Public ReadOnly Property aShortestDistance() As Double() Get Return shortestDistance End Get End Property Public ReadOnly Property path As Double() Get Return previousVertices End Get End Property End Class 文件。

在哪里可以看到实现此目的的源代码?

根据Maven plugin documentation,关于Upload任务有一些要求,但是其文档和源代码并没有具体说明。

1 个答案:

答案 0 :(得分:1)

您可以将gradle-maven-VERSION.jar添加到依赖项中,然后自己调试插件。相应的源代码位于gradle安装中,或者位于github上:https://github.com/gradle/gradle/tree/master/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal

为您提供一个良好的开端:大部分代码都位于DefaultMavenPom类中。 它是在DefaultMavenPomFactory.create()中创建的,并带有一些虚拟值:

  • MavenProject.EMPTY_PROJECT_GROUP_ID
  • MavenProject.EMPTY_PROJECT_ARTIFACT_ID
  • MavenProject.EMPTY_PROJECT_VERSION

然后,调用AbstractMavenResolver.publish(IvyModulePublishMetadata moduleVersion), 其中,

  • 根据DefaultArtifactPom.assignArtifactValuesToPom()中的实际工件填充基本pom数据
  • 填充依赖项-用DefaultMavenPom.getGeneratedDependencies()填充
  • 写入生成的文件
相关问题