plugins/org.wso2.developerstudio.eclipse.docker.distribution/src/org/wso2/developerstudio/eclipse/docker/distribution/ui/wizard/ContainerProjectCreationWizard.java
/**
     * Create new docker file in the project directory if not exists.
     * 
     * @throws IOException An error occurred while writing the file
     */
Create new docker file in the project directory if not exists.

@throws IOException An error occurred while writing the file
Create new docker file in the project directory if not exists . @throws IOException An error occurred while writing the file
private void copyDockerFile() throws IOException {
        IFile dockerFile = project.getFile(DockerProjectConstants.DOCKER_FILE_NAME);
        File newFile = new File(dockerFile.getLocationURI().getPath());
        if (!newFile.exists()) {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("FROM ");
            String remoteRepository;
            String remoteTag;
            if (dockerModel.isDockerExporterProjectChecked()) {
                remoteRepository = dockerModel.getDockerRemoteRepository();
                remoteTag = dockerModel.getDockerRemoteTag();
            } else {
                remoteRepository = dockerModel.getKubeRemoteRepository();
                remoteTag = dockerModel.getKubeRemoteTag();
            }
            if (remoteRepository == null || remoteRepository.isEmpty()) {
                stringBuilder.append(DockerProjectConstants.DOCKER_DEFAULT_REPOSITORY + ":");
            } else {
                stringBuilder.append(remoteRepository + ":");
            }
            if (remoteTag == null || remoteTag.isEmpty()) {
                stringBuilder.append(DockerProjectConstants.DOCKER_DEFAULT_TAG);
            } else {
                stringBuilder.append(remoteTag);
            }
            stringBuilder.append(System.lineSeparator());
            stringBuilder.append("COPY " + DockerProjectConstants.CARBON_APP_FOLDER + "/*.car "
                    + DockerProjectConstants.CARBON_APP_FOLDER_LOCATION);
            stringBuilder.append(System.lineSeparator());
            stringBuilder.append("#COPY " + DockerProjectConstants.LIBS_FOLDER + "/*.jar "
                    + DockerProjectConstants.LIBS_FOLDER_LOCATION);
            stringBuilder.append(System.lineSeparator());
            stringBuilder.append(System.lineSeparator());
            if (dockerModel.isDockerExporterProjectChecked() && dockerModel.getDockerEnvParameters().size() > 0) {
                stringBuilder.append("ENV ");
                for (Map.Entry<String, String> envMap : dockerModel.getDockerEnvParameters().entrySet()) {
                    stringBuilder.append(envMap.getKey() + "=" + envMap.getValue() + " ");
                }
                stringBuilder.append(System.lineSeparator());
            }
            if (newFile.createNewFile()) {
                InputStream inputStream = new ByteArrayInputStream(
                        stringBuilder.toString().getBytes(Charset.forName("UTF-8")));
                OutputStream outputStream = new FileOutputStream(newFile);
                IOUtils.copy(inputStream, outputStream);
            }
        }
    }
private void copyDockerFile ( ) throws IOException { IFile dockerFile = project . getFile ( DockerProjectConstants . DOCKER_FILE_NAME ) ; File newFile = new File ( dockerFile . getLocationURI ( ) . getPath ( ) ) ; if ( ! newFile . exists ( ) ) { StringBuilder stringBuilder = new StringBuilder ( ) ; stringBuilder . append ( "FROM " ) ; String remoteRepository ; String remoteTag ; if ( dockerModel . isDockerExporterProjectChecked ( ) ) { remoteRepository = dockerModel . getDockerRemoteRepository ( ) ; remoteTag = dockerModel . getDockerRemoteTag ( ) ; } else { remoteRepository = dockerModel . getKubeRemoteRepository ( ) ; remoteTag = dockerModel . getKubeRemoteTag ( ) ; } if ( remoteRepository == null || remoteRepository . isEmpty ( ) ) { stringBuilder . append ( DockerProjectConstants . DOCKER_DEFAULT_REPOSITORY + ":" ) ; } else { stringBuilder . append ( remoteRepository + ":" ) ; } if ( remoteTag == null || remoteTag . isEmpty ( ) ) { stringBuilder . append ( DockerProjectConstants . DOCKER_DEFAULT_TAG ) ; } else { stringBuilder . append ( remoteTag ) ; } stringBuilder . append ( System . lineSeparator ( ) ) ; stringBuilder . append ( "COPY " + DockerProjectConstants . CARBON_APP_FOLDER + "/*.car " + DockerProjectConstants . CARBON_APP_FOLDER_LOCATION ) ; stringBuilder . append ( System . lineSeparator ( ) ) ; stringBuilder . append ( "#COPY " + DockerProjectConstants . LIBS_FOLDER + "/*.jar " + DockerProjectConstants . LIBS_FOLDER_LOCATION ) ; stringBuilder . append ( System . lineSeparator ( ) ) ; stringBuilder . append ( System . lineSeparator ( ) ) ; if ( dockerModel . isDockerExporterProjectChecked ( ) && dockerModel . getDockerEnvParameters ( ) . size ( ) > 0 ) { stringBuilder . append ( "ENV " ) ; for ( Map . Entry < String , String > envMap : dockerModel . getDockerEnvParameters ( ) . entrySet ( ) ) { stringBuilder . append ( envMap . getKey ( ) + "=" + envMap . getValue ( ) + " " ) ; } stringBuilder . append ( System . lineSeparator ( ) ) ; } if ( newFile . createNewFile ( ) ) { InputStream inputStream = new ByteArrayInputStream ( stringBuilder . toString ( ) . getBytes ( Charset . forName ( "UTF-8" ) ) ) ; OutputStream outputStream = new FileOutputStream ( newFile ) ; IOUtils . copy ( inputStream , outputStream ) ; } } }
Create new docker file in the project directory if not exists.
Create new docker file in the project directory if not exists .
// Creating the new docker file