I'm trying to use the maven-antrun-plugin to get ant to generate some code for me (wsdlc with WebLogic but this isn't particularly pertinent).
I've passed maven.compile.classpath to the plugin by doing:
in the pom.xml, but when I do:
Compile classpath: ${compile_classpath}
in the build.xml I'm getting:
Compile classpath: ${compile_classpath}
which suggests it hasn't been set.
I've tried adding:
to the pom by way of debug, this gives:
Compile classpath: ${maven.compile.classpath}
which suggests it's not set there either (though I'm not convinced this is the correct thing to do anyway).
Any idea appreciated.
Regards,
Nick
Please ignore this, the problem was caused by a combination of ignorance and typos.
Should anyone want to display the classpath in the pom you need to do something like:
<property name="compile_classpath" refid="${maven.compile.classpath}"/>
<echo message="Compile classpath: $compile_classpath"/>
Related
when we are trying to run mvn eclipse:eclipse from command line, we are getting following error:
Internal error in the plugin manager executing goal
'org.apache.maven.plugins:maven-eclipse-plugin:2.6:eclipse': Unable to
load the mojo
'org.apache.maven.plugins:maven-eclipse-plugin:2.6:eclipse' in the
plugin 'org.apache.maven.plugins:maven-eclipse-plugin'. A required
class is missing:
org/codehaus/plexus/resource/loader/ResourceNotFoundException
any help to solve this is appreciated.
Thanks,
The Apache Maven Eclipse Plugin is RETIRED:
Users are advised to use m2e, the Eclipse Maven Integration instead of this plugin, as it can more closely resemble the actual build and runtime classpaths as described in the project pom.xml - among other advantages.
I'm trying to create an executable jar from IntelliJ.
First I got the Java Security Exception and I changed sqljdbc4-4.0 to unsigned. First problem solved.
Then I got Manifest not found. Added META-INF dir to output. Second problem solved.
Next I got the BeanCreationException (unsolved):
Caused by: org.springframework.beans.factory.BeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath.
In IntelliJ it is working.
I think the resources are not in the output. (application.properties, ...)
In which way do I add the resources or where are they stored in the jar.
I'm using gradle and on the spring boot homepage are only instructions for maven.
You should use spring-boot-maven-plugin or spring-boot-gradle-plugin, depending on your preferred build system.
EDIT:
Just run ./gradlew build
I suggest to dive into this getting started guide. It clarifies a lot of stuff for beginners.
A typical Spring boot project is a Maven project or a Gradle-Project (I only know how to do it with Maven, for Gradle see [luboskrnacs answer][1]). So you just need to run the maven targetpackageand pick the jar form the (created)target` folder
use a shell, go to the project root directory (where the pom.xml file is) and type
mvn clean package
cd target
the there is the xxx.jar file.
I think about using AspectJ in an existing project.
I have several pure Java Eclipse projects and I like to create an AOP project.
I'm not quite sure about when ajc is needed and when optional. We use Ant (with javac) as our main build and I would like to avoid changing the build.
Is the following possible:
I have a AspectJ enabled Eclipse and create my aspect project. I create a jar from this and include this jar with the aspectj jar in the normal eclipse workspace with the other projects.
The build includes my aspect jar and the aspectj jar as dependency jars with javac.
Is this enough for working with the aspects ?
Or do every project of the application needs to be compiled with ajc ?
The main goal is to keep the current structure of Eclipse setup and build environment as as much as possible as it is now.
Or is this only possible with the annotation style ? (if so can someone link me some information about the weaver and how to do this at runtime ?)
Thank you
If you want to weave your aspect into your codebase, you must use AJC. If you only use javac, even with the annotation, your code won't be weaved by your aspects.
That being said, you don't have to add a lot to your ant build.
something like that should do the job:
<path id="ajclasspath">
<path refid="classpath"/>
<pathelement location="${scm.home}/ant_libs/aspectjrt.jar"/>
</path>
<iajc inpath="${classes.dir}" destDir="${classes.dir}" fork="true" maxmem="${aspectj.maxmem}">
<argfiles refid="aspectj.argfiles.path"/>
<classpath refid="ajclasspath"/>
</iajc>
In fact, you just build like normal and you add a step with the iajc taking your output dir of the javac compile as the inpath and you put the result in the same directory.
You can also take a jar as input to iajc and produce a jar with all your stuff weaved inside.
Edit: Or you can use runtime weaving, if your app is a web application, it is not too bad. If not, i do not recommand runtime weaving, since each time you will start your app, it might be a lot longer to start. I don't have a lot of experience with runtime weaving, but you can check it out. I know you need a aop.xml to define your aspects.
Regards
At the end of my ant build id like it to call the equivalent of the command line call
mvn install:install-file -Dfile=my.jar -DgroupId=com.company.project -DartifactId=my_project -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true
so that it will add the newly built jar to a maven repository which another project will rely on.
Ive tried using the maven-ant-task and have added the maven-ant-task jar to the ant built project and the following code to the build.xml:
<target name ="minstall" depends="jar">
<artifact:pom id="maven_install" file="maven_install.xml" />
<artifact:install file="${out.dir}/my_project.jar">
<pom refid="maven_install"/>
</artifact:install>
</target>
but seem to be missing something as it wont work for me. To begin with i get the error in the build.xml (ant build file) saying
The prefix "artifact" for element "artifact:pom" is not bound.
What am I doing wrong. I am fairly new to ant?
On a realted question what is the purpose of the associated POM file? I would not normally have a POM in this project as it is an ant build
Perhaps maven-ant-task jar is not installed, i.e. not in your ant CLASSPATH. You can follow this instruction for this.
As mentioned previously, you need to make sure the tasks are defined in your ant script, and the artifact namespace is understood.
The POM file is used (in this case) to tell the Maven repositories the dependencies of the JAR you are putting in the repository. The POM should also specify the JAR's identification information (groupId, artifactId, version number, license, etc.).
Strictly speaking, you do not need an external POM, you could define the information in your build.xml file as follows:
<!-- Assuming tasks defined, and 'artifact' namespace exists -->
<artifact:pom id="maven_install" groupId="com.whatever" artifactId="some-jar"
version="1.0" packaging="jar">
<dependency groupId="..." artifactId="..." version="..."/>
<dependency groupId="..." artifactId="..." version="..."/>
<license name="apache" url="http://www.apache.org"/> <!-- can be omitted -->
</artifact:pom>
<target name ="minstall" depends="jar">
<artifact:install file="${out.dir}/my_project.jar" pomRefId="maven_install"/>
</target>
When you install the JAR in the 'minstall' task, the POM should be generated with the appropriate dependencies in the local Repository.
That message means you are missing an xmlns:artifact attribute in your build.xml. Have a look at the installation page in the docs for an example.
As to the purpose of the POM file, it's mostly metadata so that maven can figure out dependencies properly. In a real maven build it also describes how to build, test and package. But in your case all that is done by ant instead.
I think that it makes no sense to put such commands in Ant's build.xml. If you want to have your jar file installed in your maven repo just use mvn install command.
Besides that, I guess that you are somehow confusing the purpose of Maven and Ant tools in your project. What I'd suggest is to use Maven as your main build tool. You can configure invokation of Ant targets in your POM file if you really need that. Personally, I think it is the best solution to have Ant called by Maven. Maven goals (such as clean, test, package, install and so on) are very simple to use and powerful (I guess that you can read it in every Maven tutorial).
We have our project build using maven. We try to run our unit test cases in maven build itself and for doing that we need to add DB2 driver jar in the dependency of all the sub projects.
Instead of doing that, we need a solution to specify the absolute path of the jar file as a mvn command line argument to use it in the running of unit test cases.
This is because the driver jar is available in our app server lib folder and we don't want to specify it in the dependencies of our projects.
Couldn't find a suitable solution googling it, hence requesting for an expert solution here.
Any workaround would be of greater help.
Thanks in advance.
The usual way would be to add a dependency to the database driver and limit the dependency to testing (test scope). So the library is available for unit tests but will not deployed and jar'ed.
Practically spoken, I'd create a maven artifact for this driver (just a basic POM file) and place it on the build servers maven repository (or the nexus, if you use it for the projects).
I'm using a dependency with scope set to 'system' to reference a jar that is available in the container but not in any maven repository. In this case the jar is put in a folder named 'lib' in the project like this, :
<dependency>
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
<version>version</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/library.jar</systemPath>
</dependency>
The groupId, artifactId and version can be set to any value you want, the trick was that system dependencies have to be given with an absolute path, which is worked around by using the project.basedir property. It should also be possible to specify the complete path as a property.
We have our project build using maven. We try to run our unit test cases in maven build itself and for doing that we need to add DB2 driver jar in the dependency of all the sub projects.
Well, the maven way would be to declare the DB2 driver as dependency with a test scope in a parent project.
Instead of doing that, we need a solution to specify the absolute path of the jar file as a mvn command line argument to use it in the running of unit test cases.
You could use the additionalClasspathElement in the plugin configuration to pass the path to the driver:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>path/to/additional/resources</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
If you variablelize it, you could pass the value on the command line.
But to be honest, I can't understand why you don't install the driver in a corporate repository and declare it as dependency. And if you don't have a corporate repository, use a file based repo as described in this previous answer (please, don't use the system scope bad practice). There is no good reason to go the hacky way.