Ordering Ivy dependencies - ivy

I'm struggling to get my head around the exact behaviour of exclusions in Ivy.
In the following Ivy file, why does putting commons-logging before log4j pull in javax.activation and javax.mail from log4j whereas putting it after doesn't.
<ivy-module version="2.0">
<info organisation="test" module="test" />
<configurations defaultconfmapping="default->runtime(*)" />
<dependencies>
<dependency org="log4j" name="log4j" rev="1.2.15">
<exclude org="javax.activation" />
<exclude org="javax.mail" />
</dependency>
<dependency org="commons-logging" name="commons-logging" rev="1.1" />
<exclude org="com.sun.jdmk" />
<exclude org="com.sun.jmx" />
<exclude org="javax.jms" />
</dependencies>
</ivy-module>

The activation and mail jars are dependencies of commons logging, yet you've excluded them on the log4j dependency...
When you only use a single configuration this sends a mixed message to ivy, should they be excluded or not? The following would be a lot more explicit:
<dependencies>
<dependency org="log4j" name="log4j" rev="1.2.15"/>
<dependency org="commons-logging" name="commons-logging" rev="1.1" />
<exclude org="javax.activation" />
<exclude org="javax.mail" />
<exclude org="com.sun.jdmk" />
<exclude org="com.sun.jmx" />
<exclude org="javax.jms" />
</dependencies>
It's less confusing when the excludes are set globally.
If you want to keep the dependency resolution separate then you'll need to set up more than one configuration (think of these as dependency sets):
<ivy-module version="2.0">
<info organisation="test" module="test" />
<configurations>
<conf name="log4j_deps" description="log4j dependencies"/>
<conf name="commons_deps" description="commons-logging dependencies"/>
</configurations>
<dependencies>
<dependency org="log4j" name="log4j" rev="1.2.15" conf="log4j_deps->runtime">
<exclude org="javax.activation" />
<exclude org="javax.mail" />
</dependency>
<dependency org="commons-logging" name="commons-logging" rev="1.1" conf="commons_deps->runtime"/>
<exclude org="com.sun.jdmk" />
<exclude org="com.sun.jmx" />
<exclude org="javax.jms" />
</dependencies>
</ivy-module>
Switching around the dependency tags will have no effect now, because the dependency resolution is explicit.
Log4j and its dependencies are associated with the log4j_deps configuration
commons dependencies are placed onto the commons_deps configuration.

Related

IntelliJ Idea 2018.2 - File Status Highlights: red/brown

I have the current status of my files in the folders coloured red/brown.
I tried to follow previous discussion on stackoverflow to solve the problem but without result.
How can get rid of the red colour of the file?
What is the correct settings?
with pom.xml
> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>delta.project</groupId>
<artifactId>books</artifactId>
<version>1.0-SNAPSHOT</version>
<modelVersion>4.0.0</modelVersion>
<properties>
<maven.compiler.source>10</maven.compiler.source>
<maven.compiler.target>10</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>app.Run</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>10</source>
<target>10</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
and iml file:
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_10">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-all:1.9.5" level="project" />
</component>
</module>
Screenshot of my configuration of the project:
modules:
dependencies:
This is a version control feature that marks files that hasn't been staged yet this color.
To remove this behaviour go to
Settings -> Version Control -> File Status Colors
where you can set colors for all statuses or disable them by removing the checkmark from the "File status color" field.
This is because the files are not added into your version control, e.g. Git. Try to select the files, right click, and add them to version control. After that, they should turn into green.

Missing dependency for UmlPTestErrorHandler

I have a MontiCore Project with the following defined dependencies in my ivy.xml:
<dependencies>
<dependency name="de.monticore.re" rev="[2.0.5,2.0.5]" changing="false" />
<dependency name="de.monticore.ets" rev="[2.0.5,2.0.5]" changing="false" />
<dependency name="de.monticore.gli" rev="[2.0.5,2.0.5]" changing="false" />
<dependency name="de.umlp.umlpcore.fe" rev="[1.5.5,1.5.5]" changing="false" />
<dependency name="de.umlp.cd.fe" rev="[1.5.5,1.5.5]" changing="false" />
<dependency name="de.umlp.cdjava.fe" rev="[1.5.5,1.5.5]" changing="false" />
<dependency name="de.monticore.freemarker" rev="[2.0.5,2.0.5]" changing="false" />
<dependency name="de.monticore.java" rev="[2.0.5,2.0.5]" changing="false" />
</dependencies>
I also use the UMLP class diagram language.
Eclipse is complaining that there is no mc.umlp.helpers.UmlPTestErrorHandler.
UmlPTestErrorHandler cannot be resolved AbstractCoCoTest.java /MontiWIS/test/integration/de/montiwis/tool line 31 Java Problem
What am I missing?
UmlPTestErrorHandler no longer exists since version 1.5.4. It was replaced by mc.test.helpers.TestErrorHandler (de.monticore.gli). Use this class.

Apache IVY : Chain tag

I am new to the apache IVY. I was not able to download the springframework.web.servlet from the default repository(MAVEN) as this jar file is not present in maven repository so for adding a new repository which have this file i have used the Chain tag. But the problem is its downloading all the jar files from maven repo and the springframework.web.servlet from other repository but after that its again try to download all the other jar files from the second repository.
ivysettings.xml
<ivysettings>
<settings defaultCache="${ivy.settings.dir}/ivy-cache" defaultResolver="libraries"/>
<resolvers>
<filesystem name="projects">
<artifact pattern="${repository.dir}/[artifact]-[revision].[ext]" />
<ivy pattern="${repository.dir}/[module]-[revision].xml" />
</filesystem>
<chain name="chained">
<ibiblio name="libraries" m2compatible="true" usepoms="false" />
<ibiblio name="lib" m2compatible="true" root="https://oss.sonatype.org/content/repositories/springsource-releases"/>
</chain>
</resolvers>
<modules>
<module organisation="com.virtusa" name="dependee" resolver="projects"/>
<module organisation="org.springframework" name="org.springframework.web.servlet" resolver="lib"/>
</modules>
</ivysettings>
ivy.xml
<ivy-module version="1.0">
<info organisation="com.virtusa" module="depender"/>
<dependencies>
<dependency org="org.springframework" name="spring-core" rev="3.0.4.RELEASE" />
<dependency org="org.springframework" name="spring-aop" rev="3.0.4.RELEASE" />
<dependency org="org.springframework" name="spring-hibernate3" rev="2.0.8" />
<dependency org="org.springframework" name="spring-context" rev="3.0.4.RELEASE" />
<dependency org="org.springframework" name="spring-beans" rev="3.0.4.RELEASE" />
<dependency org="org.springframework" name="spring-web" rev="3.0.4.RELEASE" />
<dependency org="org.springframework" name="spring-webmvc" rev="3.0.4.RELEASE" />
<!-- Added -Bauddhik-->
<dependency org="org.springframework.security" name="spring-security-web" rev="3.0.4.RELEASE"/>
<dependency org="org.springframework.security" name="spring-security-taglibs" rev="3.0.4.RELEASE"/>
<dependency org="org.springframework.security" name="spring-security-core" rev="3.0.4.RELEASE"/>
<dependency org="org.springframework.security" name="spring-security-config" rev="3.0.4.RELEASE"/>
<dependency org="org.springframework.security" name="spring-security-acl" rev="3.0.4.RELEASE"/>
<dependency org="org.springframework" name="spring-instrument-tomcat" rev="3.0.4.RELEASE"/>
<dependency org="org.springframework" name="spring-jdbc" rev="3.0.4.RELEASE"/>
<dependency org="org.springframework" name="spring-context-support" rev="3.0.4.RELEASE"/>
<dependency org="org.springframework" name="spring-orm" rev="3.0.4.RELEASE"/>
<dependency org="org.springframework" name="spring-jms" rev="3.0.4.RELEASE"/>
<dependency org="org.springframework" name="spring-aspects" rev="3.0.4.RELEASE"/>
<dependency org="org.springframework" name="spring-asm" rev="3.0.4.RELEASE"/>
<dependency org="org.springframework" name="spring-expression" rev="3.0.4.RELEASE"/>
<dependency org="javax.transaction" name="jta" rev="1.1"/>
<dependency org="cglib" name="cglib" rev="2.1_3"/>
<dependency org="dom4j" name="dom4j" rev="1.6.1"/>
<dependency org="antlr" name="antlr" rev="2.7.6rc1"/>
<dependency org="org.springframework" name="spring-tx" rev="3.0.4.RELEASE"/>
<dependency org="org.springframework" name="spring-test" rev="3.0.4.RELEASE"/>
<dependency org="org.springframework" name="spring-instrument" rev="3.0.4.RELEASE"/>
<dependency org="org.springframework" name="spring-webmvc-portlet" rev="3.0.4.RELEASE"/>
<dependency org="org.springframework" name="spring-oxm" rev="3.0.4.RELEASE"/>
<dependency org="asm" name="asm" rev="3.3.1"/>
<dependency org="asm" name="asm-attrs" rev="2.2.3"/>
<dependency org="org.springframework" name="org.springframework.web.servlet" rev="3.0.4.RELEASE" />
<!-- end -->
<dependency org="mysql" name="mysql-connector-java" rev="5.1.6" />
<dependency org="org.hibernate" name="hibernate-core" rev="3.3.1.GA" />
<dependency org="org.hibernate" name="hibernate-annotations" rev="3.4.0.GA" />
<dependency org="org.hibernate" name="hibernate-commons-annotations" rev="3.3.0.ga" />
<dependency org="javax.servlet" name="servlet-api" rev="2.5"/>
<dependency org="taglibs" name="standard" rev="1.0.6"/>
<dependency org="javax.servlet" name="jstl" rev="1.2"/>
<dependency org="commons-lang" name="commons-lang" rev="2.0"/>
<dependency org="commons-collections" name="commons-collections" rev="3.1"/>
<dependency org="org.hibernate" name="ejb3-persistence" rev="3.3.2.Beta1"/>
<dependency org="org.hibernate" name="hibernate-ehcache" rev="4.0.1.Final"/>
</dependencies>
</ivy-module>
I think your issue is that your default resolver is still set to be libraries instead of chained.....
Am I correct in assuming you want to use Maven Central for all dependencies, except those exceptions listed in your modules section? If that is so, then you don't need a chained resolver. The following settings file is much simpler:
<ivysettings>
<settings defaultCache="${ivy.settings.dir}/ivy-cache" defaultResolver="central"/>
<resolvers>
<ibiblio name="central" m2compatible="true"/>
<filesystem name="local-projects">
<artifact pattern="${repository.dir}/[artifact]-[revision].[ext]" />
<ivy pattern="${repository.dir}/[module]-[revision].xml" />
</filesystem>
<ibiblio name="spring-releases" m2compatible="true" root="https://oss.sonatype.org/content/repositories/springsource-releases"/>
</resolvers>
<modules>
<module organisation="com.virtusa" name="dependee" resolver="local-projects"/>
<module organisation="org.springframework" name="org.springframework.web.servlet" resolver="spring-releases"/>
</modules>
</ivysettings>
Note:
I've dropped the "usePoms=false" attribute to the Maven central resolver. You're losing one to the main benefits of using a Maven repo. Pulling down dependencies automatically instead of having to reverse engineer other people's builds :-)

