Skip to content

Commit

Permalink
Merge pull request #42002 from NipunaMadhushan/remove-observability-s…
Browse files Browse the repository at this point in the history
…ymbols-jar

Remove generating observability-symbols.jar
  • Loading branch information
NipunaMadhushan authored Feb 29, 2024
2 parents a949e6d + 16c1967 commit 187079a
Show file tree
Hide file tree
Showing 17 changed files with 0 additions and 616 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
import org.wso2.ballerinalang.compiler.CompiledJarFile;
import org.wso2.ballerinalang.compiler.bir.codegen.CodeGenerator;
import org.wso2.ballerinalang.compiler.bir.codegen.interop.InteropValidator;
import org.wso2.ballerinalang.compiler.semantics.analyzer.ObservabilitySymbolCollectorRunner;
import org.wso2.ballerinalang.compiler.spi.ObservabilitySymbolCollector;
import org.wso2.ballerinalang.compiler.tree.BLangPackage;
import org.wso2.ballerinalang.compiler.util.CompilerContext;
import org.wso2.ballerinalang.util.Lists;
Expand Down Expand Up @@ -133,12 +131,6 @@ private JBallerinaBackend(PackageCompilation packageCompilation, JvmTarget jdkVe
this.compilerContext = projectEnvContext.getService(CompilerContext.class);
this.interopValidator = InteropValidator.getInstance(compilerContext);
this.jvmCodeGenerator = CodeGenerator.getInstance(compilerContext);
// TODO: Move to a compiler extension once Compiler revamp is complete
if (packageContext.compilationOptions().observabilityIncluded()) {
ObservabilitySymbolCollector observabilitySymbolCollector
= ObservabilitySymbolCollectorRunner.getInstance(compilerContext);
observabilitySymbolCollector.process(packageContext.project());
}
this.conflictedJars = new ArrayList<>();
performCodeGen();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,21 @@
import io.ballerina.tools.diagnostics.DiagnosticInfo;
import io.ballerina.tools.diagnostics.DiagnosticSeverity;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.wso2.ballerinalang.compiler.semantics.analyzer.ObservabilitySymbolCollectorRunner;
import org.wso2.ballerinalang.compiler.spi.ObservabilitySymbolCollector;
import org.wso2.ballerinalang.compiler.util.CompilerContext;
import org.wso2.ballerinalang.compiler.util.CompilerUtils;

import java.io.IOException;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;

import static io.ballerina.identifier.Utils.encodeNonFunctionIdentifier;
import static io.ballerina.projects.util.ProjectConstants.ANON_ORG;
import static io.ballerina.projects.util.ProjectConstants.CACHES_DIR_NAME;
import static io.ballerina.projects.util.ProjectConstants.DOT;

// TODO move this class to a separate Java package. e.g. io.ballerina.projects.platform.jballerina
Expand All @@ -66,7 +56,6 @@ public class JarResolver {
private final JBallerinaBackend jBalBackend;
private final PackageResolution pkgResolution;
private final PackageContext rootPackageContext;
private final PrintStream err = System.err;
private final List<Diagnostic> diagnosticList;
private DiagnosticResult diagnosticResult;

Expand Down Expand Up @@ -112,42 +101,6 @@ public Collection<JarLibrary> getJarFilePathsRequiredForExecution() {
PlatformLibraryScope.DEFAULT,
getPackageName(rootPackageContext)));

// TODO: Move to a compiler extension once Compiler revamp is complete
// 4) Add the Observability Symbols Jar
if (rootPackageContext.compilationOptions().observabilityIncluded()) {
try {
// Generating an empty Jar which can be used by the Observability Symbol Collector
String packageName = rootPackageContext.packageOrg().value() + "-"
+ rootPackageContext.packageName().value();
Path observabilityJarPath = ProjectUtils.generateObservabilitySymbolsJar(packageName);

// Writing the Syntax Tree to the Jar
CompilerContext compilerContext = rootPackageContext.project().projectEnvironmentContext()
.getService(CompilerContext.class);
ObservabilitySymbolCollector observabilitySymbolCollector
= ObservabilitySymbolCollectorRunner.getInstance(compilerContext);
observabilitySymbolCollector.writeToExecutable(observabilityJarPath, rootPackageContext.project());
// Cache observability jar in target
Path observeJarCachePath = rootPackageContext.project().targetDir()
.resolve(CACHES_DIR_NAME)
.resolve(rootPackageContext.packageOrg().value())
.resolve(rootPackageContext.packageName().value())
.resolve(rootPackageContext.packageVersion().value().toString())
.resolve("observe")
.resolve(rootPackageContext.packageOrg().value() + "-"
+ rootPackageContext.packageName().value()
+ "-observability-symbols.jar");
Path observeCachePath = Optional.of(observeJarCachePath.getParent()).orElseThrow();
Files.createDirectories(observeCachePath);
Files.copy(observabilityJarPath, observeJarCachePath, StandardCopyOption.REPLACE_EXISTING);

jarFiles.add(new JarLibrary(observabilityJarPath, PlatformLibraryScope.DEFAULT,
getPackageName(rootPackageContext)));
} catch (IOException e) {
err.println("\twarning: Failed to add Observability information to Jar due to: " + e.getMessage());
}
}

// TODO Filter out duplicate jar entries
return jarFiles;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@
import org.wso2.ballerinalang.compiler.semantics.analyzer.DataflowAnalyzer;
import org.wso2.ballerinalang.compiler.semantics.analyzer.DocumentationAnalyzer;
import org.wso2.ballerinalang.compiler.semantics.analyzer.IsolationAnalyzer;
import org.wso2.ballerinalang.compiler.semantics.analyzer.ObservabilitySymbolCollectorRunner;
import org.wso2.ballerinalang.compiler.semantics.analyzer.SemanticAnalyzer;
import org.wso2.ballerinalang.compiler.semantics.analyzer.SymbolEnter;
import org.wso2.ballerinalang.compiler.semantics.analyzer.SymbolResolver;
import org.wso2.ballerinalang.compiler.semantics.model.SymbolTable;
import org.wso2.ballerinalang.compiler.spi.ObservabilitySymbolCollector;
import org.wso2.ballerinalang.compiler.tree.BLangPackage;
import org.wso2.ballerinalang.compiler.util.CompilerContext;
import org.wso2.ballerinalang.compiler.util.CompilerOptions;
Expand Down Expand Up @@ -64,7 +62,6 @@ public class CompilerPhaseRunner {
private final ConstantPropagation constantPropagation;
private final DocumentationAnalyzer documentationAnalyzer;
private final CompilerPluginRunner compilerPluginRunner;
private final ObservabilitySymbolCollector observabilitySymbolCollector;
private final Desugar desugar;
private final BIRGen birGenerator;
private final BIREmitter birEmitter;
Expand Down Expand Up @@ -95,7 +92,6 @@ private CompilerPhaseRunner(CompilerContext context) {
this.documentationAnalyzer = DocumentationAnalyzer.getInstance(context);
this.constantPropagation = ConstantPropagation.getInstance(context);
this.compilerPluginRunner = CompilerPluginRunner.getInstance(context);
this.observabilitySymbolCollector = ObservabilitySymbolCollectorRunner.getInstance(context);
this.desugar = Desugar.getInstance(context);
this.birGenerator = BIRGen.getInstance(context);
this.birEmitter = BIREmitter.getInstance(context);
Expand Down
1 change: 0 additions & 1 deletion compiler/ballerina-lang/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
exports org.wso2.ballerinalang.compiler.parser;
exports org.ballerinalang.model.symbols;
exports org.ballerinalang.repository.fs;
exports org.wso2.ballerinalang.compiler.spi;
exports org.ballerinalang.util;
exports org.wso2.ballerinalang.compiler.tree.clauses;
exports org.ballerinalang.model.clauses;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion distribution/zip/jballerina-tools/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ dependencies {
dist project(':syntax-api-calls-gen')
dist project(':language-server:language-server-commons')
dist project(':docerina')
dist project(':observability-symbol-collector')
dist project(':testerina:testerina-runtime')
dist project(':toml-parser')
docerina project(':docerina-gradle-plugin')
Expand Down
43 changes: 0 additions & 43 deletions misc/observability-symbol-collector/build.gradle

This file was deleted.

5 changes: 0 additions & 5 deletions misc/observability-symbol-collector/spotbugs-exclude.xml

This file was deleted.

12 changes: 0 additions & 12 deletions misc/observability-symbol-collector/src/main/java/module-info.java

This file was deleted.

Loading

0 comments on commit 187079a

Please sign in to comment.