Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'exportsTo' configuration option similar to 'opensTo' #67

Open
xenoterracide opened this issue Jun 25, 2024 · 2 comments
Open

Add 'exportsTo' configuration option similar to 'opensTo' #67

xenoterracide opened this issue Jun 25, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@xenoterracide
Copy link

java.lang.reflect.InaccessibleObjectException: Unable to make public void org.mockito.moduletest.ModuleHandlingTest.can_define_class_in_open_java_util_module() throws java.lang.Exception accessible: module mockito.module.test.test does not "exports org.mockito.moduletest" to module junit
plugins {
    id 'org.gradlex.java-module-testing' version '1.4'
}

configurations {
    testUtil //TODO move to separate project
    // Putting 'provided' dependencies on test compile and runtime classpath.
    testCompileOnly.extendsFrom(compileOnly)
    testRuntimeOnly.extendsFrom(compileOnly)
}

dependencies {
    // scratching head, api but also optional...
    api libraries.bytebuddy, libraries.bytebuddyagent

    compileOnly libraries.junit4, libraries.hamcrest, libraries.opentest4j
    implementation libraries.objenesis

    testImplementation libraries.assertj
    testImplementation libraries.junitJupiterApi
    testImplementation libraries.junitJupiterParams
}

javaModuleTesting.whitebox(testing.suites["test"]) {
    requires.add("org.junit.jupiter.api")
    requires.add("org.junit.jupiter.params")
    requires.add("org.assertj.core")
    requires.add("java.sql")
    requires.add("java.management")
    // opensTo.add("junit")
}
module org.mockito {
    requires java.instrument;
    requires jdk.attach; // GH #2952
    requires static org.opentest4j;
    requires static net.bytebuddy;
    requires static net.bytebuddy.agent;
    requires static junit;

    opens org.mockito;

    exports org.mockito;
    exports org.mockito.codegen;
    exports org.mockito.configuration;
    exports org.mockito.creation.instance;
    exports org.mockito.exceptions.base;
    exports org.mockito.exceptions.misusing;
    exports org.mockito.exceptions.verification;
    exports org.mockito.exceptions.verification.junit;
    exports org.mockito.exceptions.verification.opentest4j;
    exports org.mockito.hamcrest;
    exports org.mockito.invocation;
    exports org.mockito.junit;
    exports org.mockito.listeners;
    exports org.mockito.mock;
    exports org.mockito.plugins;
    exports org.mockito.quality;
    exports org.mockito.session;
    exports org.mockito.stubbing;
    exports org.mockito.verification;

    // TODO: remove internal exports
    exports org.mockito.internal;
    exports org.mockito.internal.configuration.plugins;
    exports org.mockito.internal.util.reflection;
    exports org.mockito.internal.creation.bytebuddy;
}

https://github.com/xenoterracide/mockito/pull/1/files

@jjohannes
Copy link
Member

If this is added, I think this should be inline with the opensTo option:

javaModuleTesting.whitebox(testing.suites["test"]) {
    exportsTo.add("junit") // exports all packages to the 'junit' module
}

Note: I think in the provided example opensTo should also work.

@jjohannes jjohannes changed the title exports api Add 'exportsTo' configuration option similar to 'opensTo' Aug 19, 2024
@jjohannes jjohannes added the enhancement New feature or request label Aug 19, 2024
@xenoterracide
Copy link
Author

xenoterracide commented Aug 19, 2024

Note: I think in the provided example opensTo should also work.

Not certain, migrating mockito came to a halt. Can't figure out how to do certain things outside of using this plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants