Skip to content

Commit

Permalink
Clean up logging
Browse files Browse the repository at this point in the history
Signed-off-by: tvallin <thibault.vallin@oracle.com>
  • Loading branch information
tvallin committed Jul 17, 2023
1 parent 631e134 commit 424fb17
Show file tree
Hide file tree
Showing 16 changed files with 15 additions and 39 deletions.
4 changes: 0 additions & 4 deletions pico/maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@
<groupId>io.github.classgraph</groupId>
<artifactId>classgraph</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.common</groupId>
<artifactId>helidon-common</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.List;
import java.util.Set;

import io.helidon.build.common.Strings;
import io.helidon.common.types.TypeName;
import io.helidon.pico.api.PicoServices;
import io.helidon.pico.api.ServiceInfoCriteria;
Expand Down Expand Up @@ -100,9 +99,8 @@ List<Path> getSourceRootPaths() {
@Override
LinkedHashSet<Path> getClasspathElements() {
MavenProject project = getProject();
String testOutputDirectory = project.getBuild().getTestOutputDirectory();
LinkedHashSet<Path> result = new LinkedHashSet<>(project.getTestArtifacts().size());
result.add(new File(testOutputDirectory).toPath());
result.add(new File(project.getBuild().getTestOutputDirectory()).toPath());
for (Object a : project.getTestArtifacts()) {
result.add(((Artifact) a).getFile().toPath());
}
Expand Down
1 change: 0 additions & 1 deletion pico/maven-plugin/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
requires io.helidon.pico.configdriven.runtime;
requires io.helidon.common;
requires io.helidon.config;
requires io.helidon.build.common;
requires transitive io.helidon.pico.tools;

exports io.helidon.pico.maven.plugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,10 @@ void relayModuleInfoToServicesToProcess(ServicesToProcess servicesToProcess) {
AtomicReference<File> srcPath = new AtomicReference<>();
ModuleInfoDescriptor thisModuleDescriptor = thisModuleDescriptor(typeSuffix, moduleInfoFile, srcPath).orElse(null);
if (thisModuleDescriptor != null) {
log("module name : setting proper value");
servicesToProcess.lastKnownModuleInfoDescriptor(thisModuleDescriptor);
} else {
String thisModuleName = Options.getOption(Options.TAG_MODULE_NAME).orElse(null);
if (thisModuleName == null) {
log("Clear module name");
servicesToProcess.clearModuleName();
} else {
servicesToProcess.moduleName(thisModuleName);
Expand Down Expand Up @@ -210,7 +208,6 @@ private Optional<ModuleInfoDescriptor> tryFindModuleInfoTheUnconventionalWayFrom
File file = new File(srcRoot, REAL_MODULE_INFO_JAVA_NAME);
if (file.exists()) {
try {
log("Path here exist : " + file.toPath());
return Optional.of(
ModuleInfoDescriptor.create(file.toPath(), ModuleInfoOrdering.NATURAL_PRESERVE_COMMENTS));
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ ModuleInfoDescriptor createModuleInfo(ModuleInfoCreatorRequest req) {
Collection<String> modulesRequired = req.modulesRequired();
Map<TypeName, Set<TypeName>> contracts = req.contracts();
Map<TypeName, Set<TypeName>> externalContracts = req.externalContracts();

ModuleInfoDescriptor.Builder descriptorBuilder;
if (moduleInfoPath != null) {
descriptorBuilder = ModuleInfoDescriptor
Expand All @@ -197,11 +198,6 @@ ModuleInfoDescriptor createModuleInfo(ModuleInfoCreatorRequest req) {
descriptorBuilder.headerComment("// " + generatedAnno);
}

if (applicationTypeName != null
&& applicationTypeName.toString().equals("io.helidon.pico.tests.pico.Pico$$TestApplication")) {
//throw new RuntimeException(descriptorBuilder.name() + " " + req);
}

boolean isTestModule = "test".equals(classPrefixName);
if (isTestModule) {
String baseModuleName = ModuleUtils.normalizedBaseModuleName(moduleName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,11 @@ public JavaFileObject createSourceFile(CharSequence name,

Path toSourcePath(JavaFileManager.Location location,
String name) {
return toSourcePath(location, TypeName.create(name), null);
return toSourcePath(location, TypeName.create(name));
}

Path toSourcePath(JavaFileManager.Location location,
TypeName typeName, Messager messager) {
TypeName typeName) {
String sourcePath;
if (StandardLocation.SOURCE_PATH == location) {
sourcePath = paths.sourcePath().orElse(null);
Expand All @@ -254,6 +254,7 @@ Path toSourcePath(JavaFileManager.Location location,
LOGGER.log(System.Logger.Level.DEBUG, "sourcepath is not defined in " + paths);
return null;
}

return new File(sourcePath, TypeTools.toFilePath(typeName)).toPath();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,6 @@ ActivatorCreatorResponse codegen(ActivatorCreatorRequest req,
TypeName applicationTypeName;
Map<String, List<String>> metaInfServices;
TypeName moduleTypeName = toModuleTypeName(req, activatorTypeNames);
if ("unnamed/test".equals(moduleTypeName.name())) {
throw new RuntimeException(Arrays.toString(Thread.currentThread().getStackTrace()));
}
if (moduleTypeName != null) {
String className = applicationClassName(req.codeGen().classPrefixName());
applicationTypeName = TypeName.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.io.File;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -270,7 +269,6 @@ ApplicationCreatorResponse codegen(ApplicationCreatorRequest req,

Map<String, Object> subst = new HashMap<>();
subst.put("classname", application.className());

subst.put("packagename", application.packageName());
subst.put("description", application + " - Generated Pico Application.");
subst.put("header", CopyrightHandler.copyright(CREATOR,
Expand Down Expand Up @@ -453,6 +451,7 @@ void codegenModuleInfoDescriptor(CodeGenFiler filer,
if (moduleName == null || ModuleInfoDescriptor.DEFAULT_MODULE_NAME.equals(moduleName)) {
moduleName = descriptor.name();
}

TypeName moduleTypeName = moduleServiceTypeOf(picoServices, moduleName).orElse(null);
if (moduleTypeName != null) {
String typePrefix = req.codeGen().classPrefixName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ Optional<Path> toSourceLocation(String name) {
if (filer instanceof AbstractFilerMessager.DirectFilerMessager) {
TypeName typeName = TypeName.create(name);
Optional<Path> path = Optional.ofNullable(((AbstractFilerMessager.DirectFilerMessager) filer)
.toSourcePath(StandardLocation.SOURCE_PATH, typeName, messager()));
.toSourcePath(StandardLocation.SOURCE_PATH, typeName));
if (path.isPresent()) {
return path;
}
Expand Down Expand Up @@ -499,6 +499,7 @@ private Optional<Path> codegenResourceFilerOut(String outPath,
// hack: physically relocate it elsewhere under our scratch output directory
filer = scratchFiler();
}

FileObject f = filer.getResource(StandardLocation.CLASS_OUTPUT, "", outPath);
Path fPath = Path.of(f.toUri());
if (fPath.toFile().exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ private void processServiceType(ClassInfo classInfo) {
if (moduleInfo != null) {
requiresModule = Collections.singleton(moduleInfo.getName());
services.moduleName(moduleInfo.getName());
logger().log(System.Logger.Level.INFO, "Setting name " + moduleInfo.getName());
}

processTypeAndContracts(classInfo, serviceTypeName, requiresModule);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.List;
import java.util.Map;

import io.helidon.build.common.Strings;
import io.helidon.builder.api.Prototype;
import io.helidon.common.types.TypeName;

Expand Down Expand Up @@ -271,7 +270,7 @@ private static String cleanModuleAnnotations(String moduleText) {
// ignored, we cannot get an exception when closing string reader
}

return Strings.normalizeNewLines(response.toString());
return response.toString();
}

private static String cleanLine(String line) {
Expand Down
13 changes: 5 additions & 8 deletions pico/tools/src/main/java/io/helidon/pico/tools/ModuleUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
Expand All @@ -38,8 +37,6 @@

import javax.lang.model.element.TypeElement;

import io.helidon.build.common.Strings;
import io.helidon.build.common.logging.Log;
import io.helidon.common.HelidonServiceLoader;
import io.helidon.common.processor.TypeFactory;
import io.helidon.common.types.TypeName;
Expand Down Expand Up @@ -351,15 +348,16 @@ public static Optional<Path> toSourcePath(Path filePath,
* @return the base path
*/
public static Path toBasePath(String sourcePath) {
String path = Strings.normalizePath(sourcePath);
int pos = path.lastIndexOf(SRC_MAIN_JAVA_DIR);
sourcePath = sourcePath.replace("\\", "/");
int pos = sourcePath.lastIndexOf(SRC_MAIN_JAVA_DIR);
if (pos < 0) {
pos = path.lastIndexOf(SRC_TEST_JAVA_DIR);
pos = sourcePath.lastIndexOf(SRC_TEST_JAVA_DIR);
}
if (pos < 0) {
throw new ToolsException("Invalid source path: " + sourcePath);
}
return Objects.requireNonNull(Path.of(sourcePath.substring(0, pos)));
Path path = Path.of(sourcePath.substring(0, pos));
return Objects.requireNonNull(path);
}

/**
Expand Down Expand Up @@ -407,7 +405,6 @@ public static Optional<String> loadAppPackageName(Path scratchPath) {
*/
public static void saveAppPackageName(Path scratchPath,
String packageName) {

File scratchDir = scratchPath.toFile();
File packageFileName = new File(scratchDir, APPLICATION_PACKAGE_FILE_NAME);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static String toFilePath(TypeName typeName,
fileType = "." + fileType;
}

return packageName + File.separator + className + fileType;
return packageName + File.separatorChar + className + fileType;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.io.File;
import java.util.List;

import io.helidon.build.common.Strings;
import io.helidon.pico.api.Contract;
import io.helidon.pico.api.ExternalContracts;

Expand Down

0 comments on commit 424fb17

Please sign in to comment.