github.com/anchore/syft@v1.38.2/cmd/syft/internal/options/java.go (about)

     1  package options
     2  
     3  import (
     4  	"github.com/anchore/clio"
     5  	"github.com/anchore/syft/syft/pkg/cataloger/java"
     6  )
     7  
     8  type javaConfig struct {
     9  	UseNetwork                    *bool  `yaml:"use-network" json:"use-network" mapstructure:"use-network"`
    10  	UseMavenLocalRepository       *bool  `yaml:"use-maven-local-repository" json:"use-maven-local-repository" mapstructure:"use-maven-local-repository"`
    11  	MavenLocalRepositoryDir       string `yaml:"maven-local-repository-dir" json:"maven-local-repository-dir" mapstructure:"maven-local-repository-dir"`
    12  	MavenURL                      string `yaml:"maven-url" json:"maven-url" mapstructure:"maven-url"`
    13  	MaxParentRecursiveDepth       int    `yaml:"max-parent-recursive-depth" json:"max-parent-recursive-depth" mapstructure:"max-parent-recursive-depth"`
    14  	ResolveTransitiveDependencies bool   `yaml:"resolve-transitive-dependencies" json:"resolve-transitive-dependencies" mapstructure:"resolve-transitive-dependencies"`
    15  }
    16  
    17  func defaultJavaConfig() javaConfig {
    18  	def := java.DefaultArchiveCatalogerConfig()
    19  
    20  	return javaConfig{
    21  		UseNetwork:                    nil, // this defaults to false, which is the API default
    22  		MaxParentRecursiveDepth:       def.MaxParentRecursiveDepth,
    23  		UseMavenLocalRepository:       nil, // this defaults to false, which is the API default
    24  		MavenLocalRepositoryDir:       def.MavenLocalRepositoryDir,
    25  		MavenURL:                      def.MavenBaseURL,
    26  		ResolveTransitiveDependencies: def.ResolveTransitiveDependencies,
    27  	}
    28  }
    29  
    30  var _ interface {
    31  	clio.FieldDescriber
    32  } = (*javaConfig)(nil)
    33  
    34  func (o *javaConfig) DescribeFields(descriptions clio.FieldDescriptionSet) {
    35  	descriptions.Add(&o.UseNetwork, `enables Syft to use the network to fetch version and license information for packages when
    36  a parent or imported pom file is not found in the local maven repository.
    37  the pom files are downloaded from the remote Maven repository at 'maven-url'`)
    38  	descriptions.Add(&o.MavenURL, `maven repository to use, defaults to Maven central`)
    39  	descriptions.Add(&o.MaxParentRecursiveDepth, `depth to recursively resolve parent POMs, no limit if <= 0`)
    40  	descriptions.Add(&o.UseMavenLocalRepository, `use the local Maven repository to retrieve pom files. When Maven is installed and was previously used
    41  for building the software that is being scanned, then most pom files will be available in this
    42  repository on the local file system. this greatly speeds up scans. when all pom files are available
    43  in the local repository, then 'use-network' is not needed.
    44  TIP: If you want to download all required pom files to the local repository without running a full
    45  build, run 'mvn help:effective-pom' before performing the scan with syft.`)
    46  	descriptions.Add(&o.MavenLocalRepositoryDir, `override the default location of the local Maven repository. 
    47  the default is the subdirectory '.m2/repository' in your home directory`)
    48  	descriptions.Add(&o.ResolveTransitiveDependencies, `resolve transient dependencies such as those defined in a dependency's POM on Maven central`)
    49  }