Search in sources :

Example 1 with MuleProject

use of com.mulesoft.tools.migration.engine.project.structure.mule.MuleProject in project mule-migration-assistant by mulesoft.

the class ApplicationPersister method persistMuleAppProperties.

private void persistMuleAppProperties() throws Exception {
    projectType = projectFactory.getProjectType(appModel.getProjectBasePath());
    if (projectType.equals(MULE_THREE_APPLICATION) || projectType.equals(MULE_THREE_MAVEN_APPLICATION)) {
        MuleThreeApplication project = new MuleThreeApplication(appModel.getProjectBasePath());
        Path source = project.appProperties();
        if (source.toFile().exists()) {
            Path resources = ((MuleProject) projectOutput).srcMainResources();
            resources.toFile().mkdirs();
            Files.copy(source, resources.resolve("mule-app.properties"));
        }
    }
}
Also used : Path(java.nio.file.Path) MuleProject(com.mulesoft.tools.migration.engine.project.structure.mule.MuleProject) MuleThreeApplication(com.mulesoft.tools.migration.engine.project.structure.mule.three.MuleThreeApplication)

Example 2 with MuleProject

use of com.mulesoft.tools.migration.engine.project.structure.mule.MuleProject in project mule-migration-assistant by mulesoft.

the class ApplicationPersister method persistGitIgnoreFile.

/**
 * persist a .gitIgnore File from gitignore-maven-template
 *
 * @throws FileNotFoundException in case of a FileNotFoundException
 * @throws IOException in case of a IOException
 */
private void persistGitIgnoreFile() throws FileNotFoundException, IOException {
    if (projectOutput instanceof MuleProject) {
        MuleProject muleProject = (MuleProject) projectOutput;
        Path baseFolder = muleProject.baseFolder;
        if (baseFolder.toFile().exists()) {
            InputStream gitignoreResourceStream = null;
            OutputStream outputStream = null;
            try {
                gitignoreResourceStream = getClass().getClassLoader().getResourceAsStream("gitignore-maven-template");
                File gitIgnore = new File(baseFolder.toFile(), ".gitignore");
                outputStream = new FileOutputStream(gitIgnore);
                IOUtils.copy(gitignoreResourceStream, outputStream);
            } finally {
                IOUtils.closeQuietly(gitignoreResourceStream);
                IOUtils.closeQuietly(outputStream);
            }
        }
    }
}
Also used : MuleProject(com.mulesoft.tools.migration.engine.project.structure.mule.MuleProject) Path(java.nio.file.Path) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) File(java.io.File)

Example 3 with MuleProject

use of com.mulesoft.tools.migration.engine.project.structure.mule.MuleProject in project mule-migration-assistant by mulesoft.

the class ApplicationPersister method createSourcesFolders.

private void createSourcesFolders() {
    File app;
    MuleProject project = (MuleProject) projectOutput;
    if (!exists(project.srcMainConfiguration())) {
        app = project.srcMainConfiguration().toFile();
        app.mkdirs();
    }
    if (!(project instanceof MuleFourDomain || project instanceof MuleFourPolicy)) {
        if (!exists(project.srcTestConfiguration())) {
            app = project.srcTestConfiguration().toFile();
            app.mkdirs();
        }
    }
}
Also used : MuleProject(com.mulesoft.tools.migration.engine.project.structure.mule.MuleProject) MuleFourDomain(com.mulesoft.tools.migration.engine.project.structure.mule.four.MuleFourDomain) File(java.io.File) MuleFourPolicy(com.mulesoft.tools.migration.engine.project.structure.mule.four.MuleFourPolicy)

Example 4 with MuleProject

use of com.mulesoft.tools.migration.engine.project.structure.mule.MuleProject in project mule-migration-assistant by mulesoft.

the class MigrationJob method generateSourceApplicationModel.

private ApplicationModel generateSourceApplicationModel(Path project) throws Exception {
    ProjectTypeFactory projectFactory = new ProjectTypeFactory();
    ProjectType type = projectFactory.getProjectType(project);
    MuleProject muleProject = getMuleProject(project, type);
    ApplicationModelBuilder builder = new ApplicationModelBuilder().withConfigurationFiles(getFiles(muleProject.srcMainConfiguration(), "xml")).withProjectType(type).withMuleVersion(muleVersion).withPom(muleProject.pom()).withProjectPomGAV(projectGAV).withProjectBasePath(muleProject.getBaseFolder()).withSupportedNamespaces(getTasksDeclaredNamespaces(migrationTasks));
    if (muleProject.srcTestConfiguration().toFile().exists()) {
        builder.withTestConfigurationFiles(getFiles(muleProject.srcTestConfiguration(), "xml"));
    }
    return builder.build();
}
Also used : MuleProject(com.mulesoft.tools.migration.engine.project.structure.mule.MuleProject) MuleProjectFactory.getMuleProject(com.mulesoft.tools.migration.engine.project.MuleProjectFactory.getMuleProject) ApplicationModelBuilder(com.mulesoft.tools.migration.project.model.ApplicationModel.ApplicationModelBuilder) ProjectType(com.mulesoft.tools.migration.project.ProjectType) ProjectTypeFactory(com.mulesoft.tools.migration.engine.project.ProjectTypeFactory)

Aggregations

MuleProject (com.mulesoft.tools.migration.engine.project.structure.mule.MuleProject)4 File (java.io.File)2 Path (java.nio.file.Path)2 MuleProjectFactory.getMuleProject (com.mulesoft.tools.migration.engine.project.MuleProjectFactory.getMuleProject)1 ProjectTypeFactory (com.mulesoft.tools.migration.engine.project.ProjectTypeFactory)1 MuleFourDomain (com.mulesoft.tools.migration.engine.project.structure.mule.four.MuleFourDomain)1 MuleFourPolicy (com.mulesoft.tools.migration.engine.project.structure.mule.four.MuleFourPolicy)1 MuleThreeApplication (com.mulesoft.tools.migration.engine.project.structure.mule.three.MuleThreeApplication)1 ProjectType (com.mulesoft.tools.migration.project.ProjectType)1 ApplicationModelBuilder (com.mulesoft.tools.migration.project.model.ApplicationModel.ApplicationModelBuilder)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1