Adobe Flex - mxmlc.exe and compile with dependent libraries - flex3

I have Flex SDK 4.6. I would like to work with library https://github.com/y8/websocket-as. This library needed library as3corelib (https://github.com/mikechambers/as3corelib). The problem is, that I'm not able to use/include this libraries in my HelloWorld project.
package {
import flash.display.Sprite;
import flash.text.TextField;
import y8.net.WebSocket;
public class HelloWorld extends Sprite {
public function HelloWorld() {
var display_txt:TextField = new TextField();
display_txt.text = "Hello World!";
addChild(display_txt);
}
}
}
When I compile it with mxmlc.exe -o HelloWorld.swf tuts\HelloWorld.as, I get error
HelloWorld.as(5): col: 15 Error: Definition y8.net:WebSocket could not be found.
import y8.net.WebSocket;
Please, how can I put it together (directories) and how can I compile this libraries and HelloWordl with mxmlc.exe. Thanks.

You can do it like this
mxmlc -library-path+=/myLibraries/MyRotateEffect.swc;/myLibraries/MyButtonSwc.swc c:/myFiles/app.mxml
ref: http://livedocs.adobe.com/flex/3/html/help.html?content=apparch_08.html

Related

Specific gradle options for target build platform

I have a Kotlin project (not Android) that uses the LWJGL library. Under macOS, I need to add the following options to build.gradle:
project.ext.lwjglNatives = "natives-macos"
applicationDefaultJvmArgs = ["-XstartOnFirstThread"]
dependencies {
implementation platform('org.jetbrains.kotlin:kotlin-bom')
implementation platform("org.lwjgl:lwjgl-bom:3.2.3")
implementation "org.lwjgl:lwjgl"
implementation "org.lwjgl:lwjgl-openal"
runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-openal::$lwjglNatives"
}
On Windows, however, I need to drop applicationDefaultJvmArgs, and set lwjglNatives to:
project.ext.lwjglNatives = "natives-windows"
How can I tell gradle to do this? Basically I need some kind of target platform check.
Moreover, I need to know the target platform in Kotlin was well. How can I tell the build platform from Kotlin code?
I figured it out. The operating system can be tested like this:
import org.apache.tools.ant.taskdefs.condition.Os
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
project.ext.lwjglNatives = "natives-windows"
} else {
project.ext.lwjglNatives = "natives-macos"
applicationDefaultJvmArgs = ["-XstartOnFirstThread"]
}
To access this from Kotlin, a BuildConfig.java needs to be generated ad hoc:
tasks.register('generateSources') {
ext.outputDir = "$buildDir/generated/java"
outputs.dir outputDir
doFirst {
mkdir "$outputDir/ch/digorydoo/ksoundrender"
file("$outputDir/ch/digorydoo/ksoundrender/BuildConfig.java").text =
"""|package ch.digorydoo.ksoundrender;
|public class BuildConfig {
| public static Boolean isWindows() {
| return ${if (Os.isFamily(Os.FAMILY_WINDOWS)) "true" else "false"};
|}
|}""".stripMargin()
}
}
compileKotlin.dependsOn generateSources
sourceSets.main.java.srcDir generateSources.outputDir
Now I can just import BuildConfig from Kotlin.

Cannot use Duration.seconds method from kotlin.time

I'm trying to use the Duration class from kotlin.time package like this:
Duration.seconds(5)
But I see Expression 'seconds' cannot be invoked as a function. The function 'invoke()' is not found in my intelliJ.
Not sure, how should I call this function then? Or is there something I'm missing?
For time being I have to use 5.toDuration(DurationUnit.SECONDS)
Snippet:
import kotlin.time.Duration
import kotlin.time.ExperimentalTime
#ExperimentalTime
class Temp {
fun test() {
println(Duration.seconds(5))
}
}
I have kotlin ref in build.gradle.kts file
plugins {
id("org.jetbrains.kotlin.jvm") version "1.5.21"
}
Using it with kotest.
Here are my project dependencies.
dependencies {
testImplementation(kotlin("test-junit5"))
testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
testImplementation("io.kotest:kotest-runner-junit5-jvm:$kotestVersion")
testImplementation("io.rest-assured:kotlin-extensions:4.3.0")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.+")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.12.+")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.+")
implementation("io.kotest.extensions:kotest-extensions-allure:1.0.1")
}
Make sure you are importing the correct Duration
import kotlin.time.Duration
as there are other Durations.
You can also use the extension function on Int,
import kotlin.time.toDuration
5.toDuration(DurationUnit.SECONDS)
For those looking to use Java Duration, you can do this using #Francesc answer and the information in the link below is (1.toDuration(DurationUnit.SECONDS)).toJavaDuration()
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.time/to-java-duration.html

Having trouble with Random ore generation for minecraft 1.15.2