JAXB2 Maven Plugin cannot generate annotations or inject-code

I currently have an ant task that does a great job of generating my domain objects from xsd and xjb binding files. It creates the annotations and injects code where I need it based upon a custom Plugin.
Now I'm trying to move all of this to Maven and while I can generate the objects I cannot get the code to inject or add the annotations. My POM plugin entry is as follows:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<bindingDirectory>src/main/resources/jaxb/bindings</bindingDirectory>
<generatePackage>com.noush.web.domain.model.data</generatePackage>
<extension>true</extension>
<verbose>true</verbose>
<args><!-- <arg>-XtoString</arg> -->
<!-- I want to use commons-lang-plugin to generate toString but this can
wait <arg>-Xcommons-lang</arg> <arg>-Xcommons-lang:ToStringStyle=SIMPLE_STYLE</arg> -->
<arg>-Xannotate</arg>
<arg>-Xinject-code</arg>
</args>
<plugins>
<plugin>
<groupId>noush</groupId>
<artifactId>code-expander-plugin</artifactId>
<version>1.0</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
<version>0.6.0</version>
</plugin>
</plugins>
</configuration>
</plugin>
The objects get created but without any injected code or annotations. The output doesn't give any indication that anything is wrong.
If it helps here is my working ant config:
<target name="defineXjcTask">
<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask" classpathref="xjcLib" />
</target>
<target name="generateJaxb">
<xjc target="${build.generated}" package="${noushweb.domain.model.jaxb.package}">
<arg value="-verbose"/>
<arg value="-extension"/>
<arg value="-Xcommons-lang"/>
<arg value="-Xcommons-lang:ToStringStyle=SIMPLE_STYLE"/>
<arg value="-Xinject-code"/>
<arg value="-Xannotate"/>
<schema dir="${build.directory}/jaxb/bindings" includes="${matmWS.mmmws.data.filename}" />
<binding dir="${build.directory}/jaxb/bindings" includes="${matmWS.mmmws.binding.filename}"/>
<produces dir="${build.generated}/${noushweb.domain.model.jaxb.package.dir}" includes="**/*.java" />
</xjc>
</target>
<path id="xjcLib">
<pathelement location="${lib.dir}/jaxb-ri-2.0.5/lib/jaxb-xjc.jar" />
<pathelement location="${ib.dir}/jaxb-ri-2.0.5/lib/jaxb-api.jar" />
<pathelement location="${lib.dir}/jaxb-ri-2.0.5/lib/jaxb-impl.jar" />
<pathelement location="${lib.dir}/jaxb-ri-2.0.5/lib/activation.jar" />
<pathelement location="${lib.dir}/jaxb-ri-2.0.5/lib/jsr173_1.0_api.jar" />
<pathelement location="../lib/stax-api-1.0-2.jar" />
<pathelement location="../lib/jaxb-commons-lang-plugin-2.2.jar" />
<pathelement location="${lib.dir}/commons-lang-2.4/lib/commons-lang-2.4.jar" />
<pathelement location="../lib/code-expander-plugin.jar" />
<pathelement location="../lib/jaxb2-basics-runtime-0.6.0.jar" />
<pathelement location="../lib/jaxb2-basics-tools-0.6.0.jar" />
<pathelement location="../lib/jaxb2-basics-annotate-0.6.0.jar" />
<pathelement location="../lib/annox-0.5.0.jar" />
<pathelement location="${lib.dir}/axis-1_4/lib/commons-logging-1.0.4.jar" />
<pathelement location="${lib.dir}/hibernate-validator-4.1.0.Final/hibernate-validator-4.1.0.Final.jar"/>
<pathelement location="${lib.dir}/hibernate-validator-4.1.0.Final/validation-api-1.0.0.GA.jar"/>
</path>
I guess I could use a antrun kind of setup but I was hoping I could get this to work.
Any thoughts would be most welcome.
Thanks
Noush

