Overwriting generated target in local maven repository with Maven-Eclipse? - eclipse

Maven won't overwrite the built version of an eclipse project in my local repository. I only changed a META-INF/MANIFEST.MF file, but Maven doesn't seem to recognize that and therefore doesn't overwrite the artifacts in the local repository. How can I force it to overwrite? This is the maven log:
[INFO]
[INFO] --- maven-jar-plugin:2.2:jar (default-jar) # message ---
[INFO]
[INFO] --- maven-install-plugin:2.3:install (default-install) # message ---
[INFO] **Skipped re-installing C:\dev\ws\Message\target\message-0.0.1.jar to C:\Users\Tim\.m2\repository\samba\message\message\0.0.1\message-0.0.1.jar, seems unchanged**
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.915s
[INFO] Finished at: Fri Sep 03 15:22:12 CEST 2010
[INFO] Final Memory: 7M/175M
[INFO] ------------------------------------------------------------------------

Okay, I think I just saw that Maven doesn't deploy the METAINF/MENIFEST.MF file with the other files in the targets. Seems I have to work on that somehow. Sorry, I'm new to Maven.

Be careful when using RELEASE Versions with maven. You should not "redeploy" them - as the contract is that they will never change anymore. If you deploy a RELEASE Version to a global Maven repository (e.g. Nexus) you will not be able to redeploy it again. You have to build a new Version if changes are necessary.
In phases of development use SNAPSHOT Versions (0.0.1-SNAPSHOT). These can be changed and redeployed.
If you are only working with your local repository the rules are not that strong but you should know about the RELEASE / SNAPSHOT version differences.

The problem was that I used the bundle plugin to generate osgi bundles. With these, the bundle plugin generates it's own MANIFEST.MF file and doesn't use the file that I put into my resources. In fact I also got some error when I tried to use my own MANIFEST.MF file in addition to the one generated by the bundle plugin.

Related

Authorization issue in openshift online3

Whenever I try to deploy java application from GitHub to openshift I get authorization issue. This is the log file I am getting while trying to push the image from git to openshift :
Cloning "https://github.com/niladri3/niladritest2.git" ...
Commit: aa3e9851141def47bb9e93d15e5e1ff80224f63e ((commited))
Author: niladri3 <1993niladri#gmail.com>
Date: Wed Jun 28 12:30:22 2017 +0530
Pulling image "registry.access.redhat.com/jboss-webserver-3/webserver30-tomcat8-openshift#sha256:37672e770d6ad5697fffc6fec6eae09108664bb34e8b01768ee58f381d80454a" ...
Pulling image "registry.access.redhat.com/jboss-webserver-3/webserver30-tomcat8-openshift#sha256:37672e770d6ad5697fffc6fec6eae09108664bb34e8b01768ee58f381d80454a" ...
Found pom.xml... attempting to build with 'mvn -e -Popenshift -DskipTests -Dcom.redhat.xpaas.repo.redhatga package -Djava.net.preferIPv4Stack=true '
Picked up JAVA_TOOL_OPTIONS: -Duser.home=/home/jboss -Duser.name=jboss
Using Apache Maven 3.0.5 (Red Hat 3.0.5-17)
Maven home: /usr/share/maven
Java version: 1.8.0_131, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-2.b11.el7_3.x86_64/jre
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "3.10.0-514.25.2.el7.x86_64", arch: "amd64", family: "unix"
Picked up JAVA_TOOL_OPTIONS: -Duser.home=/home/jboss -Duser.name=jboss
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Dashboard Maven Webapp 0.0.1-SNAPSHOT
Downloaded: https://repo1.maven.org/maven2/org/apache/maven/shared/maven-filtering/1.0-beta-2/maven-filtering-1.0-beta-2.jar (33 KB at 437.9 KB/sec
Downloaded: https://repo1.maven.org/maven2/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1.jar (422 KB at 1839.7 KB/sec)
[INFO] Packaging webapp
[INFO] Assembling webapp [Dashboard] in [/home/jboss/source/target/ROOT]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/jboss/source/src/main/webapp]
[INFO] Webapp assembled in [196 msecs]
[INFO] Building war: /home/jboss/source/target/ROOT.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 36.622s
[INFO] Finished at: Thu Jun 29 06:13:56 UTC 2017
[INFO] Final Memory: 16M/307M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "openshift" could not be activated because it does not exist.
Copying all target war artifacts from /home/jboss/source/target directory into /opt/webserver/webapps for later deployment...
'/home/jboss/source/target/ROOT.war' -> '/opt/webserver/webapps/ROOT.war'
Pushing image 172.30.254.23:5000/jd-dashboardcheck/tomcat:latest ...
error: build error: Failed to push image: unauthorized: authentication required
At the end it's saying authentication required even when earlier I used to push in the same way and the image always used to load.
Things I have used:
Eclipse: Maven--In the POM.xml i have changed the filename directory to ROOT
Pushed the project in the GitHub.
Getting error at the time of pushing it from github to Openshift online 3.
Please help if you know the reason why I am getting this error. Thanks in advance.
There are some current issues with builds failing on starter-us-east-1 when pushing images. This is noted at:
https://status.starter.openshift.com/
with details in:
https://bugzilla.redhat.com/show_bug.cgi?id=1462542
See if that matches your problem.

Play activator downloading resources on each run

I am trying to learn Scala by implementing a simple API in Play framework. I am creating an app by command
activator new app play-scala
Then in app folder I'm doing activator run then it starts downloading tons of data from internet. I tried offline:=true in build.sbt and using the offline version activator instead of minimal one but with no success.
[info] Loading project definition from /home/amit/Codes/scala/app/project
[info] Updating {file:/home/amit/Codes/scala/app/project/}app-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to app (in build file:/home/amit/Codes/scala/app/)
[info] Updating {file:/home/amit/Codes/scala/app/}root...
[info] Resolving jline#jline;2.12.1 ...
[info] downloading https://repo1.maven.org/maven2/com/typesafe/play/play-omnidoc_2.11/2.5.3/play-omnidoc_2.11-2.5.3.jar ...
[info] downloading http://repo.typesafe.com/typesafe/ivy-releases/com.typesafe.sbtrc/client-2-11/0.3.1/jars/client-2-11.jar ...
[info] [SUCCESSFUL ] com.typesafe.sbtrc#client-2-11;0.3.1!client-2-11.jar (102499ms)
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-reflect/2.11.5/scala-reflect-2.11.5.jar ...
[info] [SUCCESSFUL ] org.scala-lang#scala-reflect;2.11.5!scala-reflect.jar (136599ms)
[info] downloading http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/serialization_2.11/0.1.0/jars/serialization_2.11.jar ...
[info] [SUCCESSFUL ] org.scala-sbt#serialization_2.11;0.1.0!serialization_2.11.jar (12655ms)
[info] downloading http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/io_2.11/0.13.8-M3/jars/io_2.11.jar ...
I have a very slow connection and I am stuck with it. I don't know something that easy in python-flask can be so difficult in scala-play or am I missing something?
By issuing activator new app play-scala activator only creates a copy of template (usually located at ~/.activator//templates). Of course template itself has to be downloaded first but it is normally tiny.
Effect what you are seeing is that when you run activator run the SBT first time resolves dependencies of your application created according to template. Two situations can happen:
you have already a lot of dependencies in your ~/.ivy2 directory because e.g. you have created project according to the template before or project with similar dependencies via SBT (not strictly with activator). Then the dependencies will be resolved and not downloaded.
you have no dependencies at all in ~/.ivy2 or your template uses such different ones that they have to be downloaded.
Your milage may vary, but important point is that your dependencies are related to your template not activator itself. Another important thing to note is that they have to be definitely downloaded at least once to be used (this is strongly dependent from state of your ~/.ivy2 directory).
I guess that you are trying activator for the first time, or at least play-scala template, thus you have to wait and definitely use better internet connection :)

Can not reflect changes using gwt-maven-plugin superdev

Follow steps in this post,
I use gwt-maven-plugin 2.6.0, when I run mvn gwt:run-codeserver it compiled successfully:
[INFO] binding: user.agent=safari
[INFO] Compiling module com.example.myModule
[INFO] Validating units:
[INFO] Ignored 3 units with compilation errors in first pass.
[INFO] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[INFO] ...
[INFO] Compiling 1 permutation
[INFO] Compiling permutation 0...
[INFO] Source Maps Enabled
[INFO] Compile of permutations succeeded
[INFO] Linking into C:\Users\admin\AppData\Local\Temp\gwt-codeserver-5664784549647002986.tmp\com.example.myModule\compile-4\war\myModule;
Writing extras to C:\Users\admin\AppData\Local\Temp\gwt-codeserver-5664784549647002986.tmp\com.example.myModule\compile-4\extras\myModule
[INFO] Link succeeded
[INFO] Compilation succeeded -- 3.401s
[INFO] Compile completed in 3496 ms
Then I started the dev server using mvn install gwt:run, made changes on my source file and click the Dev Mode On bookmark. After compiling the changes cannot reflect to UI: the UI always show old values.
Any ideas on this problem?
There's a bug in gwt-maven-plugin up to (including) 2.6.0; you have to run mvn process-classes gwt:run-codeserver instead of just mvn gwt:run-codeserver. This is fixed in 2.6.1.
Also, if you change anything in src/main/resources, you'll have to run mvn process-resources to make your changes available to Super Dev Mode (this is because you might use resource filtering, so Super Dev Mode doesn't directly look at src/main/resources).
Similarly, if you use plugins that generate resources or Java sources, you'll have to run them manually (e.g. mvn generate-sources or mvn generate-resources; or just use the same mvn process-resources as above, which will do everything at once). This will be necessary for example if you use gwt:generateAsync and change your GWT-RPC interface (note that you'll also have to redeploy your server-side code).
Note: I just updated my answer in the linked post for GWT 2.6.0, and added a note about GWT-RPC, and the gwt-maven-plugin bug.