So I am trying to make a minecraft mod that has a randomly generated ore. I have run into a problem in this part of the code.
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig;
import net.minecraft.world.gen.placement.ConfiguredPlacement;
import net.minecraft.world.gen.placement.CountRangeConfig;
import net.minecraft.world.gen.placement.Placement;
import net.minecraftforge.registries.ForgeRegistries;
public class ModOreGen {
public static void generateOre() {
for (Biome biome : ForgeRegistries.BIOMES) {
if (biome == Biomes.BAMBOO_JUNGLE) {
ConfiguredPlacement<CountRangeConfig> customConfig = Placement.COUNT_RANGE
.func_227446_a_(new CountRangeConfig(9, 10, 10, 0));
biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES,Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, blockinit.chocolate_ore.getDefaultState(), 10)).withPlacement(customConfig));
}
}
}
}
Where it says .withConfiguration it gives me the error:
The method withConfiguration(OreFeatureConfig) is undefined for the type Feature<OreFeatureConfig>
I have already tried updating my mappings and such, but nothing helped. This has been a problem that has really irritated me for days now. What is happening?
I just had this same problem with my code and finally fixed it. Try this out!
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig;
import net.minecraft.world.gen.placement.ConfiguredPlacement;
import net.minecraft.world.gen.placement.CountRangeConfig;
import net.minecraft.world.gen.placement.Placement;
import net.minecraftforge.registries.ForgeRegistries;
public class ModOreGen {
public static void generateOre() {
for (Biome biome : ForgeRegistries.BIOMES) {
if(biome == Biomes.BAMBOO_JUNGLE) {
ConfiguredPlacement<?> customConfig = Placement.COUNT_RANGE
.configure(new CountRangeConfig(9, 10, 10, 0));
biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE.withConfiguration(newOreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE,BlockInit.chocolate_ore.getDefaultState(), 10)).withPlacement(customConfig));
}
}
}
}
The obvious thing Sammerson did was to remove the strong typing for CountRangeConfig:
ConfiguredPlacement<?> , but that doesn't matter.
What you can't see is updating Forge to 1.15.2.
This is most likely your best fix. In your build.gradle, somewhere near the top (mine is line 28) you've probably already updated your mappings to:
mappings channel: 'snapshot', version: '20200409-1.15.1'
But you also want to go down and update the Forge version also (this is around line 90 for me).
dependencies {
minecraft 'net.minecraftforge:forge:1.15.2-31.1.0'
}
You need to do the same
gradlew genEclipseRuns
gradlew eclipse
just like updating the mappings.
(You can check the Forge page, there may be a newer version than 1.15.2 by the time someone else reads this. And I hope anyone using IntelliJ can figure out how to update your own mappings/forge.))

Cucumber JVM cannot find the steps defined

When I run to run this test with a feature it complains it cannot find the steps. I have tried defining them in Java 8 style, and Java 7 style and using IntelliJ to generate the steps into a MyStepdefs class but it cannot find them.
I am using version 1.2.4 of cucumber-java8 and cucumber-junit.
import cucumber.api.CucumberOptions;
import cucumber.api.DataTable;
import cucumber.api.PendingException;
import cucumber.api.java8.En;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
#RunWith(Cucumber.class)
#CucumberOptions(
monochrome = true,
glue = {"com.mycom.core.agg.RunCukesTest"})
public class RunCukesTest implements En {
public RunCukesTest() {
Given("^I have PriceLevels$", (DataTable arg1) -> {
});
And("^I have a TradeRequest$", (DataTable arg1) -> {
});
Then("^I should get these LegRequests$", (DataTable arg1) -> {
});
}
}
running the test prints
Running com.mycom.core.agg.RunCukesTest
1 Scenarios (1 undefined)
3 Steps (3 undefined)
0m0.000s
You can implement missing steps with the snippets below:
Given("^I have PriceLevels$", (DataTable arg1) -> {
.. rest deleted ...
Running the feature file from IntelliJ give much the same error.
While we couldn't figure out what the cause was, create a new maven project with a minimum of dependencies "fixed" the problem. We didn't need to change the code.

toolprovider.getsystemjavacompiler() returns null

First, I am seeing a lot of questions about the use of the JavaCompilerAPI, I want to clarify that I am creating an on-line simulation builder that takes too many inputs from the user to precreate classes. That is why I am using a java compiler in order to write the classes using the user's inputs.
As for my problem, I have tested with some basic compiler programs, and am presently working of code found here: Dynamic Compiling Without Create Physical File
The compilation of the code is successful, however when I run the code,
ToolProvider.getSystemJavaCompiler();
returns null.
From other entries I understand one cause might be that the default java.home is JRE, so I added the line where I set java home to my JDK version:
System.setProperty("java.home", "C:\\Program Files (x86)\\Java\\jdk1.7.0_51;");
I have also added tools.jar to the folder with my program, and called the program specifying tools.jar in the classpath like so:
java -cp ".;tools.jar" Compiler
These approaches have not changed anything. Any ideas about what might be the problem?
import java.io.IOException;
import java.net.URI;
import java.util.Arrays;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.tools.JavaCompiler.CompilationTask;
import javax.tools.*;
public class Compiler {
static final Logger logger = Logger.getLogger(Compiler.class.getName());
static String sourceCode = "class HelloWorld{"
+ "public static void main (String args[]){"
+ "System.out.println (\"Hello, dynamic compilation world!\");"
+ "}"
+ "}";
public void doCompilation() {
System.out.println(System.getProperty("java.home"));
System.setProperty("java.home", "C:\\Program Files (x86)\\Java\\jdk1.7.0_51;");
System.out.println(System.getProperty("java.home"));
SimpleJavaFileObject fileObject = new DynamicJavaSourceCodeObject("HelloWorld",sourceCode);
JavaFileObject javaFileObjects[] = new JavaFileObject[]{fileObject};
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
System.out.println(compiler);
StandardJavaFileManager stdFileManager = compiler.getStandardFileManager(null, Locale.getDefault(), null);
...