Why is sbt missing dependency on Vaadin project - maven

I've created a Vaadin project using maven, and installed the war in my local maven repository.
This project defines a public class, com.whatever.User.
Then, I created an sbt project wherein I'd like to add a depenecy on the Vaadin project - in order to test it's logic. In the build.sbt file of my sbt project I've added:
resolvers += "Local Maven Repository" at "file://"+Path.userHome+"/.m2/repository"
libraryDependencies ++= Seq(
"com.whatever" % "something" % "1.0"
)
After reloading the sbt project I tried using the User object from inside the sbt project. But I'm getting this error:
> test
[info] Compiling 1 Scala source to /Users/me/projects/something-test/target/scala-2.9.1/classes...
[error] /Users/me/projects/something-test/src/main/scala/TryingUser.scala:1: object whatever is not a member of package com
[error] import com.whatever.User
[error] ^
[error] one error found
[error] {file:/Users/me/projects/something-test/}default-1bc94a/compile:compile: Compilation failed
[error] Total time: 3 s, completed 2012-apr-25 13:44:56
what am I missing? Why isn't sbt adding this dependency?

I can't see sbt, or indeed any other build tool, being able to use war files as dependencies. Think about what the classpath passed to javac or java would look like. The compiler will presumably just see it as a standard zip file and won't be aware that the actual classes are in WEB-INF/classes.
I think you'd need to package the classes as a jar file and use that as a dependency.

Related

Dependencies outside of Apache NiFi must not use SNAPSHOT versions

I'm new to NiFi and I'm trying to develop my first custom processor.
I'm following documentation(s)/tutorial(s) on how to create one, and here I am:
generated maven skeleton project for nifi-processor; (✔)
added some simple implementation in the onTrigger(...) method; (✔)
failing to build .nar. (x)
Whenever I'm executing mvn clean package either within any sub-directory of the custom processor project structure (nifi-artifactBaseName-nar or nifi-artifactBaseName-processors) or in the root directory of the project, I get this:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.2.1:enforce (enforce-maven-version) on project nifi-myfirstcustomrprocessor-nar:
[ERROR] Rule 3: org.apache.maven.enforcer.rules.dependency.RequireReleaseDeps failed with message:
[ERROR] Dependencies outside of Apache NiFi must not use SNAPSHOT versions
[ERROR] com.giorgi.tutorials:nifi-myfirstcustomrprocessor-nar:nar:1.0-SNAPSHOT
[ERROR] com.giorgi.tutorials:nifi-myfirstcustomrprocessor-processors:jar:1.0-SNAPSHOT <--- is not a release dependency
Anything I'm doing wrong? any help?
Solved.
When creating a custom processor project (or just any maven project), version 1.0-SNAPSHOT is generated by default (disregarding of whether you create it from command-line, IDE, or etc.), and that's NOT OK for NiFi custom processor - you should NOT use SNAPSHOT for versioning your custom processor artifact.
I just changed 1.0-SNAPSHOT to 1.0 and everything worked fine - .nar has been built.

maven-compiler-plugin compile project with jar library

I have a maven project, which has a library (hello1.jar), that I add with IDEA. In this jar file I have the class ru.training.Hello1. In project I have the class Hello2, which contains field Hello1 hello1. When I try to compile the project with maven lifecycle, I get an error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project Learning: Compilation failure: Compilation failure:
[ERROR] /C:/Projects/Learning/src/main/java/reflection/Hello2.java:[3,19] package ru.training does not exist
[ERROR] /C:/Projects/Learning/src/main/java/reflection/Hello2.java:[7,13] cannot find symbol
[ERROR] symbol: class Hello1
What can I do to fix this error?
In this case you need to add local jar file to local repository and then compile the project. How to add local jar I have read here: How to add local jar files to a Maven project?

How to skip some java files from compilation in maven using command line?

I am using maven with jenkins. On eclipse the project build works fine. When I use jenkins I get the following error
[ERROR] /E:/jenkins/workspace/product/src/test/java/com/new/ftp/FTPTest.java:[102,55] package com.fasterxml.jackson.databind does not exist
The options for maven are as follows:
mvn clean install -X
I want to know if I can pass some arguements to maven to skip that package. I don't want to modify my pom.xml yet .
P.S - The project consists of a main pom.xml which calls other child modules.

SBT dependency on non-SBT library

My Play/SBT project needs to depend on a third-party Java library that is distributed in source form and can be built with either Ant or Maven. Its root directory contains pom.xml and build.xml.
I am thinking of having this library added as a git submodule and have SBT build it as a subproject. I tried adding
externalPom(baseDirectory(_ / "pathToLibrary" / "pom.xml"))
to my build settings, but I ended up with the following compiler error:
[info] Compiling 32 Scala sources and 5 Java sources to /home/thesamet/project]
[error] (compile:compile) scala.reflect.internal.MissingRequirementError: object scala.runtime in compiler mirror not found.
[error] Total time: 1 s, completed Aug 23, 2013 11:46:20 AM
An external pom can only be used to obtain library dependencies of the maven project but not compile it.
You can add an sbt build configuration for the external project or easier, you can publish the third-party module to a corporate Maven or Ivy repository or just local with mvn install and add ~/.m2 as file resolver to your SBT project.

Local Maven Dependency project is referenced as a class folder instead of a jar

I'm using Eclipse Indigo with the m2e Plugin (Version 1.0.1). I have two separate workspace projects: A Maven Project that is basically a Vaadin widget and a second Maven project that is my main project which is referencing that widget with:
<dependency>
<groupId>com.mycompany.widget</groupId>
<artifactId>Calendar</artifactId>
<version>1.2</version>
<type>jar</type>
</dependency>
If I run mvn clean install on the widget project it is packaged properly as a jar and also available in my local Maven repository. I can also use the classes of the widget in my main project. However, in my main project's Maven dependencies, the widget project is shown as a class folder instead of a jar (though all other external widget dependencies are shown as jar files).
This causes some problems when I try to unpack (or even copy) the dependency to my main project with dependency:unpack-dependencies (resp. dependency:copy-dependencies). The maven build fails with:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.4:unpack-dependencies (default-cli) on project [main project]: Error unpacking file: /.../Calendar/target/classes to: /.../[main-project]/target/classes
[ERROR] org.codehaus.plexus.archiver.ArchiverException: The source must not be a directory.
My question is: How can I reference my widget project as a jar instead of a class folder in my main project?
They are in separate directories, right? Try this:
Right-click your project, select Maven -> Disable Workspace Resolution.
Also check the project properties and make sure that the project isn't referenced in Java Build Path -> Projects.

Resources