SBT publishing via SSH key auth not working

My question is: Why can't I publish from SBT to my server via SSH?
Context:
I am developing a scala library and I want to publish it to a remote repository with SBT v0.12.3 over SSH (using an SFTP resolver). The relevant portion of my project/Build.scala SBT settings file is configured as prescribed by https://github.com/harrah/xsbt/wiki/Resolvers:
publishTo <<= version { v =>
Some(Resolver.sftp(
"My Repository",
"example.com",
"/var/www/public_html/repositories/" + (
if (v.trim.endsWith("SNAPSHOT")) { "snapshots" } else { "releases" }
)
))
},
resolvers ++= Seq(
{
import java.io.File
val privateKeyFile: File = new File(sys.env("HOME") + "/.ssh/id_rsa")
Resolver.ssh("scala-sh", "example.com") as("my-username", privateKeyFile) withPermissions("0644")
},
...
),
When I run sbt publish, things go fine until the authorization, where it still attempts to prompt me for login/password. When I run it locally, it brings up the username/password prompt, and when I try to publish remotely while SSH'd in to a machine it fails with a java.awt.HeadlessException. The result appears to be that the desired private-key type of authentication is not being attempted.
Here is a log of the remote session publish attempt:
> sbt-version
[info] 0.12.3
> publish
[info] Packaging /home/me/my-lib/target/scala-2.10.1/my-lib_2.10.1-SNAPSHOT-sources.jar ...
[info] Done packaging.
[info] Wrote /home/me/my-lib/target/scala-2.10.1/my-lib_2.10.1-SNAPSHOT.pom
[info] :: delivering :: org.example#my-lib_2.10.1;SNAPSHOT :: SNAPSHOT :: release :: Sun Apr 21 12:48:59 PDT 2013
[info] delivering ivy file to /home/me/my-lib/target/scala-2.10.1/ivy-SNAPSHOT.xml
[info] Generating API documentation for main sources...
model contains 75 documentable templates
[info] API documentation generation successful.
[info] Packaging /home/me/my-lib/target/scala-2.10.1/my-lib_2.10.1-SNAPSHOT-javadoc.jar ...
[info] Done packaging.
[info] Packaging my-lib-SNAPSHOT.jar ...
[info] Done packaging.
[trace] Stack trace suppressed: run last *:publish for the full output.
[error] (*:publish) java.awt.HeadlessException:
[error] No X11 DISPLAY variable was set, but this program performed an operation which requires it.
[error] Total time: 35 s, completed Apr 21, 2013 12:49:33 PM
It fails because there is no X11 display. This is unexpected behavior because the SBT project configuration is set to use private key authentication (see resolvers above).
So far I can think of 2 possible causes for the problem, detailed below.
Possible cause #1: Misconfiguration of SBT
Is there a problem in my configuration above?
Possible cause #2: Hitting an Ivy bug from an old version
At time of writing, I am using the latest SBT, 0.12.3. Maybe the version of Ivy being used by SBT is old. The more I think about it, the less likely this seems, but I haven't been able to rule it out yet.
How can I find out what version of Ivy SBT is using?
and then..
IF it is old, is there a way to get SBT to use a newer version of ivy?
There is another relevant question, see ivy ssh publisher, which references[0] an Old Ivy bug which caused java.awt.HeadlessExceptions.
[0] ivy ssh publisher
"Which version of Ivy are you using? There is a Jira Bug for Version 2.0 : issues.apache.org/jira/browse/IVY-783 which should be fixed now."
"Seems like if I upgrade to ivy 2.3 rc-2. SSH publish works."
It may after all be an Ivy version related bug. I am using SBT 0.12.2, which AFAIK is using Ivy 2.0. I am looking at the Ivy cache, located in ~/.ivy2/cache/, where Ivy creates a bunch of XML log files for the dependencies it has resolved, and I can see Ivy module version 2.0 in every XML file generated.
I don't know of a way to update the Ivy version used by SBT, but judging by the default SBT documentation, a possible solution is to manually upgrade Ivy and make sure the default machine wide path points to the right Ivy version.
Then run sbt clean or sbt update to re-fetch dependencies and allow Ivy to regenerate XML config files, etc. for the new Ivy version. More on SBT dependency management HERE:
Ivy Home Directory
By default, sbt uses the standard Ivy home directory location
${user.home}/.ivy2/. This can be configured machine-wide, for use by
both the sbt launcher and by projects, by setting the system property
sbt.ivy.home in the sbt startup script (described in Setup).
For example:
java -Dsbt.ivy.home=/tmp/.ivy2/ ...
Update
By checking the SBT Scala source code for the latest version, the version issue is confirmed again. Even SBT 0.13 appears to be using Ivy version 2.0.0, not 2.3. Have a look at the SBT source code, specifically the last few lines of THIS file.

Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: UnresolvedAddressException

