This is a very basic question but what exactly happens when we add suffix SNAPSHOT to POM.xml file of an AEM project?
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0</version>
I am asking with respect to the behavior of the OSGi container Apache Felix used in AEM.
I believe this has something to do with picking up of bundles as fresh bundle or not.
The OSGi installer always tries to install the highest version of a bundle if several bundles with same symbolic name is present.
However, when you reinstall an existing bundle which has a release version (and not a snapshot), the OSGi installer would ignore the bundle even if there were changes within the bundle.
Whereas, the OSGi installer would update the bundle with all the new changes if you are reinstalling a bundle with a snapshot version.
Bundle Handling section of Apache Sling OSGi installer would give more insights on this.
SNAPSHOT suffix is added to indicate a new version is deployed to the maven repository.Usually during development phase if developers configure pom.xml to get the latest code by adding dependency tag and latest version this will fetch them the latest from repository.
From http://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm#MAVEN401.
SNAPSHOT version references enable Maven to fetch the most recently deployed instance of the SNAPSHOT dependency at a dependent project build time. Note that the SNAPSHOT changes constantly. Whenever an agent deploys the artifact, it is updated in the shared repository. The SNAPSHOT dependency is refetched, on a developer's machine or it is updated in every build. This ensures that dependencies are updated and integrated with the latest changes without the need for changes to the project dependency reference configuration.
For Continuous Integration
Continuous build servers that include the ability to define and execute a job based on a Maven project, such as Hudson, can be configured to recognize when a SNAPSHOT artifact is updated and then rebuild projects that have a dependency on the updated artifact.
For OSGI installer, it will only install new version. But for packages with snapshot qualifier, it will install anyway.
Source: sling.apache.org/documentation/bundles/osgi-installer.html#versions-and-snapshots
Related
My spring boot application works fine when run from Spring Tool Suite. However at the time of project deployment when I use Gradle command to build jar file, I get compile error - with error message saying a specific package is missing.
The root cause was that I had missed to add a specific dependency to build.gradle. After adding the missing dependency the build was successful.
Can someone explain how STS was able to refer to the "missing" dependency and able to run the application successfully in development environment?
Is it that STS and Gradle has two different locations where dependencies are stored?
When using STS (or any other IDE for that matter) and you are manually (or through a wizard) adding jars to the classpath entries those will only be available in your IDE.
What you should be doing is adding additional dependencies to your pom.xml or build.gradle (depending on your tooling), which then in turn should be picked up by your IDE again.
NOTE: Some IDEs will automatically detect additions to the classpath and add them to your build files as well. Not sure if STS (and thus Eclipse) does this.
So first off, a little background.
I am working on converting an Eclipse Java Web Project to Gradle. We use the Vaadin framework and currently manage the project with Ant/Maven/Ivy. We have another project that contains common code that the web project depends on. In both projects our library files, JARs, are simply included in the source and committed to our VCS. With the switch to Gradle we will be using the preferred method of pulling our dependencies from a repository; mainly Maven Central.
I have completed creating the Gradle build scripts that correspond to our current Ant build scripts. I have one Gradle build script for each project, as well as one at the root for configuration injection along with the settings file. I am using the java and eclipse plugins for both projects and additionally the war and vaadin plugins for the web project.
Now to the problem. When I use Gradle to construct the WAR it works perfectly and the WEB-INF/lib directory contains only the JARs that I would expect, based on the dependency configuration. However, when I use Tomcat inside Eclipse to publish the project I end up with a bunch of additional JARs in the WEB-INF/lib directory. Most of the JARs are harmless and just unnecessary, which is why I have excluded them from the WAR, but there are a couple that are actually problematic because Tomcat already has them. In one case it just ignores the JAR and I get the usual message of:
[Tomcat] validateJarFile(*) - jar not loaded.
In the other case I actually receive exceptions in the console, which is troubling even if the application appears to work correctly. I also noticed that all the dependencies associated with the testCompile configuration are also being published, which really doesn't seem right.
The exact offending JARs are tomcat-jdbc and servlet-api-2.5. The tomcat-jdbc JAR is required for compiling our common code. The servlet-api-2.5 JAR is actually just a transitive dependency of vaadin-client-compiler. I have removed the dependency for the vaadin-client-compiler in our web project, because it doesn't appear to be necessary, but it looks like it is still being pulled in by a configuration in the vaadin plugin for Gradle. However, in both cases I am using the providedCompile configuration of the war plugin to exclude them form the WAR.
So my question is, how do I keep Tomcat/Eclipse from publishing these JARs? How do Gradle and Tomcat/Eclipse communicate, or do they at all? From what I can gather it seems that Gradle and Tomcat/Eclipse only communicate indirectly via the .classpath, that the eclipse plugin for Gradle modifies. Also, I have tried the eclipse-wtp plugin for Gradle. It did not seem to resolve the issue because the problematic JARs were still being copied. I am actually not even sure whether I need to use this plugin or if I can just simply use the eclipse plugin.
I should also add that I did install the Gradle Integration for Eclipse "plugin" via the Eclipse Marketplace. With that I used the Configure -> Convert to Gradle Project option that it adds as well as the Gradle -> Refresh Dependencies functionality that it provides. Other than that, I found it to be a little buggy so I've mostly been running Gradle via the command line.
Below is the output of running gradle -v on my machine:
------------------------------------------------------------
Gradle 1.10
------------------------------------------------------------
Build time: 2013-12-17 09:28:15 UTC
Build number: none
Revision: 36ced393628875ff15575fa03d16c1349ffe8bb6
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy: 2.2.0
JVM: 1.8.0_05 (Oracle Corporation 25.5-b02)
OS: Mac OS X 10.9.3 x86_64
Please let me know if additional clarification is required. I assume I must be doing something wrong or missing some configuration because surely my scenario is quite common. Many developers use Tomcat inside Eclipse to test web applications locally and with the popularity of Gradle I would be surprised if someone hasn't run into this before. It would seem the main difference with our switch to Gradle, as far as Tomcat/Eclipse are concerned, is that our dependencies are now being loaded from a repository instead of being linked directly in the source.
Any help is greatly appreciated.
However, when I use Tomcat inside Eclipse to publish the project I end up with a bunch of additional JARs in the WEB-INF/lib directory. Most of the JARs are harmless and just unnecessary, which is why I have excluded them from the WAR, but there are a couple that are actually problematic because Tomcat already has them.
This is a known problem with the gradle eclipse tooling. The problem is that it doesn't understand about dependencies with 'provided' scope. See this issue for some details:
https://issuetracker.springsource.com/browse/STS-2380
There is a workaround for this problem. Some common dependencies that 'cause problems' can be globally excluded via a list of regexps you specify in the preferences. Open menu "Window >> Preferences >> Gradle >> WTP". That's where you can add regexps that will be used to exclude jars from the 'deployment assembly'.
I realize, from the documentation (http://www.playframework.org/documentation/1.2.1/deployment), that if the Play! Framework is already installed and configured properly then creating a deployable war is as simple as running the command:
play war myapp -o myapp.war
But what if the Play! Framework is not installed on the target machine and requirements call for a standard war to be created from either an Ant or Maven build script? How would one go about creating a build script or pom file that could leverage the Play! Framework API to generate the desired war artifact without permanently installing the framework to the target machine. Can this be done easily?
Not straight forward. If you look at the python scripts for the play war command, you will see that quite a lot of processing goes on.
You could replicate this into an ANT or Maven script, but you then lose any backwards compatibility you have to future upgrades. I would suggest either ensuring the relevant Play framework files are included, so that the build can be done, or doing the WAR build on a central build server and distributing (or load from CVS/SVN/GIT) the WAR file to target machine(s).
Typically this would be done as follows:
Build the Play application and generate a WAR on a machine where Play is installed.
Deploy the WAR generated from Play to a Maven repository (preferably a Maven repo server shared amongst the group, or a local Maven repo dir that is synced via version control, or simply checking in the WAR into version control and teammates would install into their local Maven repo via mvn install).
Add the WAR as a dependency in your Maven project so it will be included into the build.
I don't believe it makes since to attempt to build a Play application WAR without having Play installed. The WAR needs to be generated on a machine where Play is installed and then distributed to the other machines as a packaged WAR (preferably via a shared Maven repo server, such as Archiva or Nexus).
As far as I'm aware of, Play framework is packed together in the war file with your app. So trying to build without having play installed or available seems quite difficult.
I have java project that depends from other java projects.
These projects are maven projects.
For manage maven I use
m2eclipse plugin.
Project is a web application running in Tomcat.
The problem, that after some time main project lost dependencies.
In Eclipse assembly they are present, but when I do debug in server (Tomcat) - the are not copied.
So I need do refresh of library projects, clean, update dependencies etc. After Eclipse deploy correct to Tomcat. But it always takes many time for all this clean, update procedures. Is it possible there may be some setting in Eclipse or maven plugin to always deploy last version of library projects? Maybe need set something about cache or snapshot version?
You should not use snapshot dependencies at all.
You can use the <updatePolicy> in settings.xml to control the interval when maven looks for updated versions. See http://maven.apache.org/ref/3.0.3/maven-settings/settings.html
These are set per <repository>, allowed values are: "always", "daily" (default), "interval:XXX" (in minutes) or "never".
I'm trying to create a Maven Web Application project with Google Web Toolkit in NetBeans 6.9. I've followed the steps shown on this video: http://www.youtube.com/watch?v=M-iVZ5TJ21w
After creating the project and adding GWT to the frameworks my project compiles and deploys to Tomcat nicely. Now i like to change the default GWT version from 2.0.3 to 2.2.0. As i edit the gwt.version property in the POM and save the file, NetBeans fetches the new gwt-user-2.2.0.jar file and the javadoc. However if i try to compile the project i get this Maven error in the console:
Downloading: http://repo1.maven.org/maven2/com/google/gwt/gwt-dev/2.2.0/gwt-dev-2.2.0-linux.jar
Unable to find resource 'com.google.gwt:gwt-dev:jar:linux:2.2.0' in repository central (http://repo1.maven.org/maven2)
If i point my browser to the URL http://repo1.maven.org/maven2/com/google/gwt/gwt-dev/2.2.0/ i can see that there's truly no gwt-dev-2.2.0-linux.jar present. However i can see there a gwt-dev-2.2.0.jar which i think will be the correct one to use.
What should i do to fix this error?
You're probably using old version of gwt-maven-plugin. Switch to 2.2.0 or remove version declaration and it'll fetch newest version.
It's also possible that you have some old-format dependency for GWT in your pom. There used to be tag required for old GWT versions. If you have one you can remove tag and it will fetch system independent version without -linux suffix.