Ivy configuration for springsource repo

I`m trying to set up ivy to get jars from the springsource repo.
So far I have for my ivy.xml:-
<dependencies>
<dependency org="org.springframework" name="org.springframework.core" rev="3.0.1.RELEASE"/>
<dependency org="org.springframework" name="org.springframework.aop" rev="3.0.1.RELEASE" />
<dependency org="com.adobe.flex" name="com.springsource.flex.messaging.common" rev="3.2.0.3978"/>
<dependency org="com.adobe.flex" name="com.springsource.flex.messaging" rev="3.2.0.3978" />
</dependencies>
and for my ivysettings.xml:-
<ivysettings>
<settings defaultresolver="spring.chain" deafultcache="C:/repo" />
<resolvers>
<chain name="spring.chain">
<url name="com.springsource.repository.bundles.release">
<ivy pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
<artifact pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
</url>
<url name="com.springsource.repository.bundles.external">
<ivy pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
<artifact pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
</url>
<ibiblio name="ibiblio" m2compatible="true"/>
</chain>
</resolvers>
But I keep getting the errors:-
unknown resolver null
no resolver found for org.springframework#org.springframework.core: check your configuration
unknown resolver null
no resolver found for org.springframework#org.springframework.aop: check your configuration
unknown resolver null
no resolver found for com.adobe.flex#com.springsource.flex.messaging.common: check your configura
unknown resolver null
no resolver found for com.adobe.flex#com.springsource.flex.messaging: check your configuration
Am I missign somethign with regards to the resolvers?
Its due to a typo defaultresolver="spring.chain" should be defaultResolver="spring.chain"