constructor.go 884 B

123456789101112131415161718192021222324252627282930
  1. package apksigner
  2. import (
  3. "path/filepath"
  4. "notabug.org/Umnik/GoAndroidSDK/v2/components/misc"
  5. "notabug.org/Umnik/GoAndroidSDK/v2/components/sdk"
  6. )
  7. func apksignerFromPath(dirPath string, err error) (*Apksigner, error) {
  8. if err != nil {
  9. return nil, err
  10. }
  11. binPath := filepath.Join(dirPath, "apksigner")
  12. if err = misc.TestFile(binPath); err != nil {
  13. return nil, err
  14. }
  15. return &Apksigner{binPath: binPath}, nil
  16. }
  17. // NewApkSignerLastVersion creates Apksigner from last available version in sdk build-tools
  18. func NewApkSignerLastVersion(sdk sdk.SDK) (*Apksigner, error) {
  19. return apksignerFromPath(sdk.LastBuildToolsVersion())
  20. }
  21. // NewApksSignerSpecificVersion creates Apksigner from specified version in sdk build-tools
  22. func NewApksSignerSpecificVersion(sdk sdk.SDK, version string) (*Apksigner, error) {
  23. return apksignerFromPath(sdk.SpecificBuildToolsVersion(version))
  24. }