Skip to content

Commit

Permalink
move classes of junit5-engine-api to separate package
Browse files Browse the repository at this point in the history
Since we use the `MANIFEST` entry `Automatic-Module-Name` the JUnit 5 modules are principally ready to be used on the modulepath. However, we automatically expose **all** packages declared, which means that the modules `junit5-api`, `junit5-engine` and `junit5-engine-api` all export the same package `com.tngtech.archunit.junit`, which is illegal for Java Modules. As a first step we move all classes contained in `junit5-engine-api` to a separate package to resolve part of the conflict. Unfortunately, this demands that we make some methods public that did not have to be before.

Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
  • Loading branch information
codecholeric committed Mar 5, 2022
1 parent 9913e3c commit 06d310e
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.junit.platform.launcher.core.LauncherFactory;

import static com.google.common.collect.Iterables.getOnlyElement;
import static com.tngtech.archunit.junit.FieldSelector.selectField;
import static com.tngtech.archunit.junit.engine_api.FieldSelector.selectField;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder.request;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.tngtech.archunit.junit;
package com.tngtech.archunit.junit.engine_api;

import java.lang.reflect.Field;
import java.util.Objects;

import com.tngtech.archunit.Internal;
import com.tngtech.archunit.PublicAPI;
import com.tngtech.archunit.base.ClassLoaders;
import com.tngtech.archunit.base.MayResolveTypesViaReflection;
Expand All @@ -35,11 +36,13 @@ private FieldSelector(Class<?> clazz, Field field) {
this.field = field;
}

Class<?> getJavaClass() {
@Internal
public Class<?> getJavaClass() {
return clazz;
}

Field getJavaField() {
@Internal
public Field getJavaField() {
return field;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.tngtech.archunit.junit;
package com.tngtech.archunit.junit.engine_api;

import java.lang.reflect.Field;
import java.util.Objects;

import com.tngtech.archunit.Internal;
import com.tngtech.archunit.PublicAPI;
import org.junit.platform.engine.TestSource;

Expand Down Expand Up @@ -61,17 +62,18 @@ public boolean equals(Object obj) {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final FieldSource other = (FieldSource) obj;
final FieldSource other = (FieldSource) obj;
return Objects.equals(this.javaClass, other.javaClass)
&& Objects.equals(this.fieldName, other.fieldName);
}
}

@Override
public String toString() {
@Override
public String toString() {
return getClass().getSimpleName() + "{" + getClassName() + '.' + fieldName + '}';
}
}

static FieldSource from(Field field) {
@Internal
public static FieldSource from(Field field) {
return new FieldSource(field);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tngtech.archunit.junit;
package com.tngtech.archunit.junit.engine_api;

import com.tngtech.archunit.junit.ArchTest;
import com.tngtech.archunit.lang.ArchRule;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.tngtech.archunit.core.domain.JavaClasses;
import com.tngtech.archunit.core.importer.ImportOption;
import com.tngtech.archunit.junit.engine_api.FieldSource;
import com.tngtech.archunit.lang.ArchRule;
import org.junit.platform.engine.TestDescriptor;
import org.junit.platform.engine.UniqueId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.tngtech.archunit.base.MayResolveTypesViaReflection;
import com.tngtech.archunit.core.domain.JavaClass;
import com.tngtech.archunit.core.importer.ClassFileImporter;
import com.tngtech.archunit.junit.engine_api.FieldSelector;
import org.junit.platform.engine.EngineDiscoveryRequest;
import org.junit.platform.engine.ExecutionRequest;
import org.junit.platform.engine.Filter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import com.tngtech.archunit.ArchConfiguration;
import com.tngtech.archunit.core.domain.JavaClasses;
import com.tngtech.archunit.junit.ArchUnitTestEngine.SharedCache;
import com.tngtech.archunit.junit.engine_api.FieldSelector;
import com.tngtech.archunit.junit.engine_api.FieldSource;
import com.tngtech.archunit.junit.testexamples.ClassWithPrivateTests;
import com.tngtech.archunit.junit.testexamples.ComplexMetaTags;
import com.tngtech.archunit.junit.testexamples.ComplexRuleLibrary;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Optional;

import com.tngtech.archunit.core.domain.JavaClasses;
import com.tngtech.archunit.junit.engine_api.FieldSelector;
import org.junit.platform.engine.ConfigurationParameters;
import org.junit.platform.engine.DiscoveryFilter;
import org.junit.platform.engine.DiscoverySelector;
Expand All @@ -23,7 +24,7 @@
import org.junit.platform.engine.discovery.PackageSelector;
import org.junit.platform.engine.discovery.UniqueIdSelector;

import static com.tngtech.archunit.junit.FieldSelector.selectField;
import static com.tngtech.archunit.junit.engine_api.FieldSelector.selectField;
import static java.util.Collections.emptyList;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;
Expand Down

0 comments on commit 06d310e

Please sign in to comment.