Isn't this a transitivity issue? You don't have slf4j-api in your dependency list and I think you're expecting Gradle to pick it up from slf4j-log4j. AFAIK, it won't.
On Fri, Jul 23, 2010 at 9:17 PM, Dariusz Ludera <[email protected]>wrote: > > > 2010/7/23 Jason Porter <[email protected]> > >> On Fri, Jul 23, 2010 at 10:46, Dariusz Ludera <[email protected]> >> wrote: >> > >> > >> > 2010/7/23 Jason Porter <[email protected]> >> >> >> >> On Fri, Jul 23, 2010 at 05:03, Dariusz Ludera < >> [email protected]> >> >> wrote: >> >> > Hi! >> >> > >> >> > First of all I'd like to say that I'm newbie in gradle. Secondly, I'd >> >> > like >> >> > to use dependencies for example: >> >> > >> >> > compile 'log4j:log4j:1.2.16' >> >> > compile 'org.slf4j:slf4j-log4j12:1.6.1' >> >> > >> >> > to be avialable in testCompile scope. How can I declare it in my >> >> > build.gradle script? >> >> > >> >> > I want to use classes from this libraries in /src/main/java and >> >> > /src/test/java, but when I use it in my test classes, while >> testCompile >> >> > task >> >> > execution I get an error that packages org.slf4j and log4j doesn't >> >> > exist, so >> >> > gradle doesn't include libraries. I've got Maven pom.xml configured >> the >> >> > same >> >> > way as build.gradle and there my tests work correctly. >> >> > >> >> > >> >> > >> >> > -- >> >> > Regards, >> >> > Darek >> >> > >> >> >> >> Just add it as testCompile as well, though you shouldn't have to. >> >> testCompile should be inheriting from compile. Which version of >> >> gradle are you using? >> >> >> >> -- >> >> Jason Porter >> >> http://lightguard-jp.blogspot.com >> >> http://twitter.com/lightguardjp >> >> >> >> Software Engineer >> >> Open Source Advocate >> >> >> >> PGP key id: 926CCFF5 >> >> PGP key available at: keyserver.net, pgp.mit.edu >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe from this list, please visit: >> >> >> >> http://xircles.codehaus.org/manage_email >> >> >> >> >> > >> > Thanks for your replay! >> > >> > Adding as a testCompile didn't help. >> > >> > Here is my dependencies section: >> > >> > dependencies { >> > compile 'log4j:log4j:1.2.16' >> > compile 'org.slf4j:slf4j-log4j12:1.6.1' >> > // for debug reason I removed other dependencies >> > } >> > >> > and output from gradle test run task (info level): >> > >> > :compileTestJava >> > :: resolving dependencies :: #crm;0.1-SNAPSHOT >> > confs: [testCompile] >> > found log4j#log4j;1.2.16 in >> > file:/C:/Documents%20and%20Settings/dludera/.m2/repository/ >> > found org.slf4j#slf4j-log4j12;1.6.1 in >> > file:/C:/Documents%20and%20Settings/dludera/.m2/repository/ >> > :: resolution report :: resolve 16ms :: artifacts dl 0ms >> > >> > (...) and then: >> > MyClassName.java:5: package org.slf4j does not exist >> > import org.slf4j.Logger; >> > >> > So ant compile task couldn't find package org.slf4j which is in >> > :slf4j-log4j12-1.6.1.jar library. I don't underestand why gradle doesn't >> > attach it - maven in the same configuration works fine. I use gradle >> 0.9-p3 >> > with useTestNG(), here is my test section: >> > >> > test { >> > useTestNG() >> > systemProperties 'org.uncommons.reportng.stylesheet': >> > "${projectDir}/resources/hudsonesque.css" >> > options { >> > listeners << 'org.uncommons.reportng.HTMLReporter' >> > listeners << 'org.uncommons.reportng.JUnitXMLReporter' >> > } >> > useDefaultListeners = false >> > } >> > >> > >> > >> > >> > -- >> > Regards, >> > >> > Darek >> > >> >> Very strange, pastebin or send the whole gradle script. >> >> -- >> Jason Porter >> http://lightguard-jp.blogspot.com >> http://twitter.com/lightguardjp >> >> Software Engineer >> Open Source Advocate >> >> PGP key id: 926CCFF5 >> PGP key available at: keyserver.net, pgp.mit.edu >> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email >> >> >> > Yes, it's defenetly strange. Here is my gradle script (without some not > important tasks): > > apply plugin: 'war' > apply plugin: 'eclipse' > apply plugin: 'code-quality' > apply plugin: 'project-reports' > > version = '0.1-SNAPSHOT' > warName = archivesBaseName + '-' + version + '.war' > sourceCompatibility = 1.6 > targetCompatibility = 1.6 > > repositories { > mavenRepo urls: new File(System.getProperty('user.home') + > '/.m2/repository/').toURI().toURL() > mavenCentral() > mavenRepo urls: 'http://download.java.net/maven/2/' > mavenRepo urls: 'http://repository.jboss.com/maven2' > mavenRepo urls: ' > http://oss.sonatype.org/content/repositories/vaadin-snapshots/' > } > > configurations { > findbugsConf > pmdConf > } > > dependencies { > compile 'com.vaadin:vaadin:6.4.0' > runtime 'com.oracle:oracle:11.2.0.1.0' > > compile 'log4j:log4j:1.2.16' > compile 'org.slf4j:slf4j-log4j12:1.6.1' > compile ('org.hibernate:hibernate-entitymanager:3.5.1-Final') { > exclude(module: 'slf4j-api') > } > compile ('org.hibernate:hibernate-validator:4.0.2.GA') > testCompile 'org.uncommons:reportng:1.1.1' > testCompile 'org.testng:testng:5.11:jd...@jar' > findbugsConf 'net.sourceforge.findbugs:findbugs:1.3.2', > 'net.sourceforge.findbugs:findbugs-ant:1.3.2' > pmdConf 'pmd:pmd:4.2.5' > } > > eclipseWtp { > deployName = archivesBaseName > } > > task ide(dependsOn: configurations.runtime.buildArtifacts, type: Copy) { > def libDir = file('lib') > into(libDir) > from configurations.runtime > from configurations.runtime.allArtifacts*.file > from configurations.testRuntime > from configurations.testRuntime.allArtifacts*.file > } > > Here is my dummy class from src/main/java: > package pl.something; > > import org.slf4j.Logger; > import org.slf4j.LoggerFactory; > > import com.vaadin.Application; > import com.vaadin.ui.Button; > import com.vaadin.ui.Window; > > > /** > * The Application's "main" class > */ > @SuppressWarnings("serial") > public class MyVaadinApplication extends Application { > > private static final Logger log = > LoggerFactory.getLogger(MyVaadinApplication.class); > > private Window window; > > private String appName; > > public MyVaadinApplication() { > this.appName = "My Vaadin Application"; > } > > public MyVaadinApplication(String appName) { > this.appName = appName; > } > > @Override > public void init() { > window = new Window(appName); > setMainWindow(window); > window.addComponent(new Button("Click Me")); > > log.info("Clicked!"); > } > > public String getAppName() { > return appName; > } > } > > and here is it's stupid test (from src/test/java): > > package pl.something.test; > > //import org.testng.log4testng.Logger; > > import org.slf4j.Logger; > import org.slf4j.LoggerFactory; > > import org.testng.Assert; > import org.testng.annotations.Test; > import org.testng.annotations.BeforeClass; > > import pl.something.MyVaadinApplication; > > public class MyVaadinApplicationTest { > > private static final Logger log = > LoggerFactory.getLogger(MyVaadinApplicationTest.class); > > private MyVaadinApplication testApp; > > private String testAppName; > > @BeforeClass > public void setUp() { > testAppName = "My Vaadin Test Application"; > testApp = new MyVaadinApplication(testAppName); > > log.info("Setting up ..."); > } > > @Test > public void shouldReturnValidTestAppName() { > Assert.assertEquals(testAppName, testApp.getAppName()); > } > } > > and testng.xml (src/test/resources) > > <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> > <suite name="some_suit"> > <test verbose="1" name="MyVaadinApplicationTest" annotations="JDK"> > <classes> > <class > name="pl.something.test.MyVaadinApplicationTest" /> > </classes> > </test> > </suite> > > -- > Regards! > > Darek >