I have integrated Maven with Eclipse and trying to create a maven project. Every time i am trying to create project, its POM.xml shows error.
Multiple annotations found at this line:
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
(execution: default-compile, phase: compile)
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile
(execution: default-testCompile, phase: test-compile)
- CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its
dependencies could not be resolved: Failed to read artifact
descriptor for
org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2:
ArtifactResolutionException: Failure to transfer
org.apache.maven.plugins:maven-compiler-plugin:pom:2.3.2 from
htt:///repo.maven.apache.org/maven2 was cached in the local
repository, resolution will not be reattempted until the update
interval of central has elapsed or updates are forced. Original error:
Could not transfer artifact
org.apache.maven.plugins:maven-compiler-plugin:pom:2.3.2 from/to
central (htt:///repo.maven.apache.org/maven2): null to htt://
repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/2.3.2/maven-compiler-plugin-2.3.2.pom
If I try to run maven-install or any of the maven run option. i get this error
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J:
See htt://www.slf4j.org/codes.html#StaticLoggerBinder for further
details. [INFO] Scanning for projects... [INFO]
[INFO]
------------------------------------------------------------------------ [INFO] Building CQ5 MyApp UI 0.0.1-SNAPSHOT [INFO]
------------------------------------------------------------------------ Downloading:
http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.5/maven-resources-plugin-2.5.pom
[INFO]
------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO]
------------------------------------------------------------------------ [INFO] Total time: 12.289s [INFO] Finished at: Thu Mar 14 14:39:09 IST
2013 [INFO] Final Memory: 1M/15M [INFO]
------------------------------------------------------------------------ [ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or
one of its dependencies could not be resolved: Failed to read artifact
descriptor for
org.apache.maven.plugins:maven-resources-plugin:jar:2.5: Could not
transfer artifact
org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from/to
central (htt://repo.maven.apache.org/maven2): null to
htt://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.5/maven-resources-plugin-2.5.pom:
UnresolvedAddressException -> [Help 1] [ERROR] [ERROR] To see the
full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] [ERROR] For more information about the errors and possible
solutions, please read the following articles: [ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
What should I do?
If you are working on windows like me, just go to C:\Users\Owner.m2\repository and delete all the files in it. Make sure to keep your eclipse close.
Open eclipse and right click on your project, then click on Maven and then in Update Project. A dialog window appears, make sure to have selected ‘clean projects’ and ‘update project configuration from pom.xml’ options.
That should erase all the errors in the project. :)
You do not really have to delete everything from .m2\repository directory. Just the directories for 'problematic libraries', in your example YOUR_MAVEN_REPO.m2\repository\org\apache\maven\plugins\maven-compiler-plugin and delete 2.3.2 folder.
Then right click on the project in Eclipse and Maven->Update Project. You will probably get a different error and you have to repeat the procedure. Do it 3-4 times and it should be fine...
Thank you all for you help and guidance. I got the error myself. I am in a proxy network and was required to set user id and password in settings.xml file of apache maven.
Sounds like you may need to add the sl4j dependency in your pom file. See here: Failed to load class "org.slf4j.impl.StaticLoggerBinder"
Here is the depenedency from the dependency finder in CQ5.5:
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.commons.log</artifactId>
<version>2.1.3-R1232904</version>
<scope>provided</scope>
</dependency>
Hope that helps and good luck.