Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
ProgHaj committed May 15, 2023

Verified

This commit was signed with the committer’s verified signature.
ProgHaj Magnus Tullberg
1 parent 26591f1 commit 032bc49
Showing 26 changed files with 969 additions and 111 deletions.
9 changes: 3 additions & 6 deletions pkg/callgraph/language/java11/cmd_factory_test.go
Original file line number Diff line number Diff line change
@@ -7,10 +7,9 @@ import (
)

func TestMakeGradleCopyDependenciesCmd(t *testing.T) {
workingDir := "dir"
gradlew := "gradlew"
groovyFilePath := "groovyfilename"
cmd, err := CmdFactory{}.MakeGradleCopyDependenciesCmd(workingDir, gradlew, groovyFilePath)
cmd, err := CmdFactory{}.MakeGradleCopyDependenciesCmd(dir, gradlew, groovyFilePath)
assert.NotNil(t, cmd)
args := cmd.Args
assert.Contains(t, args, "gradlew")
@@ -20,9 +19,8 @@ func TestMakeGradleCopyDependenciesCmd(t *testing.T) {
}

func TestMakeMvnCopyDependenciesCmd(t *testing.T) {
workingDir := "dir"
targetDir := "target"
cmd, _ := CmdFactory{}.MakeMvnCopyDependenciesCmd(workingDir, targetDir)
cmd, _ := CmdFactory{}.MakeMvnCopyDependenciesCmd(dir, targetDir)
assert.NotNil(t, cmd)
args := cmd.Args
assert.Contains(t, args, "mvn")
@@ -34,10 +32,9 @@ func TestMakeMvnCopyDependenciesCmd(t *testing.T) {

func TestMakeCallGraphGenerationCmd(t *testing.T) {
jarPath := "jarpath"
workingDir := "dir"
targetClasses := "targetclasses"
dependencyClasses := "dependencypath"
cmd, err := CmdFactory{}.MakeCallGraphGenerationCmd(jarPath, workingDir, targetClasses, dependencyClasses)
cmd, err := CmdFactory{}.MakeCallGraphGenerationCmd(jarPath, dir, targetClasses, dependencyClasses)

assert.NoError(t, err)
assert.NotNil(t, cmd)
4 changes: 2 additions & 2 deletions pkg/callgraph/language/java11/job.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import (

conf "github.com/debricked/cli/pkg/callgraph/config"
"github.com/debricked/cli/pkg/callgraph/job"
"github.com/debricked/cli/pkg/io/finder"
gfinder "github.com/debricked/cli/pkg/io/finder/gradle"
ioWriter "github.com/debricked/cli/pkg/io/writer"
)

@@ -52,7 +52,7 @@ func (j *Job) Run() {
}

groovyFilePath := path.Join(workingDirectory, ".debrickedGroovyScript.groovy")
ish := finder.NewScriptHandler(groovyFilePath, "embeded/gradle-script.groovy", ioWriter.FileWriter{})
ish := gfinder.NewScriptHandler(groovyFilePath, "embeded/gradle-script.groovy", ioWriter.FileWriter{})
ish.WriteInitFile()

cmd, err = j.cmdFactory.MakeGradleCopyDependenciesCmd(workingDirectory, gradlew, groovyFilePath)
10 changes: 7 additions & 3 deletions pkg/callgraph/language/java11/strategy_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package java

import (
"os"
"path/filepath"
"testing"

"github.com/debricked/cli/pkg/callgraph/config"
@@ -65,14 +67,16 @@ func TestInvokeManyFilesWCorrectFilters(t *testing.T) {
conf := config.NewConfig("java", []string{"arg1"}, map[string]string{"kwarg": "val"})
finder := testdata.NewEmptyFinderMock()
testFiles := []string{"file-1", "file-2", "file-3"}
finder.FindMavenRootsNames = []string{"file-3"}
finder.FindMavenRootsNames = []string{"file-3/pom.xml"}
finder.FindJavaClassDirsNames = []string{"file-3/test.class"}
s := NewStrategy(conf, testFiles, finder)
jobs, _ := s.Invoke()
assert.Len(t, jobs, 1)
for _, job := range jobs {
assert.Equal(t, job.GetFiles(), []string{"file-3/"})
assert.Equal(t, job.GetDir(), "file-3")
file, _ := filepath.Abs("file-3/")
dir, _ := filepath.Abs("file-3/")
assert.Equal(t, job.GetFiles(), []string{file + string(os.PathSeparator)}) // Get files return gcd path
assert.Equal(t, job.GetDir(), dir)

}
}
15 changes: 10 additions & 5 deletions pkg/io/finder/finder.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package finder

import "path/filepath"
import (
"path/filepath"

"github.com/debricked/cli/pkg/io/finder/gradle"
"github.com/debricked/cli/pkg/io/finder/maven"
)

type IFinder interface {
FindMavenRoots(files []string) ([]string, error)
@@ -12,7 +17,7 @@ type Finder struct{}

func (f Finder) FindMavenRoots(files []string) ([]string, error) {
pomFiles := FilterFiles(files, "pom.xml")
ps := PomService{}
ps := maven.PomService{}
rootFiles := ps.GetRootPomFiles(pomFiles)
return rootFiles, nil
}
@@ -34,7 +39,7 @@ func (f Finder) FindJavaClassDirs(files []string) ([]string, error) {

func (f Finder) FindGradleRoots(files []string) ([]string, error) {
gradleBuildFiles := FilterFiles(files, "gradle.build(.kts)?")
gradleSetup := NewGradleSetup()
gradleSetup := gradle.NewGradleSetup()
err := gradleSetup.Configure(files)
if err != nil {

@@ -43,15 +48,15 @@ func (f Finder) FindGradleRoots(files []string) ([]string, error) {

gradleMainDirs := make(map[string]bool)
for _, gradleProject := range gradleSetup.GradleProjects {
dir := gradleProject.dir
dir := gradleProject.Dir
if _, ok := gradleMainDirs[dir]; ok {
continue
}
gradleMainDirs[dir] = true
}
for _, file := range gradleBuildFiles {
dir, _ := filepath.Abs(filepath.Dir(file))
if _, ok := gradleSetup.subProjectMap[dir]; ok {
if _, ok := gradleSetup.SubProjectMap[dir]; ok {
continue
}
if _, ok := gradleMainDirs[dir]; ok {
18 changes: 18 additions & 0 deletions pkg/io/finder/gradle/embeded/gradle-init-script.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
def debrickedOutputFile = new File('.debricked.multiprojects.txt')

allprojects {
task debrickedFindSubProjectPaths() {
String output = project.projectDir
doLast {
synchronized(debrickedOutputFile) {
debrickedOutputFile << output + System.getProperty("line.separator")
}
}
}
}

allprojects {
task debrickedAllDeps(type: DependencyReportTask) {
outputFile = file('./.debricked-gradle-dependencies.txt')
}
}
2 changes: 1 addition & 1 deletion pkg/io/finder/err.go → pkg/io/finder/gradle/err.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package finder
package gradle

type SetupScriptError struct {
message string
62 changes: 31 additions & 31 deletions pkg/io/finder/gradle.go → pkg/io/finder/gradle/gradle.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package finder
package gradle

import (
"bufio"
@@ -28,18 +28,18 @@ type ISetup interface {
}

type Project struct {
dir string
gradlew string
mainBuildFile string
Dir string
Gradlew string
MainBuildFile string
}

type Setup struct {
gradlewMap map[string]string
settingsMap map[string]string
subProjectMap map[string]string
groovyScriptPath string
gradlewOsName string
settingsFilenames []string
GradlewMap map[string]string
SettingsMap map[string]string
SubProjectMap map[string]string
GroovyScriptPath string
GradlewOsName string
SettingsFilenames []string
GradleProjects []Project
MetaFileFinder IMetaFileFinder
Writer writer.IFileWriter
@@ -57,12 +57,12 @@ func NewGradleSetup() *Setup {
ish := InitScriptHandler{groovyScriptPath, "embeded/gradle-init-script.groovy", writer}

return &Setup{
gradlewMap: map[string]string{},
settingsMap: map[string]string{},
subProjectMap: map[string]string{},
groovyScriptPath: groovyScriptPath,
gradlewOsName: gradlewOsName,
settingsFilenames: []string{"settings.gradle", "settings.gradle.kts"},
GradlewMap: map[string]string{},
SettingsMap: map[string]string{},
SubProjectMap: map[string]string{},
GroovyScriptPath: groovyScriptPath,
GradlewOsName: gradlewOsName,
SettingsFilenames: []string{"settings.gradle", "settings.gradle.kts"},
GradleProjects: []Project{},
MetaFileFinder: MetaFileFinder{filepath: FilePath{}},
Writer: writer,
@@ -78,8 +78,8 @@ func (gs *Setup) Configure(files []string) error {
return err
}
settingsMap, gradlewMap, err := gs.MetaFileFinder.Find(files)
gs.gradlewMap = gradlewMap
gs.settingsMap = settingsMap
gs.GradlewMap = gradlewMap
gs.SettingsMap = settingsMap
if err != nil {

return err
@@ -96,16 +96,16 @@ func (gs *Setup) Configure(files []string) error {
func (gs *Setup) setupFilePathMappings(files []string) {
for _, file := range files {
dir, _ := filepath.Abs(filepath.Dir(file))
possibleGradlew := filepath.Join(dir, gs.gradlewOsName)
possibleGradlew := filepath.Join(dir, gs.GradlewOsName)
_, err := os.Stat(possibleGradlew)
if err == nil {
gs.gradlewMap[dir] = possibleGradlew
gs.GradlewMap[dir] = possibleGradlew
}
for _, settingsFilename := range gs.settingsFilenames {
for _, settingsFilename := range gs.SettingsFilenames {
possibleSettings := filepath.Join(dir, settingsFilename)
_, err := os.Stat(possibleSettings)
if err == nil {
gs.settingsMap[dir] = possibleSettings
gs.SettingsMap[dir] = possibleSettings
}
}
}
@@ -114,17 +114,17 @@ func (gs *Setup) setupFilePathMappings(files []string) {
func (gs *Setup) setupGradleProjectMappings() error {
var errors SetupError
var settingsDirs []string
for k := range gs.settingsMap {
for k := range gs.SettingsMap {
settingsDirs = append(settingsDirs, k)
}
sort.Strings(settingsDirs)
for _, dir := range settingsDirs {
if _, ok := gs.subProjectMap[dir]; ok {
if _, ok := gs.SubProjectMap[dir]; ok {
continue
}
gradlew := gs.GetGradleW(dir)
mainFile := gs.settingsMap[dir]
gradleProject := Project{dir: dir, gradlew: gradlew, mainBuildFile: mainFile}
mainFile := gs.SettingsMap[dir]
gradleProject := Project{Dir: dir, Gradlew: gradlew, MainBuildFile: mainFile}
err := gs.setupSubProjectPaths(gradleProject)

if err != nil {
@@ -152,7 +152,7 @@ func (cf CmdFactory) MakeFindSubGraphCmd(workingDirectory string, gradlew string
}

func (gs *Setup) setupSubProjectPaths(gp Project) error {
dependenciesCmd, _ := gs.CmdFactory.MakeFindSubGraphCmd(gp.dir, gp.gradlew, gs.groovyScriptPath)
dependenciesCmd, _ := gs.CmdFactory.MakeFindSubGraphCmd(gp.Dir, gp.Gradlew, gs.GroovyScriptPath)
var stderr bytes.Buffer
dependenciesCmd.Stderr = &stderr
_, err := dependenciesCmd.Output()
@@ -162,7 +162,7 @@ func (gs *Setup) setupSubProjectPaths(gp Project) error {

return SetupSubprojectError{message: errorOutput + err.Error()}
}
multiProject := filepath.Join(gp.dir, multiProjectFilename)
multiProject := filepath.Join(gp.Dir, multiProjectFilename)
file, err := os.Open(multiProject)
if err != nil {

@@ -174,7 +174,7 @@ func (gs *Setup) setupSubProjectPaths(gp Project) error {
scanner := bufio.NewScanner(file)
for scanner.Scan() {
subProjectPath := scanner.Text()
gs.subProjectMap[subProjectPath] = gp.dir
gs.SubProjectMap[subProjectPath] = gp.Dir
}

if err := scanner.Err(); err != nil {
@@ -186,11 +186,11 @@ func (gs *Setup) setupSubProjectPaths(gp Project) error {

func (gs *Setup) GetGradleW(dir string) string {
gradlew := initGradle
val, ok := gs.gradlewMap[dir]
val, ok := gs.GradlewMap[dir]
if ok {
gradlew = val
} else {
for dirPath, gradlePath := range gs.gradlewMap {
for dirPath, gradlePath := range gs.GradlewMap {
// potential improvement, sort gradlewMap in longest path first"
rel, err := filepath.Rel(dirPath, dir)
isRelative := !strings.HasPrefix(rel, "..") && rel != ".."
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package finder
package gradle

import (
"fmt"
@@ -10,7 +10,6 @@ import (

writerTestdata "github.com/debricked/cli/pkg/io/writer/testdata"

"github.com/debricked/cli/pkg/io/writer"
"github.com/stretchr/testify/assert"
)

@@ -38,35 +37,35 @@ func TestSetupFilePathMappings(t *testing.T) {
files := []string{filepath.Join("testdata", "project", "build.gradle")}
gs.setupFilePathMappings(files)

assert.Len(t, gs.gradlewMap, 1)
assert.Len(t, gs.settingsMap, 1)
assert.Len(t, gs.GradlewMap, 1)
assert.Len(t, gs.SettingsMap, 1)
}

func TestSetupFilePathMappingsNoFiles(t *testing.T) {
gs := NewGradleSetup()
gs.setupFilePathMappings([]string{})

assert.Len(t, gs.gradlewMap, 0)
assert.Len(t, gs.settingsMap, 0)
assert.Len(t, gs.GradlewMap, 0)
assert.Len(t, gs.SettingsMap, 0)
}

func TestSetupFilePathMappingsNoGradlew(t *testing.T) {
gs := NewGradleSetup()
files := []string{filepath.Join("testdata", "project", "subproject", "build.gradle")}
gs.setupFilePathMappings(files)

assert.Len(t, gs.gradlewMap, 0)
assert.Len(t, gs.settingsMap, 0)
assert.Len(t, gs.GradlewMap, 0)
assert.Len(t, gs.SettingsMap, 0)
}

func TestSetupGradleProjectMappings(t *testing.T) {
gs := NewGradleSetup()
gs.CmdFactory = &mockCmdFactory{}

gs.settingsMap = map[string]string{
gs.SettingsMap = map[string]string{
filepath.Join("testdata", "project"): filepath.Join("testdata", "project", "settings.gradle"),
}
gs.subProjectMap = map[string]string{}
gs.SubProjectMap = map[string]string{}
err := gs.setupGradleProjectMappings()
// assert GradleSetupSubprojectError
assert.NotNil(t, err)
@@ -108,35 +107,35 @@ func TestSetupSubProjectPathsNoFileCreated(t *testing.T) {
gs.CmdFactory = &mockCmdFactory{createFile: false}

absPath, _ := filepath.Abs(filepath.Join("testdata", "project"))
gradleProject := Project{dir: absPath, gradlew: filepath.Join("testdata", "project", "gradlew")}
gradleProject := Project{Dir: absPath, Gradlew: filepath.Join("testdata", "project", "gradlew")}
err := gs.setupSubProjectPaths(gradleProject)
fmt.Println(err)
assert.NotNil(t, err)
assert.Len(t, gs.subProjectMap, 0)
assert.Len(t, gs.SubProjectMap, 0)
}

func TestSetupSubProjectPaths(t *testing.T) {
gs := NewGradleSetup()
gs.CmdFactory = &mockCmdFactory{createFile: true}

absPath, _ := filepath.Abs(filepath.Join("testdata", "project"))
gradleProject := Project{dir: absPath, gradlew: filepath.Join("testdata", "project", "gradlew")}
gradleProject := Project{Dir: absPath, Gradlew: filepath.Join("testdata", "project", "gradlew")}
err := gs.setupSubProjectPaths(gradleProject)
assert.Nil(t, err)
assert.Len(t, gs.subProjectMap, 1)
assert.Len(t, gs.SubProjectMap, 1)

absPath, _ = filepath.Abs(filepath.Join("testdata", "project", "subproject"))
gradleProject = Project{dir: absPath, gradlew: filepath.Join("testdata", "project", "gradlew")}
gradleProject = Project{Dir: absPath, Gradlew: filepath.Join("testdata", "project", "gradlew")}
err = gs.setupSubProjectPaths(gradleProject)
assert.Nil(t, err)
assert.Len(t, gs.subProjectMap, 2)
assert.Len(t, gs.SubProjectMap, 2)
}

func TestSetupSubProjectPathsError(t *testing.T) {
gs := NewGradleSetup()

absPath, _ := filepath.Abs(filepath.Join("testdata", "project"))
gradleProject := Project{dir: absPath, gradlew: filepath.Join("testdata", "project", "gradlew")}
gradleProject := Project{Dir: absPath, Gradlew: filepath.Join("testdata", "project", "gradlew")}
err := gs.setupSubProjectPaths(gradleProject)

assert.NotNil(t, err)
@@ -145,7 +144,7 @@ func TestSetupSubProjectPathsError(t *testing.T) {
func TestGetGradleW(t *testing.T) {
gs := NewGradleSetup()

gs.gradlewMap = map[string]string{
gs.GradlewMap = map[string]string{
filepath.Join("testdata", "project"): filepath.Join("testdata", "project", "gradlew"),
}

@@ -160,9 +159,6 @@ func TestGetGradleW(t *testing.T) {

type mockInitScriptHandler struct {
writeInitFileErr error
groovyScriptPath string
initPath string
fileWriter writer.IFileWriter
}

func (_ mockInitScriptHandler) ReadInitFile() ([]byte, error) {
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package finder
package gradle

import (
"github.com/debricked/cli/pkg/io/writer"
28 changes: 28 additions & 0 deletions pkg/io/finder/gradle/init_script_handler_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package gradle

// func TestWriteInitFile(t *testing.T) {
// createErr := errors.New("create-error")
// fileWriterMock := &writerTestdata.FileWriterMock{CreateErr: createErr}

// sf := InitScriptHandler{fileWriter: fileWriterMock}
// err := sf.WriteInitFile()
// assert.Equal(t, SetupScriptError{createErr.Error()}, err)

// fileWriterMock = &writerTestdata.FileWriterMock{WriteErr: createErr}
// sf = InitScriptHandler{initPath: "file", fileWriter: fileWriterMock}
// err = sf.WriteInitFile()
// assert.Equal(t, SetupScriptError{createErr.Error()}, err)
// }

// func TestWriteInitFileNoInitFile(t *testing.T) {
// sf := InitScriptHandler{initPath: "file", fileWriter: nil}
// oldGradleInitScript := gradleInitScript
// defer func() {
// gradleInitScript = oldGradleInitScript
// }()
// gradleInitScript = embed.FS{}
// err := sf.WriteInitFile()
// readErr := errors.New("open gradle-init/gradle-init-script.groovy: file does not exist")
// assert.Equal(t, SetupScriptError{readErr.Error()}, err)

// }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package finder
package gradle

import (
"os"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package finder
package gradle

import (
"errors"
34 changes: 34 additions & 0 deletions pkg/io/finder/gradle/testdata/cmd_factory_mock.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package testdata

import (
"os/exec"
"strings"
)

type CmdFactoryMock struct {
Err error
Name string
}

func (f CmdFactoryMock) MakeDependenciesGraphCmd(dir string, gradlew string, _ string) (*exec.Cmd, error) {
err := f.Err
if gradlew == "gradle" {
err = nil
}

if f.Err != nil && strings.HasPrefix(f.Err.Error(), "give-error-on-gradle") {
err = f.Err
}

return exec.Command(f.Name, `MakeDependenciesCmd`), err
}

// implement the interface
func (f CmdFactoryMock) MakeFindSubGraphCmd(_ string, _ string, _ string) (*exec.Cmd, error) {
return exec.Command(f.Name, `MakeFindSubGraphCmd`), f.Err
}

// implement the interface
func (f CmdFactoryMock) MakeDependenciesCmd(_ string) (*exec.Cmd, error) {
return exec.Command(f.Name, `MakeDependenciesCmd`), f.Err
}
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
37 changes: 0 additions & 37 deletions pkg/io/finder/init_script_handler_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/io/finder/maven.go → pkg/io/finder/maven/maven.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package finder
package maven

import (
"path/filepath"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package finder
package maven

import (
"path/filepath"
16 changes: 16 additions & 0 deletions pkg/io/finder/maven/testdata/cmd_factory_mock.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package testdata

import "os/exec"

type CmdFactoryMock struct {
Err error
Name string
Arg string
}

func (f CmdFactoryMock) MakeDependencyTreeCmd(_ string) (*exec.Cmd, error) {
if len(f.Arg) == 0 {
f.Arg = `"MakeDependencyTreeCmd"`
}
return exec.Command(f.Name, f.Arg), f.Err
}
253 changes: 253 additions & 0 deletions pkg/io/finder/maven/testdata/guava/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
<version>HEAD-jre-SNAPSHOT</version>
</parent>
<artifactId>guava</artifactId>
<packaging>bundle</packaging>
<name>Guava: Google Core Libraries for Java</name>
<url>https://github.com/google/guava</url>
<description>
Guava is a suite of core and expanded libraries that include
utility classes, Google's collections, I/O classes, and
much more.
</description>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>failureaccess</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>listenablefuture</artifactId>
<version>9999.0-empty-to-avoid-conflict-with-guava</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</dependency>
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
</dependency>
<dependency>
<groupId>com.google.j2objc</groupId>
<artifactId>j2objc-annotations</artifactId>
</dependency>
<!-- TODO(cpovirk): does this comment belong on the <dependency> in <profiles>? -->
<!-- TODO(cpovirk): want this only for dependency plugin but seems not to work there? Maven runs without failure, but the resulting Javadoc is missing the hoped-for inherited text -->
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>com.google.common</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<extensions>true</extensions>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>5.1.8</version>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
<configuration>
<instructions>
<Export-Package>
!com.google.common.base.internal,
!com.google.common.util.concurrent.internal,
com.google.common.*
</Export-Package>
<Import-Package>
com.google.common.util.concurrent.internal,
javax.annotation;resolution:=optional,
javax.crypto.*;resolution:=optional,
sun.misc.*;resolution:=optional
</Import-Package>
<Bundle-DocURL>https://github.com/google/guava/</Bundle-DocURL>
</instructions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<!-- TODO(cpovirk): include JDK sources when building testlib doc, too -->
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-jdk-sources</id>
<phase>generate-sources</phase>
<goals><goal>unpack-dependencies</goal></goals>
<configuration>
<includeArtifactIds>srczip</includeArtifactIds>
<outputDirectory>${project.build.directory}/jdk-sources</outputDirectory>
<silent>false</silent>
<!-- Exclude module-info files (since we're using -source 8 to avoid other modules problems) and FileDescriptor (which uses a language feature not available in Java 8). -->
<excludes>**/module-info.java,**/java/io/FileDescriptor.java</excludes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<!-- TODO(cpovirk): Move this to the parent after making jdk-sources available there. -->
<!-- TODO(cpovirk): can we use includeDependencySources and a local com.oracle.java:jdk-lib:noversion:sources instead of all this unzipping and manual sourcepath modification? -->
<!-- (We need JDK *sources*, not just -link, so that {@inheritDoc} works.) -->
<sourcepath>${project.build.sourceDirectory}:${project.build.directory}/jdk-sources</sourcepath>

<!-- Passing `-subpackages com.google.common` breaks things, so we explicitly exclude everything else instead. -->
<!-- excludePackageNames requires specification of packages separately from "all subpackages".
https://issues.apache.org/jira/browse/MJAVADOC-584 -->
<excludePackageNames>
com.azul.tooling.in,com.google.common.base.internal,com.google.common.base.internal.*,com.google.thirdparty.publicsuffix,com.google.thirdparty.publicsuffix.*,com.oracle.*,com.sun.*,java.*,javax.*,jdk,jdk.*,org.*,sun.*
</excludePackageNames>
<!-- Ignore some tags that are found in Java 11 sources but not recognized... under -source 8, I think it was? I can no longer reproduce the failure. -->
<tags>
<tag>
<name>apiNote</name>
<placement>X</placement>
</tag>
<tag>
<name>implNote</name>
<placement>X</placement>
</tag>
<tag>
<name>implSpec</name>
<placement>X</placement>
</tag>
<tag>
<name>jls</name>
<placement>X</placement>
</tag>
<tag>
<name>revised</name>
<placement>X</placement>
</tag>
<tag>
<name>spec</name>
<placement>X</placement>
</tag>
</tags>

<!-- TODO(cpovirk): Move this to the parent after making the package-list files available there. -->
<!-- We add the link ourselves, both so that we can choose Java 9 over the version that -source suggests and so that we can solve the JSR305 problem described below. -->
<detectJavaApiLink>false</detectJavaApiLink>
<offlineLinks>
<!-- We need local copies of some of these for 2 reasons: a User-Agent problem (https://stackoverflow.com/a/47891403/28465) and an SSL problem (https://issues.apache.org/jira/browse/MJAVADOC-507). If we choose to work around the User-Agent problem, we can go back to <links>, sidestepping the SSL problem. -->
<!-- Even after we stop using JSR305 annotations in our own code, we'll want this link so that NullPointerTester's docs can link to @CheckForNull and friends... at least once we start using this config for guava-testlib. -->
<offlineLink>
<url>https://static.javadoc.io/com.google.code.findbugs/jsr305/3.0.1/</url>
<location>${project.basedir}/javadoc-link/jsr305</location>
</offlineLink>
<offlineLink>
<url>https://static.javadoc.io/com.google.j2objc/j2objc-annotations/1.1/</url>
<location>${project.basedir}/javadoc-link/j2objc-annotations</location>
</offlineLink>
<!-- The JDK doc must be listed after JSR305 (and as an <offlineLink>, not a <link>) so that JSR305 "claims" javax.annotation. -->
<offlineLink>
<url>https://docs.oracle.com/javase/9/docs/api/</url>
<location>https://docs.oracle.com/javase/9/docs/api/</location>
</offlineLink>
<!-- The Checker Framework likewise would claim javax.annotations, despite providing only a subset of the JSR305 annotations, so it must likewise come after JSR305. -->
<offlineLink>
<url>https://checkerframework.org/api/</url>
<location>${project.basedir}/javadoc-link/checker-framework</location>
</offlineLink>
</offlineLinks>
<links>
<link>https://errorprone.info/api/latest/</link>
</links>
</configuration>
<executions>
<execution>
<id>attach-docs</id>
</execution>
<execution>
<id>generate-javadoc-site-report</id>
<phase>site</phase>
<goals><goal>javadoc</goal></goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>srczip-parent</id>
<activation>
<file>
<exists>${java.home}/../src.zip</exists>
</file>
</activation>
<dependencies>
<dependency>
<groupId>jdk</groupId>
<artifactId>srczip</artifactId>
<version>999</version>
<scope>system</scope>
<systemPath>${java.home}/../src.zip</systemPath>
<optional>true</optional>
</dependency>
</dependencies>
</profile>
<profile>
<id>srczip-lib</id>
<activation>
<file>
<exists>${java.home}/lib/src.zip</exists>
</file>
</activation>
<dependencies>
<dependency>
<groupId>jdk</groupId>
<artifactId>srczip</artifactId>
<version>999</version>
<scope>system</scope>
<systemPath>${java.home}/lib/src.zip</systemPath>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<!-- We need to point at the java.base subdirectory because Maven appears to assume that package foo.bar is located in foo/bar and not java.base/foo/bar when translating excludePackageNames into filenames to pass to javadoc. (Note that manually passing -exclude to javadoc appears to possibly not work at all for java.* types??) Also, referring only to java.base avoids a lot of other sources. -->
<sourcepath>${project.build.sourceDirectory}:${project.build.directory}/jdk-sources/java.base</sourcepath>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
3 changes: 3 additions & 0 deletions pkg/io/finder/maven/testdata/notAPom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pandas==1.1.1
# comment
numpy==1.2.3
541 changes: 541 additions & 0 deletions pkg/io/finder/maven/testdata/pom.xml

Large diffs are not rendered by default.

0 comments on commit 032bc49

Please sign in to comment.