Skip to content

Commit

Permalink
Support more 8.x Gradle versions
Browse files Browse the repository at this point in the history
  • Loading branch information
rnc committed Jan 25, 2024
1 parent 3c70944 commit cc903df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
strategy:
fail-fast: false
matrix:
gradle: [4.10.3, "5.0", 5.1.1, 5.2.1, 5.3.1, 5.4.1, 5.5.1, 5.6.4, 6.0.1, 6.1.1, 6.2.2, 6.3, 6.4.1, 6.5.1, 6.6.1, 6.7.1, 6.8.3, 6.9.3, 7.0.2, 7.1.1, 7.2, 7.3.3, 7.4.2, 7.5.1, 7.6, 8.0.2]
gradle: [4.10.3, "5.0", 5.1.1, 5.2.1, 5.3.1, 5.4.1, 5.5.1, 5.6.4, 6.0.1, 6.1.1, 6.2.2, 6.3, 6.4.1, 6.5.1, 6.6.1, 6.7.1, 6.8.3, 6.9.4, 7.0.2, 7.1.1, 7.2, 7.3.3, 7.4.2, 7.5.1, 7.6.3, 8.0.2, 8.1.1, 8.2.1, 8.3, 8.4, 8.5]
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idif
if: github.repository == 'project-ncl/gradle-manipulator' && github.event_name == 'pull_request'
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jboss.gm.analyzer.alignment;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.util.Collection;
Expand Down Expand Up @@ -76,17 +77,23 @@ public class AlignmentTaskEmptyVersionTest {
* task object.
*/
@Before
public void before() {
public void before()
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
final Class<? extends TaskInternal> taskType = Cast.uncheckedCast(DefaultTask.class);
final ProjectInternal projectInternal = mock(ProjectInternal.class);
when(projectInternal.getGradle()).thenReturn(mock(GradleInternal.class));
when(projectInternal.getServices()).thenReturn(mock(ServiceRegistry.class));
//noinspection UnstableApiUsage
when(projectInternal.getObjects()).thenReturn(mock(ObjectFactory.class));

//noinspection ConstantConditions
AbstractTask.injectIntoNewInstance(projectInternal,
TaskIdentity.create("DummyIdentity", taskType, projectInternal), null);
if (GradleVersion.current().compareTo(GradleVersion.version("8.0")) < 0) {
// In Gradle 8.2. this static method doesn't exist. However, we're only testing this under Gradle 8.0
Method method = TaskIdentity.class.getMethod("create", String.class, Class.class, ProjectInternal.class);
AbstractTask.injectIntoNewInstance(projectInternal,
(TaskIdentity) method.invoke(null, "DummyIdentity", taskType,
projectInternal),
null);
}
}

@Test
Expand Down

0 comments on commit cc903df

Please sign in to comment.