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)
	}
}
示例#2
0
func createJavaJSON() {
	destFile := path.Join("env", "default", "java.json")
	showMessage("create", destFile)
	if common.FileExists(destFile) {
		showMessage("skip", destFile)
	} else {
		srcFile := path.Join(getInstallationSharePath(), "skel", "env", "java.json")
		err := common.CopyFile(srcFile, destFile)
		if err != nil {
			showMessage("error", fmt.Sprintf("Failed to copy %s. %s", srcFile, err.Error()))
		}
	}
}
示例#3
0
func createStepImplementationClass() {
	destFile := path.Join("src", step_implementation_class)
	showMessage("create", destFile)
	if common.FileExists(destFile) {
		showMessage("skip", destFile)
	} else {
		srcFile := path.Join(getInstallationSharePath(), "skel", "java", step_implementation_class)
		err := common.CopyFile(srcFile, destFile)
		if err != nil {
			showMessage("error", fmt.Sprintf("Failed to copy %s. %s", srcFile, err.Error()))
		}
	}
}