How to use a pom file in the Maven deployer plugin for Gradle?

I need to be able to generate a pom file locally and deploy the project to sonatype.

Here is how I am doing so:

task createPom {
    doLast {
        pom.project {
            groupId = "com.example"

uploadArchives {
    repositories {
        mavenDeployer {
            beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

            repository(url: "") {
                authentication(userName: ossrhUsername, password: ossrhPassword)

            snapshotRepository(url: "") {
                authentication(userName: ossrhUsername, password: ossrhPassword)

            pom.project {
                groupId = "com.example"


As you noticed it doesn’t follow the DRY principle as I am writing the same pom file two times. If I need to add or remove any field in the POM file I need to remove it in both places.
I have an idea. We can say that the uploadArchives task depends on the createPom task like this uploadArchives (dependsOn: createPom). Now we could generate a POM file and then read when use mavenDeployer. But how to tell mavenDeployer to read pom from the file and not generate default pom file? Or if it is possible to generate global pom variable and use it in both tasks.

Can someone clarify how this return boolean is functioning?

This approach I’m seeing is new to me. Typically one returns a boolean true/false value when the method is defined as such. But, what is this doing? I’m thinking that as long as the value is not null it treats it as true otherwise it is false. I cannot figure out how to phrase this in a search to find the answer.


String x = "a";
public boolean demoIt(String valueX){
    return new Integer(valueX);

Ignore the fact there is no try catch just pretend that an alpha value just won’t work and would return a null instead of a throw exception.


String x = "a";
public boolean demoIt(String valueX){
    return new ANYCUSTOMOBJECT(valueX);

Apache Configuration add object instead of String

I have a problem with apache Configuration. Is it possible to add objects and not the string representation of them?

For example, I would like to save the whole ‘SiteNode’ and not the “toString()” variant:

public void persistSiteTree(Context context, Configuration config) {
    List<SiteNode> nodes = Model.getSingleton().getSession().getNodesInContextFromSiteTree(context);
    config.addProperty(CONFIG_PROPERTY_AUTHORISATION, nodes);

public void loadSiteTree(Context context, Configuration config) {
    List<Object> nodes = new ArrayList<>();
    nodes = config.getList(CONFIG_PROPERTY_AUTHORISATION, nodes);
    if(nodes != null && !nodes.isEmpty()) {
        // Load in sites tree
        SiteNode node = (SiteNode) nodes.get(0); // Gives error as String cannot be cast to "SiteNode"

But when I call ‘loadSiteTree’ it gives me String cannot be case to SiteNode. Is it possible for Apache to save the object?

Missing return statement Netbeans ProductDAO

This ProductDAO class returns with a list of products for the user, but the compiler in Netbeans shows that “Missing return statement.” Any advance?

public List<Product> doSelectAvailableProducts( String userid){
    Connection con = null; 
    Statement stmt = null; 
    ResultSet rs = null; 
    List<Product> cl = new ArrayList<Product>(); 
        con = datasource.getConnection(); 
    catch( SQLException e){ 
      stmt = con.createStatement(); 
      String sql = "select * from Product where id not in " +"(select cid from registration where uid ='" + userid + "')";
      rs = stmt.executeQuery(sql); 
      while( ){ 
        Product product = new Product(); 
        product.setDescription( rs.getString("description")); 
        product.setPrice( Double.parseDouble(rs.getString("price"))); cl.add(product); } 
      return cl; 
  catch( SQLException e ){ 
  finally { 
      if(stmt != null) { 
          try { stmt.close();} 
          catch (Exception e) { e.printStackTrace(); } 
      if(con != null) { 
          try { con.close();}
          catch (Exception e) { e.printStackTrace(); }        
      }}  }

Convert Json to gson from InputStreamReader

I got a JSON from URL, it’s loooks like:|

{"total_users_count":1,"users":[{"first_name":"jan","email":"admin@localhost","city":null,"position":"","experience_years":"5 - 8","salary_expectations":"0 - 7300"}]}

In this respons will be more users. My code:

URLConnection urlConnection = url.openConnection();
    urlConnection.setRequestProperty("Authorization", "Basic " + authStringEnc);
    InputStream is = urlConnection.getInputStream();
    InputStreamReader isr = new InputStreamReader(is);

   CandidateDTO candidateDTO = new Gson().fromJson(isr, CandidateDTO.class);

    // using the deserialized object

private class CandidateDTO {
    int total_users_count;
    Map <String, String> first_name;
    String email;
    String city;
    String position;
    Integer experience_years;
    Integer salary_expectations;


Unfortunetly this code doesn’t work and I can’t add user to my Map. What’s wrong with this?

I can’t see Extras Folder in Android Studio Folder

I have android studio installed
want to run my app in my android device
USB hard driver sdk installed
developer mode enabled in device

but in video it says there will be extras folder in android studio folder but there is no any folder with name of extras in this extras folder we have folder of usb driver sdk 🙂

Vudeo ( ) stuck at 5:53 seconds area of video while he going in extras folder for selecting the usb driver sdk which i can’t see in my android studio folder I have new android studio mean updated

Help will be appreciated

Weka in R not working – unable to load weka packages via WPM

I am trying to use the RWeka package in R (Studio). After having installed JAVA to match R (64 bit) I created a WEKA_HOME directory where I have put the folder ‘wekafiles’ earlier stored elsewhere.
So, to summarize, I get an error when trying to install a weka package, e.g.:

WPM(“install-package”, “optics_dbSCan”)
Error in .jcall(wpm, “Z”, “installPackageFromRepository”, args[1L], version, : C:devwekafilesrepCacheoptics_dbSCanLatest.props (The system cannot find the path specified)

I’ve read a lot of threads related to it, but was not able to find a solution which would Weka make work.I really tried several things, but without ever even getting a Weka package installed.

Additional infos: “HOME_” directories:

[1] “C:devwekafiles”
[1] “c:Program FilesJavajre1.8.0_144”
[1] “C:/PROGRA~1/R/R-34~1.0”

Installed packages: RWeka, RWekajars, rJava
Working with RStudio Version 1.0.143
Windows 10, R and Java on 64bit

Any hint is welcome, thanks!

Android – ClassCastException: app crashes when using DialogFragment

I have a RecyclerView in my In each RecyclerView row, I have a button, and when it’s pressed, it supposed to open a customized fragment dialog with RecyclerView list in it (it’s a multi-choice dialog).

In my, which is my other activity, I also have the same button which is supposed to do the same thing (this is why I need the modal to be the fragment dialog). In my, there is no RecyclerView, it’s just a single post (detail page).

My problem:

When I click on the button for the popup on, it opens the dialog fragment popup normally. When I do the same for any individual row in my RecyclerView (which is in, I get a ClassCastException error:

java.lang.ClassCastException: com.example.appname.MainActivity cannot be cast to interfaces.DialogCommunicator$Communicator

My code:


// This code will run when the button is clicked.
// postOptions is a string array of menu items.
Bundle args = new Bundle();
args.putStringArray("displaymenu", postOptions);
mDialogFragment = new CustomDialogFragment();
mDialogFragment.setArguments(args);, "title");


// This code is planted in onClick method listener in onBindViewHolder
// for the button that's supposed to open the fragment dialog.
FragmentManager fm = ((MainActivity) mContext).getSupportFragmentManager();
String[] items = mContext.getResources().getStringArray(R.array.post_options);
CustomDialogFragment customDialogFragment = CustomDialogFragment.newInstance(items);, "title");

public class CustomDialogFragment extends DialogFragment {

    private RecyclerView mRecyclerView;

    public CustomDialogFragment() {
        // Empty constructor is required for DialogFragment
        // Make sure not to add arguments to the constructor
        // Use `newInstance` instead as shown below

    public static CustomDialogFragment newInstance(String[] items) {
        CustomDialogFragment customDialogFragment = new CustomDialogFragment();
        Bundle args = new Bundle();
        args.putStringArray("displaymenu", items);
        return customDialogFragment;

    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.layout_multiselect_dialog, container, false);

    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        Bundle args = getArguments();
        String[] items = args.getStringArray("displaymenu");
        List<String> itemsList = Arrays.asList(items);

        MultiDialogAdapter adapter = new MultiDialogAdapter(getActivity(), itemsList);

        mRecyclerView = (RecyclerView) view.findViewById(;
        mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));



public class MultiDialogAdapter extends RecyclerView.Adapter<MultiDialogViewHolder> {

    private List<String> mItems;
    private LayoutInflater mInflater;
    private CustomFonts mCustomFont;
    private DialogCommunicator.Communicator mCommunicator;

    public MultiDialogAdapter(Context context, List<String> items) {
        this.mInflater = LayoutInflater.from(context);
        this.mItems = items;
        this.mCustomFont = new CustomFonts(context);

        try {
            mCommunicator = (DialogCommunicator.Communicator) context;
        } catch (ClassCastException e) {
            throw new ClassCastException(context.toString());

    public MultiDialogViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = mInflater.inflate(R.layout.layout_multiselect_dialog_row, parent, false);
        return new MultiDialogViewHolder(view);

    public void onBindViewHolder(MultiDialogViewHolder holder, int position) {
        final String item = mItems.get(position);
        holder.getItemTextView().setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {

    public int getItemCount() {
        return mItems.size();


class MultiDialogViewHolder extends RecyclerView.ViewHolder {

    private TextView mItemTextView;

    public MultiDialogViewHolder(View rootView) {
        mItemTextView = (TextView) rootView.findViewById(;

    public TextView getItemTextView() {
        return mItemTextView;


So, I have built the dialog fragment correctly because it works in a normal activity outside of a list, but for each row in a RecyclerView list, that dialog fragment crashes the app because of the ClassCastException. Why?

How to use Grouping and sorted together in JAVA8

I am trying to sort a list and then group the elements. Problem is that when I group the elements sorting order is going for a toss.
Below is my piece of code

This is how my output is coming us the ng the above code

    "Presidential suite": [
            "roomInfoLabel": "Presidential suite",
            "stayAverageRate": "1696.0",
            "roomInfoLabel": "Presidential suite",
            "stayAverageRate": "1729.0",
    "Premier king room": [
            "roomInfoLabel": "Premier king room",
            "stayAverageRate": "370.0",
            "roomInfoLabel": "Premier king room",
            "stayAverageRate": "377.0",

Basically, my requirement is to show cheapest room type first. So the output should be grouped by Premier king room first as it has the cheapest Room of 370£.
Can you please suggest me any alternative method or whats wrong with above implementation, any new ideas are welcome.

Can Spring JPA matched multiple records for List

I have a class called product which has lots of tags.

Such object define as below:

public class Product{
    private List<Tag> tags;

Since a product may has lots of tags. If I want to select a product with tags A and B at the same time. Could I implement it in JPA way?

I can do it easily with native querySELECT t.product_id FROM ta_product p INNER JOIN ta_product_tags t ON = t.product_id GROUP BY t.product_id HAVING SUM(CASE WHEN t.tags_id IN (?1) THEN 1 ELSE 0 END) >= ?2 LIMIT ?3,?4 But it do not support Pageable interface.

I try to write a Query like these

@Query("SELECT COUNT( FROM Product p INNER JOIN p.tags t WHERE SUM(CASE WHEN IN ?1 THEN 1 ELSE 0 END) >= ?2 ")
int countByTags(List<Long> tagIds, long length);

It told me that Invalid use of group function

Any solution that I can make use of Pageable interface?