Example #1
0
func getEclipseClasspath() string {
	eclipseOutDir := path.Join(getProjectRoot(), "bin")
	if !common.DirExists(eclipseOutDir) {
		return ""
	}

	return eclipseOutDir
}
Example #2
0
func getInstallationSharePath() string {
	possibleInstallationPaths := []string{"/usr/local/share/twist2", "/usr/share/twist2"}
	for _, p := range possibleInstallationPaths {
		if common.DirExists(p) {
			return p
		}
	}

	panic(errors.New("Can't find installation files"))
}
Example #3
0
func createSrcDirectory() {
	showMessage("create", "src/")
	if !common.DirExists("src") {
		err := os.Mkdir("src", 0755)
		if err != nil {
			fmt.Printf("Failed to make directory. %s\n", err.Error())
		}
	} else {
		showMessage("skip", "src/")
	}
}
func setupJavaVersion(versionParts []string) {
	downloadLink := fmt.Sprintf("http://selenium-release.storage.googleapis.com/%s.%s/selenium-server-standalone-%s.%s.%s.jar",
		versionParts[0], versionParts[1], versionParts[0], versionParts[1], versionParts[2])
	if !common.DirExists("libs") {
		err := os.Mkdir("libs", common.NewDirectoryPermissions)
		if err != nil {
			fmt.Printf("Failed to create libs directory. %s\n", err.Error())
			os.Exit(1)
		}
	}
	absLibs, _ := filepath.Abs("libs")
	err := common.Download(downloadLink, absLibs)
	if err != nil {
		fmt.Printf("Failed to download %s. %s\n", downloadLink, err.Error())
		os.Exit(1)
	}

	// Copies Files WebdriverBrowserFactory.java && WebdriverHooks.java into project src
	pluginsPath, err := common.GetPluginsPath()
	if err != nil {
		fmt.Printf("Could not find plugins path")
		os.Exit(1)
	}
	javaPluginsPath := filepath.Join(pluginsPath, "selenium-webdriver", "0.0.0", "skel", "java")
	projectRoot, err := common.GetProjectRoot()
	if err != nil {
		fmt.Printf("failed to get Project Source")
		os.Exit(1)
	}
	projectSrc := filepath.Join(projectRoot, "src")
	err = common.CopyFile(filepath.Join(javaPluginsPath, WebdriverBrowserFactory), filepath.Join(projectSrc, WebdriverBrowserFactory))
	if err != nil {
		fmt.Printf("failed to Copy File %s ", WebdriverBrowserFactory)
		os.Exit(1)
	}
	err = common.CopyFile(filepath.Join(javaPluginsPath, WebdriverHooks), filepath.Join(projectSrc, WebdriverHooks))
	if err != nil {
		fmt.Printf("failed to Copy File %s ", WebdriverHooks)
		os.Exit(1)
	}
	projectEnv := filepath.Join(projectRoot, "env", "default")
	err = common.CopyFile(filepath.Join(javaPluginsPath, WebdriverPropertiesFile), filepath.Join(projectEnv, WebdriverPropertiesFile))
	if err != nil {
		fmt.Printf("failed to Copy File %s ", WebdriverPropertiesFile)
		os.Exit(1)
	}
}
Example #5
0
func getIntelliJClasspath() string {
	intellijOutDir := path.Join(getProjectRoot(), "out", "production")
	if !common.DirExists(intellijOutDir) {
		return ""
	}

	cp := ""
	walker := func(path string, info os.FileInfo, err error) error {
		if path == intellijOutDir {
			return nil
		}
		if info.IsDir() {
			appendClasspath(&cp, path)
			// we need only top-level directories. Don't walk nested
			return filepath.SkipDir
		}
		return nil
	}
	filepath.Walk(intellijOutDir, walker)
	return cp
}