Skip to content

Commit

Permalink
Merge pull request #120 from ortus-boxlang/development
Browse files Browse the repository at this point in the history
v1.0.0-Beta17
  • Loading branch information
lmajano authored Oct 4, 2024
2 parents 62038a6 + a3caa86 commit c525d47
Show file tree
Hide file tree
Showing 41 changed files with 782 additions and 362 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,17 @@ jobs:
DEST_DIR: "boxlang/${{ env.VERSION }}"

# Publish to Maven Central + Github ONLY on Beta/Final Releases
# - name: Publish Package (Maven+Github)
# if: env.SNAPSHOT == 'false'
# run: |
# gradle publish --no-daemon --no-parallel
# gradle publishToSonatype closeAndReleaseSonatypeStagingRepository
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GPG_KEY: ${{ secrets.GPG_KEY }}
# GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
# MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
# MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
- name: Publish Package (Maven+Github)
if: env.SNAPSHOT == 'false'
run: |
gradle publish --no-daemon --no-parallel
gradle publishAllPublicationsToCentralPortal
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_KEY: ${{ secrets.GPG_KEY }}
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}

- name: Create Github Release
uses: taiki-e/create-gh-release-action@v1.8.0
Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,19 @@ dependencies {
// https://mvnrepository.com/artifact/org.apache.commons/commons-cli
implementation "commons-cli:commons-cli:1.9.0"
// https://mvnrepository.com/artifact/com.fasterxml.jackson.jr/jackson-jr-objects
implementation 'com.fasterxml.jackson.jr:jackson-jr-objects:2.17.2'
implementation 'com.fasterxml.jackson.jr:jackson-jr-objects:2.18.0'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.jr/jackson-jr-extension-javatime
implementation 'com.fasterxml.jackson.jr:jackson-jr-extension-javatime:2.17.2'
implementation 'com.fasterxml.jackson.jr:jackson-jr-extension-javatime:2.18.0'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.jr/jackson-jr-stree
implementation 'com.fasterxml.jackson.jr:jackson-jr-stree:2.17.2'
implementation 'com.fasterxml.jackson.jr:jackson-jr-stree:2.18.0'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.jr/jackson-jr-annotation-support
implementation 'com.fasterxml.jackson.jr:jackson-jr-annotation-support:2.17.2'
implementation 'com.fasterxml.jackson.jr:jackson-jr-annotation-support:2.18.0'
// https://mvnrepository.com/artifact/org.slf4j/slf4j-api
implementation 'org.slf4j:slf4j-api:2.0.16'
// https://mvnrepository.com/artifact/ch.qos.logback/logback-classic
implementation 'ch.qos.logback:logback-classic:1.5.8'
// https://mvnrepository.com/artifact/com.zaxxer/HikariCP
implementation 'com.zaxxer:HikariCP:5.1.0'
implementation 'com.zaxxer:HikariCP:6.0.0'
// https://mvnrepository.com/artifact/org.ow2.asm/asm-tree
implementation 'org.ow2.asm:asm-tree:9.7'
// https://mvnrepository.com/artifact/org.ow2.asm/asm-util
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Fri Sep 20 12:58:58 UTC 2024
#Fri Sep 27 20:09:04 UTC 2024
antlrVersion=4.13.1
jdkVersion=21
version=1.0.0-beta16
version=1.0.0-beta17
40 changes: 20 additions & 20 deletions src/main/java/ortus/boxlang/compiler/Boxpiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ public ParsingResult validateParse( ParsingResult result, String source ) {
public Class<IBoxRunnable> compileStatement( String source, BoxSourceType type ) {
ClassInfo classInfo = ClassInfo.forStatement( source, type, this );
var classPool = getClassPool( classInfo.classPoolName() );
classPool.putIfAbsent( classInfo.FQN(), classInfo );
classInfo = classPool.get( classInfo.FQN() );
classPool.putIfAbsent( classInfo.fqn().toString(), classInfo );
classInfo = classPool.get( classInfo.fqn().toString() );

return classInfo.getDiskClass();

Expand All @@ -212,8 +212,8 @@ public Class<IBoxRunnable> compileStatement( String source, BoxSourceType type )
public Class<IBoxRunnable> compileScript( String source, BoxSourceType type ) {
ClassInfo classInfo = ClassInfo.forScript( source, type, this );
var classPool = getClassPool( classInfo.classPoolName() );
classPool.putIfAbsent( classInfo.FQN(), classInfo );
classInfo = classPool.get( classInfo.FQN() );
classPool.putIfAbsent( classInfo.fqn().toString(), classInfo );
classInfo = classPool.get( classInfo.fqn().toString() );

return classInfo.getDiskClass();
}
Expand All @@ -229,19 +229,19 @@ public Class<IBoxRunnable> compileScript( String source, BoxSourceType type ) {
public Class<IBoxRunnable> compileTemplate( ResolvedFilePath resolvedFilePath ) {
ClassInfo classInfo = ClassInfo.forTemplate( resolvedFilePath, Parser.detectFile( resolvedFilePath.absolutePath().toFile() ), this );
var classPool = getClassPool( classInfo.classPoolName() );
classPool.putIfAbsent( classInfo.FQN(), classInfo );
classPool.putIfAbsent( classInfo.fqn().toString(), classInfo );
// If the new class is newer than the one on disk, recompile it
if ( classPool.get( classInfo.FQN() ).lastModified() < classInfo.lastModified() ) {
if ( classPool.get( classInfo.fqn().toString() ).lastModified() < classInfo.lastModified() ) {
try {
// Don't know if this does anything, but calling it for good measure
classPool.get( classInfo.FQN() ).getClassLoader().close();
classPool.get( classInfo.fqn().toString() ).getClassLoader().close();
} catch ( IOException e ) {
e.printStackTrace();
}
classPool.put( classInfo.FQN(), classInfo );
compileClassInfo( classInfo.classPoolName(), classInfo.FQN() );
classPool.put( classInfo.fqn().toString(), classInfo );
compileClassInfo( classInfo.classPoolName(), classInfo.fqn().toString() );
} else {
classInfo = classPool.get( classInfo.FQN() );
classInfo = classPool.get( classInfo.fqn().toString() );
}
return classInfo.getDiskClass();
}
Expand All @@ -257,8 +257,8 @@ public Class<IBoxRunnable> compileTemplate( ResolvedFilePath resolvedFilePath )
public Class<IBoxRunnable> compileClass( String source, BoxSourceType type ) {
ClassInfo classInfo = ClassInfo.forClass( source, type, this );
var classPool = getClassPool( classInfo.classPoolName() );
classPool.putIfAbsent( classInfo.FQN(), classInfo );
classInfo = classPool.get( classInfo.FQN() );
classPool.putIfAbsent( classInfo.fqn().toString(), classInfo );
classInfo = classPool.get( classInfo.fqn().toString() );

return classInfo.getDiskClass();
}
Expand All @@ -274,19 +274,19 @@ public Class<IBoxRunnable> compileClass( String source, BoxSourceType type ) {
public Class<IBoxRunnable> compileClass( ResolvedFilePath resolvedFilePath ) {
ClassInfo classInfo = ClassInfo.forClass( resolvedFilePath, Parser.detectFile( resolvedFilePath.absolutePath().toFile() ), this );
var classPool = getClassPool( classInfo.classPoolName() );
classPool.putIfAbsent( classInfo.FQN(), classInfo );
classPool.putIfAbsent( classInfo.fqn().toString(), classInfo );
// If the new class is newer than the one on disk, recompile it
if ( classPool.get( classInfo.FQN() ).lastModified() < classInfo.lastModified() ) {
if ( classPool.get( classInfo.fqn().toString() ).lastModified() < classInfo.lastModified() ) {
try {
// Don't know if this does anything, but calling it for good measure
classPool.get( classInfo.FQN() ).getClassLoader().close();
classPool.get( classInfo.fqn().toString() ).getClassLoader().close();
} catch ( IOException e ) {
e.printStackTrace();
}
classPool.put( classInfo.FQN(), classInfo );
compileClassInfo( classInfo.classPoolName(), classInfo.FQN() );
classPool.put( classInfo.fqn().toString(), classInfo );
compileClassInfo( classInfo.classPoolName(), classInfo.fqn().toString() );
} else {
classInfo = classPool.get( classInfo.FQN() );
classInfo = classPool.get( classInfo.fqn().toString() );
}
return classInfo.getDiskClass();
}
Expand All @@ -295,8 +295,8 @@ public Class<IBoxRunnable> compileClass( ResolvedFilePath resolvedFilePath ) {
public Class<IProxyRunnable> compileInterfaceProxy( IBoxContext context, InterfaceProxyDefinition definition ) {
ClassInfo classInfo = ClassInfo.forInterfaceProxy( definition.name(), definition, this );
var classPool = getClassPool( classInfo.classPoolName() );
classPool.putIfAbsent( classInfo.FQN(), classInfo );
classInfo = classPool.get( classInfo.FQN() );
classPool.putIfAbsent( classInfo.fqn().toString(), classInfo );
classInfo = classPool.get( classInfo.fqn().toString() );

return classInfo.getDiskClassProxy();

Expand Down
76 changes: 34 additions & 42 deletions src/main/java/ortus/boxlang/compiler/ClassInfo.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ortus.boxlang.compiler;

import java.io.File;
import java.net.URL;
import java.nio.file.Paths;

Expand All @@ -11,16 +10,16 @@
import ortus.boxlang.runtime.runnables.IBoxRunnable;
import ortus.boxlang.runtime.runnables.IProxyRunnable;
import ortus.boxlang.runtime.types.exceptions.BoxRuntimeException;
import ortus.boxlang.runtime.util.BoxFQN;
import ortus.boxlang.runtime.util.FQN;
import ortus.boxlang.runtime.util.ResolvedFilePath;

/**
* A Record that represents the information about a class to be compiled
*/
public record ClassInfo(
FQN packageName,
String className,
FQN boxPackageName,
FQN fqn,
BoxFQN boxFqn,
String baseclass,
String returnType,
BoxSourceType sourceType,
Expand All @@ -35,7 +34,7 @@ public record ClassInfo(
* Hash Code
*/
public int hashCode() {
return FQN().hashCode();
return fqn().toString().hashCode();
}

/**
Expand All @@ -46,16 +45,15 @@ public boolean equals( Object obj ) {
return false;
}
if ( obj instanceof ClassInfo ) {
return FQN().equals( ( ( ClassInfo ) obj ).FQN() );
return fqn().toString().equals( ( ( ClassInfo ) obj ).fqn().toString() );
}
return false;
}

public static ClassInfo forScript( String source, BoxSourceType sourceType, IBoxpiler boxpiler ) {
return new ClassInfo(
FQN.of( "boxgenerated.scripts" ),
"Script_" + IBoxpiler.MD5( sourceType.toString() + source ),
FQN.of( "" ),
FQN.of( "boxgenerated.scripts", "Script_" + IBoxpiler.MD5( sourceType.toString() + source ) ),
BoxFQN.of( "" ),
"BoxScript",
"Object",
sourceType,
Expand All @@ -70,9 +68,8 @@ public static ClassInfo forScript( String source, BoxSourceType sourceType, IBox

public static ClassInfo forStatement( String source, BoxSourceType sourceType, IBoxpiler boxpiler ) {
return new ClassInfo(
FQN.of( "boxgenerated.scripts" ),
"Statement_" + IBoxpiler.MD5( sourceType.toString() + source ),
FQN.of( "" ),
FQN.of( "boxgenerated.scripts", "Statement_" + IBoxpiler.MD5( sourceType.toString() + source ) ),
BoxFQN.of( "" ),
"BoxScript",
"Object",
sourceType,
Expand All @@ -86,13 +83,9 @@ public static ClassInfo forStatement( String source, BoxSourceType sourceType, I
}

public static ClassInfo forTemplate( ResolvedFilePath resolvedFilePath, BoxSourceType sourceType, IBoxpiler boxpiler ) {
File lcaseFile = new File( resolvedFilePath.absolutePath().toString().toLowerCase() );
String className = IBoxpiler.getClassName( lcaseFile );
FQN packageName = resolvedFilePath.getPackage( "boxgenerated.templates" );
return new ClassInfo(
packageName,
className,
packageName,
resolvedFilePath.getFQN( "boxgenerated.templates" ),
resolvedFilePath.getBoxFQN( "boxgenerated.templates" ),
"BoxTemplate",
"void",
sourceType,
Expand All @@ -106,11 +99,9 @@ public static ClassInfo forTemplate( ResolvedFilePath resolvedFilePath, BoxSourc
}

public static ClassInfo forClass( ResolvedFilePath resolvedFilePath, BoxSourceType sourceType, IBoxpiler boxpiler ) {
String className = IBoxpiler.getClassName( resolvedFilePath.absolutePath().toFile() );
return new ClassInfo(
resolvedFilePath.getPackage( "boxgenerated.boxclass" ),
className,
resolvedFilePath.getPackage(),
resolvedFilePath.getFQN( "boxgenerated.boxclass" ),
resolvedFilePath.getBoxFQN(),
null,
null,
sourceType,
Expand All @@ -125,9 +116,8 @@ public static ClassInfo forClass( ResolvedFilePath resolvedFilePath, BoxSourceTy

public static ClassInfo forClass( String source, BoxSourceType sourceType, IBoxpiler boxpiler ) {
return new ClassInfo(
FQN.of( "boxgenerated.boxclass" ),
"Class_" + IBoxpiler.MD5( source ),
FQN.of( "" ),
FQN.of( "boxgenerated.boxclass", "Class_" + IBoxpiler.MD5( source ) ),
BoxFQN.of( "" ),
null,
null,
sourceType,
Expand All @@ -142,9 +132,8 @@ public static ClassInfo forClass( String source, BoxSourceType sourceType, IBoxp

public static ClassInfo forInterfaceProxy( String name, InterfaceProxyDefinition interfaceProxyDefinition, IBoxpiler boxpiler ) {
return new ClassInfo(
FQN.of( "boxgenerated.dynamicProxy" ),
"InterfaceProxy_" + name,
FQN.of( "" ),
FQN.of( "boxgenerated.dynamicProxy", "InterfaceProxy_" + name ),
BoxFQN.of( "" ),
null,
null,
null,
Expand All @@ -157,21 +146,16 @@ public static ClassInfo forInterfaceProxy( String name, InterfaceProxyDefinition
);
}

public String FQN() {
return packageName.toString() + "." + className();
}

public String toString() {
if ( resolvedFilePath != null )
return "Class Info-- sourcePath: [" + resolvedFilePath.absolutePath().toString() + "], packageName: [" + packageName + "], className: [" + className
+ "]";
return "Class Info-- sourcePath: [" + resolvedFilePath.absolutePath().toString() + "], fqn: [" + fqn().toString() + "]";
else if ( sourceType != null )
return "Class Info-- type: [" + sourceType + "], packageName: [" + packageName + "], className: [" + className + "]";
return "Class Info-- type: [" + sourceType + "], fqn: [" + fqn().toString() + "]";
else if ( interfaceProxyDefinition != null )
return "Class Info-- interface proxy: [" + interfaceProxyDefinition.interfaces().toString() + "], packageName: [" + packageName
+ "], className: [" + className + "]";
return "Class Info-- interface proxy: [" + interfaceProxyDefinition.interfaces().toString() + "], fqn: [" + fqn().toString()
+ "]";
else
return "Class Info-- packageName: [" + packageName + "], className: [" + className + "]";
return "Class Info-- fqn: [" + fqn().toString() + "]";
}

public DiskClassLoader getClassLoader() {
Expand Down Expand Up @@ -201,9 +185,9 @@ public DiskClassLoader getClassLoader() {
@SuppressWarnings( "unchecked" )
public Class<IBoxRunnable> getDiskClass() {
try {
return ( Class<IBoxRunnable> ) getClassLoader().loadClass( FQN() );
return ( Class<IBoxRunnable> ) getClassLoader().loadClass( fqn().toString() );
} catch ( ClassNotFoundException e ) {
throw new BoxRuntimeException( "Error compiling source " + FQN(), e );
throw new BoxRuntimeException( "Error compiling source " + fqn().toString(), e );
}
}

Expand All @@ -215,12 +199,20 @@ public Class<IBoxRunnable> getDiskClass() {
@SuppressWarnings( "unchecked" )
public Class<IProxyRunnable> getDiskClassProxy() {
try {
return ( Class<IProxyRunnable> ) getClassLoader().loadClass( FQN() );
return ( Class<IProxyRunnable> ) getClassLoader().loadClass( fqn().toString() );
} catch ( ClassNotFoundException e ) {
throw new BoxRuntimeException( "Error compiling source " + FQN(), e );
throw new BoxRuntimeException( "Error compiling source " + fqn().toString(), e );
}
}

public String packageName() {
return fqn().getPackageString();
}

public String className() {
return fqn().getClassName();
}

public Boolean isClass() {
return packageName().toString().startsWith( "boxgenerated.boxclass" );
}
Expand Down
Loading

0 comments on commit c525d47

Please sign in to comment.