mal-lang / coreLang

A probabilistic attack simulation language for the (abstract) IT domain
https://mal-lang.org/coreLang/
Other
10 stars 12 forks source link

fix #30: add Dummy.java #31

Closed jesajx closed 3 years ago

jesajx commented 3 years ago

This is a workaround for #30. By adding a java-file we force coreLang-0.1.0.jar to be generated.

The MAL reference compiler uses (only?) *.mal-files as input. This means that any project that uses coreLang along with the reference compiler actually uses coreLang-0.1.0-source.jar, not coreLang-0.1.0.jar. The problem is that maven expects to find a coreLang-0.1.0.jar when downloading coreLang in order to work properly.

Another workaround could perhaps be to copy the *.mal-files into coreLang-0.1.0.jar as part of the buildprocess, but the above solves the problem for now.

You can't build e.g. icsLang with the reference compiler unless you already have coreLang-0.1.0.jar installed. Steps to reproduce:

  1. export JAVA_HOME=/usr/lib/jvm/java-11-openjdk # setup on archlinux. other OS do this differently.
  2. rm -rf ~/.m2/repository/org/mal-lang/corelang/0.1.0
  3. cd coreLang
  4. mvn install # only installs coreLang-0.1.0-source.jar not coreLang-0.1.0.jar
  5. cd icsLang
  6. mvn test # fails
  7. cp ~/.m2/repository/org/mal-lang/corelang/0.1.0/corelang-0.1.0{-source,}.jar
  8. mvn test # succeeds
jesajx commented 3 years ago

I don't think that travis-ci build error is my fault (HTTP 504 when downloading maven-mal-plugin).

andrewbwm commented 3 years ago

If the goal is to simply generate a .jar regardless of what it contains we can just remove the <skipIfEmpty>true</skipIfEmpty> line from pom.xml and that will generate a jar that has no actual content.

jesajx commented 3 years ago

That does sound like a cleaner solution!

I'm fine with any solution as long as we get automatic imports of coreLang into other projects to start working...

skatsikeas commented 3 years ago

@maxwalls What do you think about this?

maxwalls commented 3 years ago

I think that a better solution is to make sure that icsLang doesn't need coreLang-0.1.0.jar. I could achieve this by changing

    <dependency>
      <groupId>org.mal-lang</groupId>
      <artifactId>corelang</artifactId>
      <version>0.1.0</version>
    </dependency>

into

    <dependency>
      <groupId>org.mal-lang</groupId>
      <artifactId>corelang</artifactId>
      <version>0.1.0</version>
      <classifier>source</classifier>
    </dependency>

in pom.xml in icsLang.

skatsikeas commented 3 years ago

That seems very reasonable @maxwalls !

jesajx commented 3 years ago

I tried that but it does not seem to work:

rm -rf ~/.m2/repository/org/mal-lang/corelang
mvn clean test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< org.mal-lang:icslang >------------------------
[INFO] Building icsLang 0.0.1
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from maven.foreseeti.com-release: s3://maven.foreseeti.com/release/org/mal-lang/corelang/0.1.0/corelang-0.1.0.pom
[INFO] File permissions: Private
[INFO] Logged in - maven.foreseeti.com
[INFO] Downloading: s3://maven.foreseeti.com/release/org/mal-lang/corelang/0.1.0/corelang-0.1.0.pom
[INFO] Logged off - maven.foreseeti.com
[INFO] Transfers: 1 Time: 99ms Amount: 0 bytes Throughput: 0.000 bytes/s
Downloading from central: https://repo.maven.apache.org/maven2/org/mal-lang/corelang/0.1.0/corelang-0.1.0.pom
[WARNING] The POM for org.mal-lang:corelang:jar:source:0.1.0 is missing, no dependency information available
Downloading from maven.foreseeti.com-release: s3://maven.foreseeti.com/release/org/mal-lang/corelang/0.1.0/corelang-0.1.0-source.jar
[INFO] File permissions: Private
[INFO] Logged in - maven.foreseeti.com
[INFO] Downloading: s3://maven.foreseeti.com/release/org/mal-lang/corelang/0.1.0/corelang-0.1.0-source.jar
[INFO] Logged off - maven.foreseeti.com
[INFO] Transfers: 1 Time: 63ms Amount: 0 bytes Throughput: 0.000 bytes/s
Downloading from central: https://repo.maven.apache.org/maven2/org/mal-lang/corelang/0.1.0/corelang-0.1.0-source.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  10.700 s
[INFO] Finished at: 2021-02-17T13:10:24+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project icslang: Could not resolve dependencies for project org.mal-lang:icslang:jar:0.0.1: Could not find artifact org.mal-lang:corelang:jar:source:0.1.0 in maven.foreseeti.com-release (s3://maven.foreseeti.com/release) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
maxwalls commented 3 years ago

You need to install corelang into your local maven repo before running mvn clean test in icsLang:

$ rm -rf ~/.m2/repository/org/mal-lang/{corelang,icslang}
$ cd coreLang/
$ mvn clean install
$ cd ../icsLang/
$ mvn clean test
jesajx commented 3 years ago

ok, that does work.

jesajx commented 3 years ago

It would be nice to not have to do that though, but I guess that is different issue.

maxwalls commented 3 years ago

That would require deploying corelang into a public repo somewhere, which is a different issue.