66 "cmp"
77 "context"
88 "encoding/xml"
9+ "errors"
910 "fmt"
1011 "io"
1112 "io/fs"
@@ -25,6 +26,7 @@ import (
2526 "golang.org/x/mod/semver"
2627 "golang.org/x/mod/sumdb/dirhash"
2728
29+ "github.com/bufbuild/plugins/internal/maven"
2830 "github.com/bufbuild/plugins/internal/plugin"
2931 "github.com/bufbuild/plugins/internal/source"
3032)
@@ -326,6 +328,38 @@ func TestMavenDependencies(t *testing.T) {
326328 }
327329}
328330
331+ func TestMavenPOMInSync (t * testing.T ) {
332+ t .Parallel ()
333+ plugins := loadFilteredPlugins (t )
334+ pluginsDir , err := filepath .Abs (filepath .Join (".." , "plugins" ))
335+ require .NoError (t , err )
336+ for _ , p := range plugins {
337+ if p .Registry .Maven == nil {
338+ continue
339+ }
340+ pomPath := filepath .Join (filepath .Dir (p .Path ), "pom.xml" )
341+ if _ , err := os .Stat (pomPath ); err != nil {
342+ if errors .Is (err , fs .ErrNotExist ) {
343+ continue
344+ }
345+ require .NoError (t , err )
346+ }
347+ t .Run (fmt .Sprintf ("%s/%s@%s" , p .Identity .Owner (), p .Identity .Plugin (), p .PluginVersion ), func (t * testing.T ) {
348+ t .Parallel ()
349+ pluginVersionDir := filepath .Dir (p .Path )
350+ pluginConfig , err := bufremotepluginconfig .ParseConfig (p .Path )
351+ require .NoError (t , err )
352+ require .NoError (t , maven .MergeTransitiveDeps (pluginConfig , pluginsDir ))
353+ require .NoError (t , maven .DeduplicateAllDeps (pluginConfig .Registry .Maven ))
354+ expectedPOM , err := maven .RenderPOM (pluginConfig )
355+ require .NoError (t , err )
356+ actualPOM , err := os .ReadFile (filepath .Join (pluginVersionDir , "pom.xml" ))
357+ require .NoError (t , err )
358+ assert .Equal (t , expectedPOM , string (actualPOM ), "pom.xml is out of sync with buf.plugin.yaml" )
359+ })
360+ }
361+ }
362+
329363func TestNugetDependencies (t * testing.T ) {
330364 t .Parallel ()
331365
0 commit comments