jjtParadox / Barometer

An old experimental test library for 1.12 MinecraftForge mods.
GNU Lesser General Public License v3.0
7 stars 3 forks source link

Switch gradle plugin dependencies to provided to fix test runtime errors #12

Closed tdaffin closed 6 years ago

tdaffin commented 6 years ago

Fixes this issue: https://github.com/jjtParadox/Barometer/issues/11

jjtParadox commented 6 years ago

If you publish this version of Barometer to your local maven repo, what does the .pom file contain? I don't think the provided option is a normal option of Gradle and it might screw up Maven dependency resolution if others include Barometer from my maven repo.

jjtParadox commented 6 years ago

Actually... does using compileOnly fix it? That one might be compatible with Maven.

tdaffin commented 6 years ago

Publishing with ./gradlew publishToMavenLocal gives:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.jjtparadox.barometer</groupId>
  <artifactId>Barometer</artifactId>
  <version>0.0.5</version>
  <dependencies>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-stdlib</artifactId>
      <version>1.1.2-5</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-reflect</artifactId>
      <version>1.1.2-5</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>io.github.lukehutch</groupId>
      <artifactId>fast-classpath-scanner</artifactId>
      <version>2.18.1</version>
      <scope>runtime</scope>
    </dependency>
  </dependencies>
</project>

I can then use this version from the repository in my test mod and run the tests ok -- that is using the old (non-plugin) method -- I haven't tried the plugin route yet.

FYI: I also use provided in my test mod to include 'project lombok', as does IntegratedDynamics, via: provided "org.projectlombok:lombok:1.16.8"

tdaffin commented 6 years ago

Looking here though, it looks like I should be using compileOnly:

https://blog.gradle.org/introducing-compile-only-dependencies

I'll test again with that change and update the PR if it works.

tdaffin commented 6 years ago

Yup, compileOnly worked fine... not sure why provided works as well!

jjtParadox commented 6 years ago

Thanks for your investigation! provided likely works very similarly to compileOnly except that it might be available at runtime and should be included when the project is run from the dev environment.

In this case, Barometer needs ForgeGradle to compile and run, but because ForgeGradle is always already included in projects it just causes issues to include it multiple times. There's probably some better way of managing this problem (e.g. splitting base Barometer and the Gradle plugin into separate jars) but this works for now :smile: