Skip to content

Commit

Permalink
Merge pull request #106 from tudortimi/fix-error-when-depending-on-pr…
Browse files Browse the repository at this point in the history
…oject-with-multiple-source-sets

Fix error when depending on project with multiple source sets
  • Loading branch information
tudortimi authored Feb 5, 2023
2 parents ee7289f + fb83167 commit add0f8c
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 2 deletions.
8 changes: 7 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ group = "com.verificationgentleman.gradle"

gradlePlugin {
plugins {
create("base") {
id = "com.verificationgentleman.gradle.hdvl.base"
displayName = "Base plugin for hardware design and verification languages"
description = "A plugin that adds support for compiling and running code in HDL simulators"
implementationClass = "com.verificationgentleman.gradle.hdvl.HDVLBasePlugin"
}
create("systemverilog") {
id = "com.verificationgentleman.gradle.hdvl.systemverilog"
displayName = "Plugin for SystemVerilog support in HDL simulators"
Expand Down Expand Up @@ -58,7 +64,7 @@ gradlePlugin {
}

dependencies {
testImplementation("org.spockframework:spock-core:2.0-groovy-3.0") {
testImplementation("org.spockframework:spock-core:2.2-groovy-3.0") {
exclude(group = "org.codehaus.groovy")
}
testImplementation("org.spockframework:spock-junit4:2.0-groovy-3.0")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Copyright 2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.verificationgentleman.gradle.hdvl

import org.gradle.testkit.runner.GradleRunner
import spock.lang.Specification
import spock.lang.TempDir
import spock.util.io.FileSystemFixture

import static org.gradle.testkit.runner.TaskOutcome.SUCCESS

class HDVLBasePluginSpec extends Specification {
@TempDir FileSystemFixture fsFixture
def buildFile

def setup() {
fsFixture.create {
file('build.gradle') << """
plugins {
id 'com.verificationgentleman.gradle.hdvl.base'
}
"""
}
buildFile = fsFixture.resolve('build.gradle')
}

def "can successfully import the plugin"() {
when:
def result = GradleRunner.create()
.withProjectDir(fsFixture.currentPath.toFile())
.withPluginClasspath()
.build()

then:
result.task(":help").outcome == SUCCESS
}

def "project with extra source set can be used as dependency"() {
given:
fsFixture.create {
dir('consumer') {
file('build.gradle') << """
plugins {
id 'com.verificationgentleman.gradle.hdvl.systemverilog'
}
dependencies {
compile ':producer'
}
"""
file('settings.gradle') << """
includeBuild '../producer'
"""
dir('src/main/sv') {
file('main.sv')
}
}
dir('producer') {
file('build.gradle') << """
plugins {
id 'com.verificationgentleman.gradle.hdvl.systemverilog'
}
sourceSets.create('other')
"""
dir('src/main/sv') {
file('main.sv')
}
dir('src/other/sv') {
file('other.sv')
}
}
}

when:
def result = GradleRunner.create()
.withProjectDir(fsFixture.resolve('consumer').toFile())
.withPluginClasspath()
.withArguments('genFullXrunArgsFile')
.build()
println result.output

then:
result.task(":genFullXrunArgsFile").outcome == SUCCESS
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private void configureCompileConfiguration(Project project) {
private void configureArgsFilesConfiguration(Project project, SourceSet sourceSet, String toolName) {
Configuration argsFiles = project.getConfigurations().create(sourceSet.getArgsFilesConfigurationName(toolName));
argsFiles.extendsFrom(project.getConfigurations().getByName("compile"));
argsFiles.setCanBeConsumed(true);
argsFiles.setCanBeConsumed(sourceSet.getName().equals("main"));
argsFiles.setCanBeResolved(true);
argsFiles.getAttributes().attribute(HDVLBasePlugin.TOOL_ATTRIBUTE, toolName);
}
Expand Down

0 comments on commit add0f8c

Please sign in to comment.