Skip to content

Commit

Permalink
fixed no special module with re-open project
Browse files Browse the repository at this point in the history
  • Loading branch information
zengkid committed Sep 28, 2020
1 parent 524fa2e commit bf8527a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
7 changes: 3 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
kotlin("jvm") version "1.3.72"
}

version = "3.8.0"
version = "3.8.1"

repositories {
mavenCentral()
Expand All @@ -19,7 +19,7 @@ dependencies {

// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
version = "2020.2.1"
version = "2020.2.2"
setPlugins("java")
pluginName = "SmartTomcat"
updateSinceUntilBuild = false
Expand All @@ -37,8 +37,7 @@ tasks.getByName<org.jetbrains.intellij.tasks.PatchPluginXmlTask>("patchPluginXml
sinceBuild("193")
changeNotes("""
<ul>
<li>1. save console log to a file</li>
<li>2. fixed bugs</li>
<li>fixed no special module with re-open project</li>
</ul>
""")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* Author : zengkid
Expand Down Expand Up @@ -68,22 +67,17 @@ protected JavaParameters createJavaParameters() {
try {

Path tomcatInstallationPath = Paths.get(configuration.getTomcatInfo().getPath());
Project project = this.configuration.getProject();
Module module = configuration.getModule();
String contextPath = configuration.getContextPath();
String tomcatVersion = configuration.getTomcatInfo().getVersion();
String vmOptions = configuration.getVmOptions();
Map<String, String> envOptions = configuration.getEnvOptions();

Project project = this.configuration.getProject();

JavaParameters javaParams = new JavaParameters();


ProjectRootManager manager = ProjectRootManager.getInstance(project);
javaParams.setJdk(manager.getProjectSdk());

javaParams.setDefaultCharset(project);

javaParams.setMainClass(TOMCAT_MAIN_CLASS);
javaParams.getProgramParametersList().add("start");
addBinFolder(tomcatInstallationPath, javaParams);
Expand All @@ -96,7 +90,7 @@ protected JavaParameters createJavaParameters() {
Path workPath = PluginUtils.getWorkPath(configuration);
Path confPath = workPath.resolve("conf");
if (!confPath.toFile().exists()) {
confPath.toFile().mkdirs();
confPath.toFile().mkdirs();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.xmlb.XmlSerializer;
import com.poratu.idea.plugins.tomcat.setting.TomcatInfo;
Expand All @@ -24,6 +25,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
Expand Down Expand Up @@ -122,6 +124,10 @@ public void writeExternal(Element element) throws WriteExternalException {
}

public Module getModule() {
if (module == null) {
VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(new File(options.getDocBase()));
module = ModuleUtil.findModuleForFile(virtualFile, this.getProject());
}
return module;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.poratu.idea.plugins.tomcat.utils;

import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.ProjectJdkTable;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.util.JdkBundle;
Expand Down Expand Up @@ -98,7 +100,9 @@ private static String getValue(String s) {
public static Path getWorkPath(TomcatRunConfiguration configuration) {

String userHome = System.getProperty("user.home");
Path workPath = Paths.get(userHome, ".SmartTomcat", configuration.getProject().getName(), configuration.getModule().getName());
Project project = configuration.getProject();
Module module = configuration.getModule();
Path workPath = Paths.get(userHome, ".SmartTomcat", project.getName(), module.getName());

return workPath;
}
Expand Down

0 comments on commit bf8527a

Please sign in to comment.